HarmonyOS 鸿蒙Next openharmony3.1 usb连接通信异常
HarmonyOS 鸿蒙Next openharmony3.1 usb连接通信异常 因为 @ohos.usb 的 claimInterface 接口一直返回-1,而且在虚拟机linux尝试与USB设备通信下usbmon抓取数据时发现使用的是中断传输模式,@ohos.usb文档没看到有中断传输的接口。
所以转为在 NativeC++模板下使用fcntl.h unistd.h的open()、write()、read()函数打开hidraw1进行数据通信的方式,拿到数据。该方法确实可以有概率成功运行,拿到数据,但目前更大的情况是如图所示,write()函数经常以控制传输模式进行数据传输,无法固定中断传输模式进行数据通信。
各位有什么解决思路吗?或者 @ohos.usb 有什么方法可以解决?
usb.getDevices 的返回数据:
[
{
"name": "2-7",
"serial": "0100510312",
"manufacturerName": " ",
"productName": "RFID READER",
"version": "0002",
"vendorId": 65534,
"productId": 145,
"clazz": 0,
"subclass": 0,
"protocol": 0,
"devAddress": 7,
"busNum": 2,
"configs": [
{
"id": 1,
"attributes": 128,
"isRemoteWakeup": false,
"isSelfPowered": true,
"maxPower": 200,
"name": " ",
"interfaces": [
{
"id": 0,
"protocol": 0,
"clazz": 3,
"subclass": 0,
"alternateSetting": 0,
"name": " ",
"endpoints": [
{
"address": 132,
"attributes": 3,
"interval": 1,
"maxPacketSize": 64,
"direction": 128,
"number": 4,
"type": 3,
"interfaceId": 0
},
{
"address": 5,
"attributes": 3,
"interval": 1,
"maxPacketSize": 64,
"direction": 0,
"number": 5,
"type": 3,
"interfaceId": 0
}
]
},
{
"id": 1,
"protocol": 1,
"clazz": 3,
"subclass": 1,
"alternateSetting": 0,
"name": " ",
"endpoints": [
{
"address": 134,
"attributes": 3,
"interval": 10,
"maxPacketSize": 64,
"direction": 128,
"number": 6,
"type": 3,
"interfaceId": 1
}
]
}
]
}
]
}
]
更多关于HarmonyOS 鸿蒙Next openharmony3.1 usb连接通信异常的实战教程也可以访问 https://www.itying.com/category-93-b0.html
更多关于HarmonyOS 鸿蒙Next openharmony3.1 usb连接通信异常的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
针对“HarmonyOS 鸿蒙Next openharmony3.1 usb连接通信异常”的问题,以下是一些可能的解决方案:
-
检查USB调试设置: 确保在鸿蒙系统的开发者选项中已启用USB调试。同时,检查是否选择了正确的USB连接模式,如“传输文件”或“仅充电”。
-
更新驱动程序: 计算机上的USB驱动程序可能过时或不兼容。尝试更新计算机的USB驱动程序到最新版本,以确保与鸿蒙系统的兼容性。
-
检查USB线和接口: 更换USB线或使用其他USB接口连接设备,以排除硬件故障的可能性。
-
检查系统日志: 查看鸿蒙系统的日志,特别是与USB通信相关的日志,以获取更多关于通信异常的信息。这有助于确定问题的具体原因。
-
重启设备: 有时简单的重启设备可以解决USB连接通信异常的问题。
-
检查openharmony版本兼容性: 确保你的鸿蒙设备与openharmony 3.1版本兼容。如果不兼容,可能需要降级或升级系统。
如果以上方法均未能解决问题,可能是系统或硬件层面的复杂问题。此时,建议联系官网客服以获取更专业的帮助。官网地址是:https://www.itying.com/category-93-b0.html,