提交 7bd363aa 编写于 作者: S shawn_he

update doc

Signed-off-by: Nshawn_he <shawn.he@huawei.com>
上级 a0631f1d
......@@ -2,7 +2,7 @@
## Introduction
The Socket Connection module allows an application to transmit data over a Socket connection through the TCP, UDP, or TLS protocol.
The Socket Connection module allows an application to transmit data over a socket connection through the TCP, UDP, or TLS protocol.
## Basic Concepts
......@@ -13,10 +13,11 @@ The Socket Connection module allows an application to transmit data over a Socke
## When to Use
Applications transmit data over TCP, UDP, or TLS Socket connections. The main application scenarios are as follows:
Applications transmit data over TCP, UDP, or TLS socket connections. The main application scenarios are as follows:
- Implementing data transmission over TCP/UDP Socket connections
- Implementing encrypted data transmission over TLS Socket connections
- Implementing data transmission over TCP socket or UDP socket connections
- Implementing data transmission over TCP socket server connections
- Implementing encrypted data transmission over TLS socket connections
## Available APIs
......@@ -28,72 +29,75 @@ Socket connection functions are mainly implemented by the **socket** module. The
| -------- | -------- |
| constructUDPSocketInstance() | Creates a **UDPSocket** object.|
| constructTCPSocketInstance() | Creates a **TCPSocket** object.|
| constructTCPSocketServerInstance() | Creates a **TCPSocketServer** object.|
| listen() | Listens for and accepts TCP socket connections established over the socket. (This API is applicable only to TCP.)|
| bind() | Binds the IP address and port number.|
| send() | Sends data.|
| close() | Closes a Socket connection.|
| getState() | Obtains the Socket connection status.|
| close() | Closes a socket connection.|
| getState() | Obtains the socket connection status.|
| connect() | Connects to the specified IP address and port. This function is supported only for TCP.|
| getRemoteAddress() | Obtains the peer address of the Socket connection. This function is supported only for TCP. The **connect** API must have been called before you use this API.|
| on(type:&nbsp;'message') | Subscribes to **message** events of the Socket connection.|
| off(type:&nbsp;'message') | Unsubscribes from **message** events of the Socket connection.|
| on(type:&nbsp;'close') | Subscribes to **close** events of the Socket connection.|
| off(type:&nbsp;'close') | Unsubscribes from **close** events of the Socket connection.|
| on(type:&nbsp;'error') | Subscribes to **error** events of the Socket connection.|
| off(type:&nbsp;'error') | Unsubscribes from **error** events of the Socket connection.|
| on(type:&nbsp;'listening') | Subscribes to **listening** events of the UDP Socket connection. |
| off(type:&nbsp;'listening') | Unsubscribes from **listening** events of the UDP Socket connection. |
| on(type:&nbsp;'connect') | Subscribes to **connect** events of the TCP Socket connection. |
| off(type:&nbsp;'connect') | Unsubscribes from **connect** events of the TCP Socket connection.|
TLS Socket connection functions are mainly provided by the **tls_socket** module. The following table describes the related APIs.
| getRemoteAddress() | Obtains the peer address of the socket connection. This function is supported only for TCP. The **connect** API must have been called before you use this API.|
| setExtraOptions() | Sets other properties of the socket connection.|
| on(type:&nbsp;'message') | Subscribes to **message** events of the socket connection.|
| off(type:&nbsp;'message') | Unsubscribes from **message** events of the socket connection.|
| on(type:&nbsp;'close') | Subscribes to **close** events of the socket connection.|
| off(type:&nbsp;'close') | Unsubscribes from **close** events of the socket connection.|
| on(type:&nbsp;'error') | Subscribes to **error** events of the socket connection.|
| off(type:&nbsp;'error') | Unsubscribes from **error** events of the socket connection.|
| on(type:&nbsp;'listening') | Subscribes to **listening** events of the UDP socket connection. |
| off(type:&nbsp;'listening') | Unsubscribes from **listening** events of the UDP socket connection. |
| on(type:&nbsp;'connect') | Subscribes to **connect** events of the TCP socket connection. |
| off(type:&nbsp;'connect') | Unsubscribes from **connect** events of the TCP socket connection.|
TLS socket connection functions are mainly provided by the **tls_socket** module. The following table describes the related APIs.
| API| Description|
| -------- | -------- |
| constructTLSSocketInstance() | Creates a **TLSSocket** object.|
| bind() | Binds the IP address and port number.|
| close(type:&nbsp;'error') | Closes a Socket connection.|
| close(type:&nbsp;'error') | Closes a socket connection.|
| connect() | Sets up a connection to the specified IP address and port number.|
| getCertificate() | Obtains an object representing the local certificate.|
| getCipherSuite() | Obtains a list containing information about the negotiated cipher suite.|
| getProtocol() | Obtains a string containing the SSL/TLS protocol version negotiated for the current connection.|
| getRemoteAddress() | Obtains the peer address of the TLS Socket connection.|
| getRemoteAddress() | Obtains the peer address of the TLS socket connection.|
| getRemoteCertificate() | Obtains an object representing a peer certificate.|
| getSignatureAlgorithms() | Obtains a list containing signature algorithms shared between the server and client, in descending order of priority.|
| getState() | Obtains the TLS Socket connection status.|
| off(type:&nbsp;'close') | Unsubscribes from **close** events of the TLS Socket connection.|
| off(type:&nbsp;'error') | Unsubscribes from **error** events of the TLS Socket connection.|
| off(type:&nbsp;'message') | Unsubscribes from **message** events of the TLS Socket connection.|
| on(type:&nbsp;'close') | Subscribes to **close** events of the TLS Socket connection.|
| on(type:&nbsp;'error') | Subscribes to **error** events of the TLS Socket connection.|
| on(type:&nbsp;'message') | Subscribes to **message** events of the TLS Socket connection.|
| getState() | Obtains the TLS socket connection status.|
| off(type:&nbsp;'close') | Unsubscribes from **close** events of the TLS socket connection.|
| off(type:&nbsp;'error') | Unsubscribes from **error** events of the TLS socket connection.|
| off(type:&nbsp;'message') | Unsubscribes from **message** events of the TLS socket connection.|
| on(type:&nbsp;'close') | Subscribes to **close** events of the TLS socket connection.|
| on(type:&nbsp;'error') | Subscribes to **error** events of the TLS socket connection.|
| on(type:&nbsp;'message') | Subscribes to **message** events of the TLS socket connection.|
| send() | Sends data.|
| setExtraOptions() | Sets other properties of the TLS Socket connection.|
| setExtraOptions() | Sets other properties of the TLS socket connection.|
## Transmitting Data over TCP/UDP Socket Connections
## Transmitting Data over TCP Socket or UDP Socket Connections
The implementation is similar for UDP Socket and TCP Socket connections. The following uses data transmission over a TCP Socket connection as an example.
The implementation is similar for UDP socket and TCP socket connections. The following uses data transmission over a TCP socket connection as an example.
1. Import the required **socket** module.
2. Create a **TCPSocket** object.
2. Create a TCP socket connection. A **TCPSocket** object is returned.
3. (Optional) Subscribe to TCP Socket connection events.
3. (Optional) Subscribe to TCP socket connection events.
4. Bind the IP address and port number. The port number can be specified or randomly allocated by the system.
5. Set up a connection to the specified IP address and port number.
6. Send data.
6. Send data over the connection.
7. Enable the TCP Socket connection to be automatically closed after use.
7. Enable the TCP socket connection to be automatically closed after use.
```js
import socket from '@ohos.net.socket'
// Create a TCPSocket object.
// Create a TCP socket connection. A TCPSocket object is returned.
let tcp = socket.constructTCPSocketInstance();
// Subscribe to TCP Socket connection events.
// Subscribe to events of the TCPSocket object.
tcp.on('message', value => {
console.log("on message")
let buffer = value.message
......@@ -139,7 +143,7 @@ tcp.bind(bindAddress, err => {
}
console.log('connect success');
// Send data.
// Send data over the connection.
tcp.send({
data: 'Hello, server!'
}, err => {
......@@ -152,7 +156,7 @@ tcp.bind(bindAddress, err => {
});
});
// Enable the TCP Socket connection to be automatically closed after use. Then, disable listening for TCP Socket connection events.
// Enable the socket connection to be automatically closed after use. Then, unsubscribe from events of the connection.
setTimeout(() => {
tcp.close((err) => {
console.log('close socket.')
......@@ -163,11 +167,92 @@ setTimeout(() => {
}, 30 * 1000);
```
## Implementing Data Transmission over TCP Socket Server Connections
### How to Develop
The TCP socket server connection process is described as follows:
1. Import the required **socket** module.
2. Create a TCP socket server connection. A **TCPSocketServer** object is returned.
3. Bind the local IP address and port, and listen for and accept TCP socket connections established over the socket.
4. Subscribe to **connect** events of the **TCPSocketServer** object to listen for client connection status changes.
5. Set up a connection between the client and the server. A **TCPSocketConnection** object is returned.
6. Subscribe to events of the **TCPSocketConnection** object, and send data to the client through the **TCPSocketConnection** object.
7. Close the connection between the client and the server.
8. Unsubscribe from events of the **TCPSocketConnection** and **TCPSocketServer** objects.
```js
import socket from '@ohos.net.socket'
// Create a TCP socket server connection. A TCPSocketServer object is returned.
let tcpServer = socket.constructTCPSocketServerInstance();
// Bind the local IP address and port number for listening.
tcpServer.listen({ address: "192.168.xx.xxx", port: xxxx, family: 1 }, err => {
if (err) {
console.log("listen fail");
return;
}
console.log("listen success");
})
// Subscribe to connect events of the TCPSocketServer object.
tcpServer.on('connect', function(client) {
// Subscribe to events of the TCPSocketConnection object.
client.on('close', () => {
console.log("on close success");
});
client.on('message', function(value) {
let buffer = value.message;
let dataView = new DataView(buffer);
let str = "";
for (let i = 0; i < dataView.byteLength; ++i) {
str += String.fromCharCode(dataView.getUint8(i));
}
console.log("received message--:" + str);
console.log("received address--:" + value.remoteInfo.address);
console.log("received family--:" + value.remoteInfo.family);
console.log("received port--:" + value.remoteInfo.port);
console.log("received size--:" + value.remoteInfo.size);
});
// Send data to the client.
client.send({data: 'Hello, client!'}, err => {
if (err) {
console.log('send fail');
return;
}
console.log('send success');
});
// Close the connection between the client and the server.
client.close(err => {
if (err) {
console.log('close fail');
return;
}
console.log('close success');
});
// Unsubscribe from events of the TCPSocketConnection object.
setTimeout(() => {
client.off('message');
client.off('close');
}, 10 * 1000);
});
// Unsubscribe from events of the TCPSocketServer object.
setTimeout(() => {
tcpServer.off('connect');
}, 30 * 1000);
```
## Implementing Encrypted Data Transmission over TLS Socket Connections
### How to Develop
TLS Socket connection process on the client:
The TLSsocket connection process on the client is described as follows:
1. Import the required **socket** module.
......@@ -175,21 +260,21 @@ TLS Socket connection process on the client:
3. For two-way authentication, upload the client CA certificate and digital certificate. For one-way authentication, upload the client CA certificate.
4. Create a **TLSSocket** object.
4. Create a TLS socket connection. A **TLSsocket** object is returned.
5. (Optional) Subscribe to TLS Socket connection events.
5. (Optional) Subscribe to TLS socket connection events.
6. Send data.
6. Send data over the connection.
7. Enable the TLS Socket connection to be automatically closed after use.
7. Enable the TLS socket connection to be automatically closed after use.
```js
import socket from '@ohos.net.socket'
// Create a TLS Socket connection (for two-way authentication).
// Create a TLS socket connection (for two-way authentication). A TLSSocket object is returned.
let tlsTwoWay = socket.constructTLSSocketInstance();
// Subscribe to TLS Socket connection events.
// Subscribe to TLS socket connection events.
tlsTwoWay.on('message', value => {
console.log("on message")
let buffer = value.message
......@@ -246,7 +331,7 @@ tlsTwoWay.connect(options, (err, data) => {
console.log(data);
});
// Enable the TCP Socket connection to be automatically closed after use. Then, disable listening for TCP Socket connection events.
// Enable the socket connection to be automatically closed after use. Then, unsubscribe from events of the connection.
tlsTwoWay.close((err) => {
if (err) {
console.log("close callback error = " + err);
......@@ -258,10 +343,10 @@ tlsTwoWay.close((err) => {
tlsTwoWay.off('close');
});
// Create a TLS Socket connection (for one-way authentication).
// Create a TLS socket connection (for one-way authentication). A TLSsocket object is returned.
let tlsOneWay = socket.constructTLSSocketInstance(); // One way authentication
// Subscribe to TLS Socket connection events.
// Subscribe to TLS socket connection events.
tlsTwoWay.on('message', value => {
console.log("on message")
let buffer = value.message
......@@ -307,7 +392,7 @@ tlsOneWay.connect(oneWayOptions, (err, data) => {
console.log(data);
});
// Enable the TCP Socket connection to be automatically closed after use. Then, disable listening for TCP Socket connection events.
// Enable the socket connection to be automatically closed after use. Then, unsubscribe from events of the connection.
tlsTwoWay.close((err) => {
if (err) {
console.log("close callback error = " + err);
......@@ -319,11 +404,3 @@ tlsTwoWay.close((err) => {
tlsTwoWay.off('close');
});
```
## Samples
The following samples are provided to help you better understand how to develop Socket connection features:
- [`Socket`: Socket Connection (ArkTS) (API9)] (https://gitee.com/openharmony/applications_app_samples/tree/master/code/BasicFeature/Connectivity/Socket)
- [UDP Socket (ArkTS) (API9)](https://gitee.com/openharmony/codelabs/tree/master/NetworkManagement/UdpDemoOH)
- [TCP Socket (ArkTS) (API9)](https://gitee.com/openharmony/codelabs/tree/master/NetworkManagement/TcpSocketDemo)
# @ohos.ai.mindSporeLite (Inference)
MindSpore Lite is an AI engine that implements AI model inference for different hardware devices. It has been used in a wide range of fields, such as image classification, target recognition, facial recognition, and character recognition.
The **mindSporeLite** module provides APIs for the MindSpore Lite inference engine to implment model inference.
The **mindSporeLite** module provides APIs for the MindSpore Lite inference engine to implement model inference.
> **NOTE**
>
......@@ -48,7 +48,7 @@ Defines the CPU backend device option.
| threadNum | number | Yes | Yes | Number of runtime threads. The default value is **2**. |
| threadAffinityMode | [ThreadAffinityMode](#threadaffinitymode) | Yes | Yes | Affinity mode for binding runtime threads to CPU cores. The default value is **mindSporeLite.ThreadAffinityMode.NO_AFFINITIES**.|
| threadAffinityCoreList | number[] | Yes | Yes | List of CPU cores bound to runtime threads. Set this parameter only when **threadAffinityMode** is set. If **threadAffinityMode** is set to **mindSporeLite.ThreadAffinityMode.NO_AFFINITIES**, this parameter is empty. The number in the list indicates the SN of the CPU core. The default value is **[]**.|
| precisionMode | string | Yes | Yes | Whether to enable the Float16 inference mode. The value **preferred_fp16** means to enable half-precision inference and the default value **force_fp32** means to disable half-precision inference. Other settings are not supported.|
| precisionMode | string | Yes | Yes | Whether to enable the Float16 inference mode. The value **preferred_fp16** means to enable half-precision inference and the default value **enforce_fp32** means to disable half-precision inference. Other settings are not supported.|
**Float16 inference mode**: a mode that uses half-precision inference. Float16 uses 16 bits to represent a number and therefore it is also called half-precision.
......@@ -125,7 +125,7 @@ Loads the input model from the full path for model inference. This API uses an a
```js
let context: mindSporeLite.Context = {};
let context = {'target': ['cpu']};
context = {'target': ['cpu']};
let model_file = '/path/to/xxx.ms';
mindSporeLite.loadModelFromFile(model_file, context, (result) => {
const modelInputs = result.getInputs();
......@@ -181,17 +181,17 @@ Loads the input model from the memory for inference. This API uses an asynchrono
```js
import resourceManager from '@ohos.resourceManager'
@State modelName: string = 'xxx.ms';
let modelName = '/path/to/xxx.ms';
let syscontext = globalThis.context;
syscontext.resourceManager.getRawFileContent(this.modelName).then((buffer) => {
this.modelBuffer = buffer;
syscontext.resourceManager.getRawFileContent(modelName).then((buffer) => {
let modelBuffer = buffer;
mindSporeLite.loadModelFromBuffer(modelBuffer.buffer, (result) => {
const modelInputs = result.getInputs();
console.log(modelInputs[0].name);
})
}).catch(error => {
console.error('Failed to get buffer, error code: ${error.code},message:${error.message}.');
})
mindSporeLite.loadModelFromBuffer(this.modelBuffer.buffer, (result) => {
const modelInputs = result.getInputs();
console.log(modelInputs[0].name);
})
```
## mindSporeLite.loadModelFromBuffer
......@@ -213,19 +213,19 @@ Loads the input model from the memory for inference. This API uses an asynchrono
```js
import resourceManager from '@ohos.resourceManager'
@State modelName: string = 'xxx.ms';
let modelName = '/path/to/xxx.ms';
let syscontext = globalThis.context;
syscontext.resourceManager.getRawFileContent(this.modelName).then((error,buffer) => {
this.modelBuffer = buffer;
syscontext.resourceManager.getRawFileContent(modelName).then((error,buffer) => {
let modelBuffer = buffer;
let context: mindSporeLite.Context = {};
context = {'target': ['cpu']};
mindSporeLite.loadModelFromBuffer(modelBuffer.buffer, context, (result) => {
const modelInputs = result.getInputs();
console.log(modelInputs[0].name);
})
}).catch(error => {
console.error('Failed to get buffer, error code: ${error.code},message:${error.message}.');
})
let context: mindSporeLite.Context = {};
context = {'target': ['cpu']};
mindSporeLite.loadModelFromBuffer(this.modelBuffer.buffer, context, (result) => {
const modelInputs = result.getInputs();
console.log(modelInputs[0].name);
})
```
## mindSporeLite.loadModelFromBuffer
......@@ -252,17 +252,17 @@ Loads the input model from the memory for inference. This API uses a promise to
```js
import resourceManager from '@ohos.resourceManager'
@State modelName: string = 'xxx.ms';
let modelName = '/path/to/xxx.ms';
let syscontext = globalThis.context;
syscontext.resourceManager.getRawFileContent(this.modelName).then((buffer) => {
this.modelBuffer = buffer;
syscontext.resourceManager.getRawFileContent(modelName).then((buffer) => {
let modelBuffer = buffer;
mindSporeLite.loadModelFromBuffer(modelBuffer.buffer).then((result) => {
const modelInputs = result.getInputs();
console.log(modelInputs[0].name);
})
}).catch(error => {
console.error('Failed to get buffer, error code: ${error.code},message:${error.message}.');
})
mindSporeLite.loadModelFromBuffer(model_file).then((result) => {
const modelInputs = result.getInputs();
console.log(modelInputs[0].name);
})
```
## mindSporeLite.loadModelFromFd
......@@ -284,7 +284,7 @@ Loads the input model based on the specified file descriptor for inference. This
```js
import fs from '@ohos.file.fs';
let model_file = '/path/to/xxx.ms';
let file = await fs.open(model_file, 0);
let file = fs.openSync(model_file, fs.OpenMode.READ_ONLY);
mindSporeLite.loadModelFromFd(file.fd, (result) => {
const modelInputs = result.getInputs();
console.log(modelInputs[0].name);
......@@ -313,7 +313,7 @@ import fs from '@ohos.file.fs';
let model_file = '/path/to/xxx.ms';
let context : mindSporeLite.Context = {};
context = {'target': ['cpu']};
let file = await fs.open(model_file, 0);
let file = fs.openSync(model_file, fs.OpenMode.READ_ONLY);
mindSporeLite.loadModelFromFd(file.fd, context, (result) => {
const modelInputs = result.getInputs();
console.log(modelInputs[0].name);
......@@ -345,7 +345,7 @@ Loads the input model based on the specified file descriptor for inference. This
```js
import fs from '@ohos.file.fs';
let model_file = '/path/to/xxx.ms';
let file = await fs.open(model_file, 0);
let file = fs.openSync(model_file, fs.OpenMode.READ_ONLY);
let mindSporeLiteModel = await mindSporeLite.loadModelFromFd(file.fd);
mindSporeLite.loadModelFromFd(file.fd).then((result) => {
const modelInputs = result.getInputs();
......@@ -383,9 +383,9 @@ mindSporeLite.loadModelFromFile(model_file).then((result) => {
```
### predict
predict(inputs: MSTensor[], callback: Callback&lt;Model&gt;): void
predict(inputs: MSTensor[], callback: Callback&lt;MSTensor[]&gt;): void
Executes the inference model. This API uses an asynchronous callback to return the result.
Executes the inference model. This API uses an asynchronous callback to return the result. Ensure that the model object is not reclaimed when being invoked.
**System capability**: SystemCapability.AI.MindSporeLite
......@@ -394,20 +394,20 @@ Executes the inference model. This API uses an asynchronous callback to return t
| Name| Type | Mandatory| Description |
| ------ | ----------------------- | ---- | -------------------------- |
| inputs | [MSTensor](#mstensor)[] | Yes | Model input, which is an **MSTensor** object.|
| callback | Callback<[Model](#model)> | Yes | Callback used to return the result, which is a **Model** object.|
| callback | Callback<[MSTensor](#mstensor)[]> | Yes | Callback used to return the result, **MSTensor** object.|
**Example**
```js
import resourceManager from '@ohos.resourceManager'
@State inputName: string = 'input_data.bin';
let inputName = 'input_data.bin';
let syscontext = globalThis.context;
syscontext.resourceManager.getRawFileContent(this.inputName).then((buffer) => {
this.inputBuffer = buffer;
syscontext.resourceManager.getRawFileContent(inputName).then(async (buffer) => {
let inputBuffer = buffer;
let model_file = '/path/to/xxx.ms';
let mindSporeLiteModel = await mindSporeLite.loadModelFromFile(model_file);
const modelInputs = mindSporeLiteModel.getInputs();
modelInputs[0].setData(this.inputBuffer.buffer);
modelInputs[0].setData(inputBuffer.buffer);
result.predict(modelInputs, (result) => {
let output = new Float32Array(result[0].getData());
for (let i = 0; i < output.length; i++) {
......@@ -420,7 +420,7 @@ syscontext.resourceManager.getRawFileContent(this.inputName).then((buffer) => {
predict(inputs: MSTensor[]): Promise&lt;MSTensor[]&gt;
Executes the inference model. This API uses a promise to return the result.
Executes the inference model. This API uses a promise to return the result. Ensure that the model object is not reclaimed when being invoked.
**System capability**: SystemCapability.AI.MindSporeLite
......@@ -440,14 +440,14 @@ Executes the inference model. This API uses a promise to return the result.
```js
import resourceManager from '@ohos.resourceManager'
@State inputName: string = 'input_data.bin';
let inputName = 'input_data.bin';
let syscontext = globalThis.context;
syscontext.resourceManager.getRawFileContent(this.inputName).then((buffer) => {
this.inputBuffer = buffer;
syscontext.resourceManager.getRawFileContent(inputName).then(async (buffer) => {
let inputBuffer = buffer;
let model_file = '/path/to/xxx.ms';
let mindSporeLiteModel = await mindSporeLite.loadModelFromFile(model_file);
const modelInputs = mindSporeLiteModel.getInputs();
modelInputs[0].setData(this.inputBuffer.buffer);
modelInputs[0].setData(inputBuffer.buffer);
result.predict(modelInputs).then((result) => {
let output = new Float32Array(result[0].getData());
for (let i = 0; i < output.length; i++) {
......@@ -541,14 +541,14 @@ Obtains tensor data.
```js
import resourceManager from '@ohos.resourceManager'
@State inputName: string = 'input_data.bin';
let inputName = 'input_data.bin';
let syscontext = globalThis.context;
syscontext.resourceManager.getRawFileContent(this.inputName).then((buffer) => {
this.inputBuffer = buffer;
syscontext.resourceManager.getRawFileContent(inputName).then(async (buffer) => {
let inputBuffer = buffer;
let model_file = '/path/to/xxx.ms';
let mindSporeLiteModel = await mindSporeLite.loadModelFromFile(model_file);
const modelInputs = mindSporeLiteModel.getInputs();
modelInputs[0].setData(this.inputBuffer.buffer);
modelInputs[0].setData(inputBuffer.buffer);
result.predict(modelInputs).then((result) => {
let output = new Float32Array(result[0].getData());
for (let i = 0; i < output.length; i++) {
......@@ -576,15 +576,15 @@ Sets the tensor data.
```js
import resourceManager from '@ohos.resourceManager'
@State inputName: string = 'input_data.bin';
let inputName = 'input_data.bin';
let syscontext = globalThis.context;
syscontext.resourceManager.getRawFileContent(this.inputName).then((buffer) => {
this.inputBuffer = buffer;
syscontext.resourceManager.getRawFileContent(inputName).then(async (buffer) => {
inputBuffer = buffer;
let model_file = '/path/to/xxx.ms';
let mindSporeLiteModel = await mindSporeLite.loadModelFromFile(model_file);
const modelInputs = mindSporeLiteModel.getInputs();
modelInputs[0].setData(inputBuffer.buffer);
})
let model_file = '/path/to/xxx.ms';
let mindSporeLiteModel = await mindSporeLite.loadModelFromFile(model_file);
const modelInputs = mindSporeLiteModel.getInputs();
modelInputs[0].setData(this.inputBuffer.buffer);
```
## DataType
......
......@@ -16,7 +16,7 @@ import runningLock from '@ohos.runningLock';
isSupported(type: RunningLockType): boolean;
Checks whether the specified type of **RunningLock** is supported. This API uses an asynchronous callback to return the result.
Checks whether the specified type of **RunningLock** is supported.
**System capability:** SystemCapability.PowerManager.PowerManager.Core
......@@ -26,7 +26,7 @@ Checks whether the specified type of **RunningLock** is supported. This API uses
| ------ | ----------------------------------- | ---- | -------------------- |
| type | [RunningLockType](#runninglocktype) | Yes | Type of the **RunningLock** object.|
**Return Value**
**Return value**
| Type | Description |
| ------- | --------------------------------------- |
......@@ -69,14 +69,6 @@ Creates a **RunningLock** object.
| type | [RunningLockType](#runninglocktype) | Yes | Type of the **RunningLock** object to be created. |
| callback | AsyncCallback<[RunningLock](#runninglock)> | Yes | Callback used to return the result. If a lock is successfully created, **err** is **undefined** and **data** is the created **RunningLock**. Otherwise, **err** is an error object.|
**Error codes**
For details about the error codes, see [RunningLock Error Codes](../errorcodes/errorcode-runninglock.md).
| ID | Error Message |
|---------|----------|
| 4900101 | If connecting to the service failed. |
**Example**
```js
......@@ -106,20 +98,12 @@ Creates a **RunningLock** object.
| name | string | Yes | Name of the **RunningLock** object. |
| type | [RunningLockType](#runninglocktype) | Yes | Type of the **RunningLock** object to be created.|
**Return Value**
**Return value**
| Type | Description |
| ------------------------------------------ | ------------------------------------ |
| Promise&lt;[RunningLock](#runninglock)&gt; | Promise used to return the result.|
**Error codes**
For details about the error codes, see [RunningLock Error Codes](../errorcodes/errorcode-runninglock.md).
| ID | Error Message |
|---------|----------|
| 4900101 | If connecting to the service failed. |
**Example**
```js
......@@ -138,7 +122,7 @@ isRunningLockTypeSupported(type: RunningLockType, callback: AsyncCallback&lt;boo
> **NOTE**<br>This API is deprecated since API version 9. You are advised to use [runningLock.isSupported](#runninglockissupported9).
Checks whether the specified type of **RunningLock** is supported. This API uses an asynchronous callback to return the result. This API uses an asynchronous callback to return the result.
Checks whether the specified type of **RunningLock** is supported. This API uses an asynchronous callback to return the result.
**System capability:** SystemCapability.PowerManager.PowerManager.Core
......@@ -167,7 +151,7 @@ isRunningLockTypeSupported(type: RunningLockType): Promise&lt;boolean>
> **NOTE**<br>This API is deprecated since API version 9. You are advised to use [runningLock.isSupported](#runninglockissupported9).
Checks whether the specified type of **RunningLock** is supported. This API uses an asynchronous callback to return the result. This API uses a promise to return the result.
Checks whether the specified type of **RunningLock** is supported. This API uses a promise to return the result.
**System capability:** SystemCapability.PowerManager.PowerManager.Core
......@@ -177,7 +161,7 @@ Checks whether the specified type of **RunningLock** is supported. This API uses
| ------ | ----------------------------------- | ---- | -------------------- |
| type | [RunningLockType](#runninglocktype) | Yes | Type of the **RunningLock** object.|
**Return Value**
**Return value**
| Type | Description |
| ---------------------- | ---------------------------------------------------- |
......@@ -246,7 +230,7 @@ Creates a **RunningLock** object.
| name | string | Yes | Name of the **RunningLock** object. |
| type | [RunningLockType](#runninglocktype) | Yes | Type of the **RunningLock** object to be created.|
**Return Value**
**Return value**
| Type | Description |
| ------------------------------------------ | ------------------------------------ |
......@@ -354,7 +338,7 @@ Checks the hold status of the **Runninglock** object.
**System capability:** SystemCapability.PowerManager.PowerManager.Core
**Return Value**
**Return value**
| Type | Description |
| ------- | ------------------------------------------------------------ |
......@@ -452,7 +436,7 @@ Checks the hold status of the **Runninglock** object.
**System capability:** SystemCapability.PowerManager.PowerManager.Core
**Return Value**
**Return value**
| Type | Description |
| ------- | ------------------------------------------------------------ |
| boolean | The value **true** indicates that the **Runninglock** object is held; and the value **false** indicates that the **Runninglock** object is released.|
......@@ -478,5 +462,5 @@ Enumerates the types of **RunningLock** objects.
| Name | Value | Description |
| --------------------------------- | ---- | ------------------------------------------------------------ |
| BACKGROUND<sup>(deprecated)</sup> | 1 | A lock that prevents the system from hibernating when the screen is off.<br>**NOTE**<br>This parameter is supported since API version 7 and deprecated since API version 10.|
| BACKGROUND<sup>(deprecated)</sup> | 1 | A lock that prevents the system from hibernating when the screen is off.<br>**NOTE**<br/>This parameter is supported since API version 7 and deprecated since API version 10.|
| PROXIMITY_SCREEN_CONTROL | 2 | A lock that determines whether to turn on or off the screen based on the distance away from the screen. |
......@@ -137,7 +137,7 @@ Checks whether the application has the permission to access the device.
**Example**
```js
let devicesName="1-1";
let devicesName= "1-1";
let bool = usb.hasRight(devicesName);
console.log(bool);
```
......@@ -165,7 +165,7 @@ Requests the temporary permission for the application to access a USB device. Th
**Example**
```js
let devicesName="1-1";
let devicesName= "1-1";
usb.requestRight(devicesName).then((ret) => {
console.log(`requestRight = ${ret}`);
});
......@@ -375,7 +375,14 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**Example**
```js
let param = new usb.USBControlParams();
let param = {
request: 0,
reqType: 0,
target:0,
value: 0,
index: 0,
data: null
};
usb.controlTransfer(devicepipe, param).then((ret) => {
console.log(`controlTransfer = ${ret}`);
})
......@@ -500,7 +507,7 @@ Converts the USB function list in the numeric mask format to a string in Device
**Example**
```js
let funcs = usb.ACM | usb.ECM;
let funcs = usb.FunctionType.ACM | usb.FunctionType.ECM;
let ret = usb.usbFunctionsToString(funcs);
```
......@@ -529,8 +536,12 @@ Sets the current USB function list in Device mode.
**Example**
```js
let funcs = usb.HDC;
let ret = usb.setCurrentFunctions(funcs);
let funcs = usb.FunctionType.HDC;
usb.setCurrentFunctions(funcs).then(() => {
console.info('usb setCurrentFunctions successfully.');
}).catch(err => {
console.error('usb setCurrentFunctions failed: ' + err.code + ' message: ' + err.message);
});
```
## usb.getCurrentFunctions<sup>9+</sup>
......@@ -848,7 +859,7 @@ Enumerates power role types.
| Name | Value | Description |
| ------ | ---- | ---------- |
| NONE | 0 | None |
| NONE | 0 | None. |
| SOURCE | 1 | External power supply.|
| SINK | 2 | Internal power supply.|
......@@ -862,6 +873,6 @@ Enumerates data role types.
| Name | Value | Description |
| ------ | ---- | ------------ |
| NONE | 0 | None |
| NONE | 0 | None. |
| HOST | 1 | USB host.|
| DEVICE | 2 | USB device.|
......@@ -177,3 +177,21 @@ System resources are not loaded to the sandbox path of the application process.
**Solution**
Check whether the application process contains the sandbox path of system resources.
## 9001010 Invalid Overlay Path
**Error Message**
Overlay resource path is invalid.
**Description**
This error code is reported if the specified overlay path is invalid.
**Possible Causes**
The path does not exist or is not in the installation path of the application.
**Solution**
Check the location of the specified overlay path.
......@@ -157,8 +157,9 @@ You must install **Node.js** and HPM on your local PC. The installation procedur
2. Learn more about the distribution.
1. Read carefully the information about the distribution to learn its application scenarios, features, components, usage, and customization methods.
2. Click **Download** if you want to download the distribution to your local PC.
3. Click **Device component tailoring** if you want to add or delete components of the distribution.
2. Use either of the following modes to obtain the source code:
- Click **Download** if you want to download the distribution to your local PC.
- Click **Device component tailoring** if you want to add or delete components of the distribution.
**Figure 2** Example distribution
......
# AI Framework Development
# AI Framework Development Guide
## **Overview**
### Introduction
The AI subsystem is the part of OpenHarmony that provides native distributed AI capabilities. At the heart of the subsystem is a unified AI engine framework, which implements quick integration of AI algorithm plug-ins.
The framework consists of the plug-in management, module management, and communication management modules, fulfilling lifecycle management and on-demand deployment of AI algorithms. Specifically, plug-in management implements lifecycle management, on-demand deployment, and quick integration of AI algorithm plug-ins; module management implements task scheduling and client instance management; communication management manages inter-process communication (IPC) between the client and server and data transmission between the AI engine and plug-ins.
Under this framework, AI algorithm APIs will be standardized to facilitate distributed calling of AI capabilities. In addition, unified inference APIs will be provided to adapt to different inference framework hierarchies.
The AI subsystem is the part of OpenHarmony that provides native distributed AI capabilities. At the heart of the subsystem is a unified AI engine framework, which implements quick integration of AI algorithm plug-ins.
The framework consists of the plug-in management, module management, and communication management modules, fulfilling lifecycle management and on-demand deployment of AI algorithms. Specifically, plug-in management implements lifecycle management, on-demand deployment, and quick integration of AI algorithm plug-ins; module management implements task scheduling and client instance management; communication management manages inter-process communication (IPC) between the client and server and data transmission between the AI engine and plug-ins. Under this framework, AI algorithm APIs will be standardized to facilitate distributed calling of AI capabilities. In addition, unified inference APIs will be provided to adapt to different inference framework hierarchies.
The following figure shows the AI engine framework.
**Figure 1** AI engine framework
![en-us_image_0000001200128073](figures/en-us_image_0000001200128073.png)
![en-us_image_0000001200128073](figure/en-us_image_0000001200128073.png)
### Setting Up the Environment
......@@ -22,11 +19,11 @@ The following figure shows the AI engine framework.
2. [Download the source code.](../get-code/sourcecode-acquire.md)
## Technical specifications
## Technical Specifications
### Code Management
The AI engine framework consists of three modules: **client**, **server**, and **common**. The client module provides the server connection management function. The SDK needs to encapsulate and call the public APIs provided by the client in the algorithm's external APIs. The server module provides functions such as plug-in loading and task management. Plug-ins are integrated using the plug-in APIs provided by the server. The common module provides platform-related operation methods, engine protocols, and tool classes for other modules.
The AI engine framework consists of three modules: **client**, **server**, and **common**. The client module provides the server connection management function. An OpenHarmony SDK needs to encapsulate and call the public APIs provided by the client in the algorithm's external APIs. The server module provides functions such as plug-in loading and task management. Plug-ins are integrated using the plug-in APIs provided by the server. The common module provides platform-related operation methods, engine protocols, and tool classes for other modules.
The following figure shows the code dependency between modules of the AI engine framework.
......@@ -34,12 +31,12 @@ The following figure shows the code dependency between modules of the AI engine
**Figure 2** Code dependency
![en-us_image_0000001151931738](figures/en-us_image_0000001151931738.jpg)
![en-us_image_0000001151931738](figure/en-us_image_0000001151931738.jpg)
#### Recommendation: Develop plug-ins and SDKs in the directories specified by the AI engine.
#### Recommendation: Develop plug-ins and OpenHarmony SDKs in the directories specified by the AI engine.
In the overall planning of the AI engine framework, SDKs are a part of the client, and plug-ins are called by the server and are considered a part of the server. Therefore, the following directories have been planned for plug-in and SDK development in the AI engine framework:
In the overall planning of the AI engine framework, OpenHarmony SDKs are a part of the client, and plug-ins are called by the server and are considered a part of the server. Therefore, the following directories have been planned for plug-in and OpenHarmony SDK development in the AI engine framework:
- SDK code directory: //foundation/ai/engine/services/client/algorithm_sdk
......@@ -56,7 +53,7 @@ In the overall planning of the AI engine framework, SDKs are a part of the clien
#### Rule: Store all external APIs provided by plug-ins in the **interfaces/kits** directory of the AI subsystem.
The AI subsystem exposes its capabilities through external APIs of SDKs. According to API management requirements of OpenHarmony, store all external APIs of SDKs in the **interfaces/kits** directory of the subsystem. Currently, the external APIs of plug-ins of the AI subsystem are stored in the **//foundation/ai/engine/interfaces/kits** directory. You can add a sub-directory for each newly added plug-in in this directory. For example, if you add a CV plug-in, then store its external APIs in the **//foundation/ai/engine/interfaces/kits/cv** directory.
The AI subsystem exposes its capabilities through external APIs of OpenHarmony SDKs. According to API management requirements of OpenHarmony, store all external APIs of the SDK in the **interfaces/kits** directory of the subsystem. Currently, the external APIs of plug-ins of the AI subsystem are stored in the **//foundation/ai/engine/interfaces/kits** directory. You can add a sub-directory for each newly added plug-in in this directory. For example, if you add a CV plug-in, then store its external APIs in the **//foundation/ai/engine/interfaces/kits/cv** directory.
#### Rule: Make sure that plug-in build results are stored in the **/usr/lib** directory.
......@@ -65,14 +62,14 @@ Plug-in loading on the server uses the dlopen mode and can only be performed in
### Naming rule
#### Rule: Name an SDK in the format of **domain\_keyword&lt;*other information 1*\_*other information 2*\_…&gt;\_sdk.so**.
#### Rule: Name an SDK in the format of **domain_keyword<_other information 1_other information 2_...>_sdk.so**.
You are advised to use the commonly known abbreviations for domains. For example, use **cv** for image and video, **asr** for voice recognition, and **translation** for text translation. Add one if there is no available abbreviation for a domain. Use keywords that accurately describe the algorithm capability of the plug-in. For example, use **keyword\_spotting** for wakeup keyword spotting (KWS). Add other information, such as the supported chip type and applicable region, between **keyword** and **sdk**, with each of them separated by an underscore (\_). Note that the name of a SDK must end with **\_sdk**.
You are advised to use the commonly known abbreviations for domains. For example, use **cv** for image and video, **asr** for voice recognition, and **translation** for text translation. Add one if there is no available abbreviation for a domain. Use keywords that accurately describe the algorithm capability of the plug-in. For example, use **keyword\_spotting** for wakeup keyword spotting (KWS). Add other information, such as the supported chip type and applicable region, between **keyword** and **sdk**, with each of them separated by an underscore (\_). Note that the name of an SDK must end with **\_sdk**.
For example, if the SDK for the KWS plug-in supports only the Kirin 9000 chipset and is applicable only in China, then name the SDK as follows: **asr\_keyword\_spotting\_kirin9000\_china\_sdk.so**.
#### Rule: Name a plug-in in the format of **domain\_keyword&lt;*other information 1*\_*other information 2*\_…&gt;.so**.
#### Rule: Name a plug-in in the format of **domain_keyword<_other information 1_other information 2_...>.so**.
There is a one-to-one mapping between plug-ins and SDKs. Therefore, the definitions and requirements of terms such as the domain, keyword, and other information in plug-in names are the same as those in SDK names. The only difference is that the name of the SDK ends with **\_sdk** additionally. For example, if the plug-in is named **asr\_keyword\_spotting.so**, the corresponding SDK is named **asr\_keyword\_spotting\_sdk.so**.
......@@ -151,14 +148,19 @@ retCode = ProcessEncode(dataInfo, arg1, arg2, arg3) // The number of parameters
retCode = ProcessDecode(dataInfo, arg1, arg2, arg3) // The number of parameters can be flexible.
```
> **NOTE**
>
> - The sequence of parameters must be the same during encoding and decoding.
> - After encoding, the memory used by **dataInfo** needs to be manually released by the caller.
> - The memory is managed and released separately on the server and the client.
> - If a pointer contains the shared memory, no extra processing is required.
> - If other types of pointers are used, you need to dereference them before using **ProcessEncode** or **ProcessDecode**.
> - The codec module has not been adapted to the **class** data type and therefore it is not recommended.
Note:
- The sequence of parameters must be the same during encoding and decoding.
- After encoding, the memory used by **dataInfo** needs to be manually released by the caller.
- The memory is managed and released separately on the server and the client.
- If a pointer contains the shared memory, no extra processing is required.
- If other types of pointers are used, you need to dereference them before using **ProcessEncode** or **ProcessDecode**.
- The codec module has not been adapted to the **class** data type and therefore it is not recommended.
#### Rule: Release the memory used by the encoded or decoded parameters in the SDK. Otherwise, a memory leakage occurs.
......@@ -249,7 +251,7 @@ The following table describes the data structure of **ConfigInfo**, **ClientInfo
| ConfigInfo | Algorithm configuration item information| **const&nbsp;char&nbsp;\*description**: body of configuration item information. |
| ClientInfo | Client information.| **long&nbsp;long&nbsp;clientVersion**: client version number. This parameter is not used currently.<br>**int&nbsp;clientId**: client ID.<br>**int&nbsp;sessionId**: session ID.<br>**uid\_t&nbsp;serverUid**: server UID.<br>**uid\_t&nbsp;clientUid**: client UID.<br>**int&nbsp;extendLen**: length of the extended information (**extendMsg**).<br>**unsigned&nbsp;char&nbsp;\*extendMsg**: body of the extended information. |
| AlgorithmInfo | Algorithm information| **long&nbsp;long&nbsp;clientVersion**: client version number. This parameter is not used currently.<br>**bool&nbsp;isAsync**: whether asynchronous execution is used.<br>**int&nbsp;algorithmType**: algorithm type ID allocated by the AI engine framework based on the plug-in loading sequence.<br>**long&nbsp;long&nbsp;algorithmVersion**: algorithm version number.<br>**bool&nbsp;isCloud**: whether to migrate data to the cloud. This parameter is not used currently.<br>**int&nbsp;operateId**: execution ID. This parameter is not used currently.<br>**int&nbsp;requestId**: request ID, which identifies each request and corresponds to the execution result.<br>**int&nbsp;extendLen**: length of the extended information (**extendMsg**).<br>**unsigned&nbsp;char&nbsp;\*extendMsg**: body of the extended information. |
| DataInfo | Algorithm input parameter configuration information (**inputInfo**) and output parameter configuration information (**outputInfo**)| **unsigned&nbsp;char&nbsp;\*data**: data subject.<br>**int&nbsp;length**: data length. |
| DataInfo | Algorithm input parameter configuration information (**inputInfo**)<br>and output parameter configuration information (**outputInfo**)| **unsigned&nbsp;char&nbsp;\*data**: data subject.<br>**int&nbsp;length**: data length. |
For details about the development process, see the development example of the [KWS SDK](#kws-sdk).
......@@ -313,7 +315,7 @@ The following table describes the attributes of the **Response** class.
| Attribute| Description| Default Value|
| -------- | -------- | -------- |
| innerSequenceId_ | Type: long&nbsp;long<br>**Function**: reserved| 0 |
| innerSequenceId_ | **Type**: long&nbsp;long<br>**Function**: reserved| 0 |
| requestId_ | **Type**: int<br>**Function**: Indicates the request sequence, which is used to bind the return result.| 0 |
| retCode__ | **Type**: int<br>**Function**: Indicates the inference result code of the asynchronous algorithm.| 0 |
| retDesc_ | **Type**: string<br>**Function**: reserved| - |
......@@ -454,10 +456,11 @@ The preceding code implements the **IPlugin** APIs provided by the server. The f
| AieClientGetOption | GetOption | Obtains algorithm-related configuration items. For KWS, this API can obtain the input and output scale of the KWS model. The input scale is the MFCC feature (fixed value: **4000**) required by the KWS model, and the output scale is the confidence (fixed value: **2**) of the result.|
| AieClientRelease | Release | Releases the algorithm model. For KWS, this API releases the specified algorithm model and clears the dynamic memory in the feature processor.|
> **NOTE**
>
> - The **AieClientInit** and **AieClientDestroy** APIs are used to connect to and disconnect from the server, respectively. They are not called in the plug-in algorithm and therefore do not need to be defined in the plug-in.
> - The KWS plug-in needs to use the **PLUGIN\_INTERFACE\_IMPL** statement to expose the function pointer. Otherwise, the plug-in cannot be properly loaded.
Note:
1. The **AieClientInit** and **AieClientDestroy** APIs are used to connect to and disconnect from the server, respectively. They are not called in the plug-in algorithm and therefore do not need to be defined in the plug-in.
2. The KWS plug-in needs to use the **PLUGIN\_INTERFACE\_IMPL** statement to expose the function pointer. Otherwise, the plug-in cannot be properly loaded.
```
......
......@@ -223,7 +223,7 @@ The following is a demo debugging process, where the **StartTrace** and **Finish
external_deps = [ "hitrace:hitrace_meter" ]
subsystem_name = "hiviewdfx"
part_name = "hitrace"
part_name = "hitrace_native"
}
group("hitrace_target") {
......
......@@ -88,7 +88,7 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma
"subsystem": "product_hihope"
}
```
In the preceding code, `//vendor/hihope/rk3568/thermal/` is the folder path, `profile` is the folder name, and `thermal_hdf_config` is the build target.
In the preceding code, `//vendor/hihope/rk3568/thermal/` is the folder path, `profile` is the folder name, and `thermal_service_config` is the build target.
6. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md).
......
......@@ -106,7 +106,7 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma
"subsystem": "product_hihope"
}
```
In the preceding code, `//vendor/hihope/rk3568/thermal/` is the folder path, `profile` is the folder name, and `thermal_hdf_config` is the build target.
In the preceding code, `//vendor/hihope/rk3568/thermal/` is the folder path, `profile` is the folder name, and `thermal_service_config` is the build target.
6. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md).
......@@ -150,7 +150,6 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma
```
## Reference
During development, you can refer to the [default thermal control configuration](https://gitee.com/openharmony/powermgr_thermal_manager/blob/master/services/native/profile/thermal_service_config.xml).
Packing path: `/vendor/etc/thermal_config/hdf`
......@@ -144,6 +144,6 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma
```
## Reference
During development, you can refer to the [default thermal detection configuration](https://gitee.com/openharmony/drivers_peripheral/blob/master/thermal/interfaces/hdi_service/profile/thermal_hdi_config.xml).
During development, you can refer to the [default thermal detection configuration](https://gitee.com/openharmony/drivers_peripheral/tree/master/thermal/interfaces/hdi_service/profile/thermal_hdf_config.xml).
Packing path: `/vendor/etc/thermal_config/hdf`
......@@ -111,7 +111,7 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma
"subsystem": "product_hihope"
}
```
In the preceding code, `//vendor/hihope/rk3568/thermal/` is the folder path, `profile` is the folder name, and `thermal_hdf_config` is the build target.
In the preceding code, `//vendor/hihope/rk3568/thermal/` is the folder path, `profile` is the folder name, and `thermal_service_config` is the build target.
6. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md).
......
......@@ -26,7 +26,7 @@ For details about the requirements on the Linux environment, see [Quick Start](.
The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568) as an example to illustrate thermal log customization.
1. Create the thermal folder in the product directory [/vendor/hihope/rk3568](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568).
1. Create the `thermal` folder in the product directory [/vendor/hihope/rk3568](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568).
2. Create a target folder by referring to the [default thermal log configuration folder](https://gitee.com/openharmony/drivers_peripheral/tree/master/thermal/interfaces/hdi_service/profile), and install it in `//vendor/hihope/rk3568/thermal`. The content is as follows:
......@@ -50,6 +50,8 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma
| Configuration Item| Description| Data Type| Value Range|
| -------- | -------- | -------- | -------- |
| interval | Interval for recording temperature tracing logs, in ms.| int | >0 |
| width | Width of the temperature tracing log, in characters.| int | >0 |
| outpath | Path for storing temperature tracing logs.| string | N/A|
**Table 2** Description of the node configuration
......@@ -61,7 +63,7 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma
| value | path | Path for obtaining the thermal zone temperature.|
```shell
<tracing outpath="/data/log/thermal-log">
<tracing interval="5000" width="20" outpath="/data/log/thermal-log">
<node>
<title path="sys/class/thermal/thermal_zone0/type"/>
<value path="sys/class/thermal/thermal_zone0/temp"/>
......@@ -84,10 +86,10 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma
thermal.para.dac:
```text
persist.thermal.log.="power_host:power_host:500" # Configure access permissions.
persist.thermal.log.="power_host:power_host:600" # Configure access permissions.
```
6. Write the `BUILD.gn` file by referring to the [BUILD.gn](https://gitee.com/openharmony/drivers_peripheral/blob/master/thermal/interfaces/hdi_service/profile/BUILD.gn) file in the default thermal log configuration folder to pack the thermal_hdi_config.xml file to the `//vendor/etc/thermal_config/hdf` directory. The configuration is as follows:
6. Write the `BUILD.gn` file by referring to the [BUILD.gn](https://gitee.com/openharmony/drivers_peripheral/blob/master/thermal/interfaces/hdi_service/profile/BUILD.gn) file in the default thermal log configuration folder to pack the `thermal_hdi_config.xml` file to the `//vendor/etc/thermal_config/hdf` directory. The configuration is as follows:
```shell
import("//build/ohos.gni")
......@@ -95,7 +97,7 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma
ohos_prebuilt_etc("thermal_hdf_config") {
source = "thermal_hdi_config.xml"
relative_install_dir = "thermal_config/hdf"
install_images = [ chipset_base_dir ] # Required configuration for installing the thermal_service_config.xml file in the vendor directory.
install_images = [ chipset_base_dir ] # Required configuration for installing the thermal_hdi_config.xml file in the vendor directory.
part_name = "product_rk3568" # Set part_name to product_rk3568 for subsequent build. You can change it as required.
}
```
......@@ -149,7 +151,7 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma
"subsystem": "product_hihope"
}
```
In the preceding code, //vendor/hihope/rk3568/thermal/ is the folder path, profile and etc are folder names, and thermal_hdf_config and param_files are the build targets.
In the preceding code, `//vendor/hihope/rk3568/thermal/` is the folder path, `profile` and `etc` are folder names, and `thermal_hdf_config` and `param_files` are the build targets.
9. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md).
......
......@@ -150,7 +150,7 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma
"subsystem": "product_hihope"
}
```
In the preceding code, `//vendor/hihope/rk3568/thermal/` is the folder path, `profile` is the folder name, and `thermal_hdf_config` is the build target.
In the preceding code, `//vendor/hihope/rk3568/thermal/` is the folder path, `profile` is the folder name, and `thermal_service_config` is the build target.
6. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md).
......
......@@ -86,7 +86,7 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma
"subsystem": "product_hihope"
}
```
In the preceding code, `//vendor/hihope/rk3568/thermal/` is the folder path, `profile` is the folder name, and `thermal_hdf_config` is the build target.
In the preceding code, `//vendor/hihope/rk3568/thermal/` is the folder path, `profile` is the folder name, and `thermal_service_config` is the build target.
6. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md).
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册