From 626cb71cc1f708eae319303d75bfe93206ffdfd3 Mon Sep 17 00:00:00 2001 From: wu-chengwen Date: Mon, 25 Apr 2022 09:47:21 +0800 Subject: [PATCH] fixed 799b559 from https://gitee.com/wu-chengwen/docs/pulls/3467 fix(usb):add language type Signed-off-by: wu-chengwen --- en/application-dev/device/usb-guidelines.md | 10 +++++----- en/device-dev/subsystems/subsys-usbservice-demo.md | 2 +- .../subsystems/subsys-usbservice-guide.md | 14 +++++++------- zh-cn/application-dev/device/usb-guidelines.md | 10 +++++----- .../subsystems/subsys-usbservice-demo.md | 2 +- .../subsystems/subsys-usbservice-guide.md | 14 +++++++------- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/en/application-dev/device/usb-guidelines.md b/en/application-dev/device/usb-guidelines.md index 71c6d0b796..46304e882a 100644 --- a/en/application-dev/device/usb-guidelines.md +++ b/en/application-dev/device/usb-guidelines.md @@ -93,7 +93,7 @@ You can set a USB device as a host to connect to a device for data transfer. The 1. Obtain the USB device list. - ``` + ```js // Import the USB API package. import usb from '@ohos.usb'; // Obtain the USB device list. @@ -153,7 +153,7 @@ You can set a USB device as a host to connect to a device for data transfer. The 2. Obtain the device operation permissions. - ``` + ```js var deviceName = deviceList[0].name; // Request the permissions to operate a specified device. usb.requestRight(deviceName).then(hasRight => { @@ -165,7 +165,7 @@ You can set a USB device as a host to connect to a device for data transfer. The 3. Open the device. - ``` + ```js // Open the device, and obtain the USB device pipe for data transfer. var pipe = usb.connectDevice(deviceList[0]); /* @@ -177,7 +177,7 @@ You can set a USB device as a host to connect to a device for data transfer. The 4. Perform data transfer. - ``` + ```js /* Read data. Select the corresponding RX endpoint from deviceList for data transfer. (endpoint.direction == 0x80); dataUint8Array indicates the data to read. The data type is Uint8Array. @@ -208,7 +208,7 @@ You can set a USB device as a host to connect to a device for data transfer. The 5. Release the USB interface, and close the USB device. - ``` + ```js usb.releaseInterface(pipe, interface); usb.closePipe(pipe); ``` diff --git a/en/device-dev/subsystems/subsys-usbservice-demo.md b/en/device-dev/subsystems/subsys-usbservice-demo.md index 80506e955c..d39ca05444 100644 --- a/en/device-dev/subsystems/subsys-usbservice-demo.md +++ b/en/device-dev/subsystems/subsys-usbservice-demo.md @@ -1,7 +1,7 @@ # USB Usage Demo -``` +```cpp #include #include #include diff --git a/en/device-dev/subsystems/subsys-usbservice-guide.md b/en/device-dev/subsystems/subsys-usbservice-guide.md index 6ccfc2594d..090bb05fc9 100644 --- a/en/device-dev/subsystems/subsys-usbservice-guide.md +++ b/en/device-dev/subsystems/subsys-usbservice-guide.md @@ -7,40 +7,40 @@ The following procedure uses bulk transfer as an example. 1. Obtain a USB service instance. -``` +```cpp static OHOS::USB::UsbSrvClient &g_usbClient = OHOS::USB::UsbSrvClient::GetInstance(); ``` 2. Obtain the USB device list. -``` +```cpp std::vector deviceList; int32_t ret = g_usbClient.GetDevices(deviceList); ``` 3. Apply for device access permissions. -``` +```cpp int32_t ret = g_usbClient.RequestRight(device.GetName()); ``` 4. Open the USB device. -``` +```cpp USBDevicePipe pip; int32_t et = g_usbClient.OpenDevice(device, pip); ``` 5. Configure the USB interface. -``` +```cpp ret = g_usbClient.ClaimInterface(pip, interface, true); **interface** indicates an interface of the USB device in **deviceList**. ``` 6. Transfer data. -``` +```cpp srvClient.BulkTransfer(pipe, endpoint, vdata, timeout); ``` - **pipe** indicates the pipe for data transfer of the USB device opened. @@ -50,6 +50,6 @@ srvClient.BulkTransfer(pipe, endpoint, vdata, timeout); 7. Close the USB device. -``` +```cpp ret = g_usbClient.Close(pip); ``` diff --git a/zh-cn/application-dev/device/usb-guidelines.md b/zh-cn/application-dev/device/usb-guidelines.md index e652c76123..d3bf99be8b 100644 --- a/zh-cn/application-dev/device/usb-guidelines.md +++ b/zh-cn/application-dev/device/usb-guidelines.md @@ -38,7 +38,7 @@ USB设备可作为Host设备连接Device设备进行数据传输。开发示例 1. 获取设备列表。 - ``` + ```js // 导入usb接口api包。 import usb from '@ohos.usb'; // 获取设备列表。 @@ -97,7 +97,7 @@ USB设备可作为Host设备连接Device设备进行数据传输。开发示例 ``` 2. 获取设备操作权限。 - ``` + ```js var deviceName = deviceList[0].name; // 申请操作指定的device的操作权限。 usb.requestRight(deviceName).then(hasRight => { @@ -108,7 +108,7 @@ USB设备可作为Host设备连接Device设备进行数据传输。开发示例 ``` 3. 打开Device设备。 - ``` + ```js // 打开设备,获取数据传输通道。 var pipe = usb.connectDevice(deviceList[0]); /* @@ -119,7 +119,7 @@ USB设备可作为Host设备连接Device设备进行数据传输。开发示例 ``` 4. 数据传输。 - ``` + ```js /* 读取数据,在device信息中选取对应数据接收的endpoint来做数据传输 (endpoint.direction == 0x80);dataUint8Array是要读取的数据,类型为Uint8Array。 @@ -149,7 +149,7 @@ USB设备可作为Host设备连接Device设备进行数据传输。开发示例 ``` 5. 释放接口,关闭设备。 - ``` + ```js usb.releaseInterface(pipe, interface1); usb.closePipe(pipe); ``` diff --git a/zh-cn/device-dev/subsystems/subsys-usbservice-demo.md b/zh-cn/device-dev/subsystems/subsys-usbservice-demo.md index 6d41ebec6e..ddca6dd996 100644 --- a/zh-cn/device-dev/subsystems/subsys-usbservice-demo.md +++ b/zh-cn/device-dev/subsystems/subsys-usbservice-demo.md @@ -1,7 +1,7 @@ # USB服务子系使用实例 -``` +```cpp #include #include #include diff --git a/zh-cn/device-dev/subsystems/subsys-usbservice-guide.md b/zh-cn/device-dev/subsystems/subsys-usbservice-guide.md index c5cd817924..1692e51715 100644 --- a/zh-cn/device-dev/subsystems/subsys-usbservice-guide.md +++ b/zh-cn/device-dev/subsystems/subsys-usbservice-guide.md @@ -8,46 +8,46 @@ 1. 获取usb service实例 -``` +```cpp static OHOS::USB::UsbSrvClient &g_usbClient = OHOS::USB::UsbSrvClient::GetInstance(); ``` 2. 获取usb设备列表 -``` +```cpp std::vector deviceList; int32_t ret = g_usbClient.GetDevices(deviceList); ``` 3. 申请设备权限 -``` +```cpp int32_t ret = g_usbClient.RequestRight(device.GetName()); ``` 4. 打开设备 -``` +```cpp USBDevicePipe pip; int32_t et = g_usbClient.OpenDevice(device, pip); ``` 5. 配置设备接口 -``` +```cpp ret = g_usbClient.ClaimInterface(pip, interface, true); interface为deviceList中device的interface。 ``` 6. 数据传输 -``` +```cpp srvClient.BulkTransfer(pipe, endpoint, vdata, timeout); ``` pipe为打开设备后的数据传输通道,endpoint为device中数据传输的端点,vdata是需要传输或读取的二进制数据块,timeout为传输超时时长. 7. 关闭设备 -``` +```cpp ret = g_usbClient.Close(pip); ``` -- GitLab