未验证 提交 c78cb700 编写于 作者: A Austin 提交者: Gitee

update zh-cn/device-dev/subsystems/subsys-usbservice-guide.md.

Signed-off-by: NAustin23 <liaozhiqi7@huawei.com>
上级 d37f3a95
......@@ -13,40 +13,40 @@
2. 获取usb设备列表
```cpp
std::vector<OHOS::USB::UsbDevice> deviceList;
int32_t ret = g_usbClient.GetDevices(deviceList);
```
```cpp
std::vector<OHOS::USB::UsbDevice> deviceList;
int32_t ret = g_usbClient.GetDevices(deviceList);
```
3. 申请设备权限
```cpp
int32_t ret = g_usbClient.RequestRight(device.GetName());
```
```cpp
int32_t ret = g_usbClient.RequestRight(device.GetName());
```
4. 打开设备
```cpp
USBDevicePipe pip;
int32_t et = g_usbClient.OpenDevice(device, pip);
```
```cpp
USBDevicePipe pip;
int32_t et = g_usbClient.OpenDevice(device, pip);
```
5. 配置设备接口
```cpp
ret = g_usbClient.ClaimInterface(pip, interface, true);
interfacedeviceListdeviceinterface
```
```cpp
ret = g_usbClient.ClaimInterface(pip, interface, true);
interfacedeviceListdeviceinterface
```
6. 数据传输
```cpp
srvClient.BulkTransfer(pipe, endpoint, vdata, timeout);
```
pipe为打开设备后的数据传输通道,endpoint为device中数据传输的端点,vdata是需要传输或读取的二进制数据块,timeout为传输超时时长。
```cpp
srvClient.BulkTransfer(pipe, endpoint, vdata, timeout);
```
pipe为打开设备后的数据传输通道,endpoint为device中数据传输的端点,vdata是需要传输或读取的二进制数据块,timeout为传输超时时长。
7. 关闭设备
```cpp
ret = g_usbClient.Close(pip);
```
```cpp
ret = g_usbClient.Close(pip);
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册