Android Studio通过USB与arduino进行串行通信

时间:2020-08-28 06:46:04

标签: java android android-studio arduino

我正在尝试通过USB在arduino nano和我的应用之间传递数据。 我正在使用https://github.com/felHR85/UsbSerial/库。

在使用示例代码尝试了几次之后,我尝试测试该问题 我的测试代码:

UsbManager usbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
HashMap<String, UsbDevice> usbDevices = usbManager.getDeviceList();
    if (usbDevices.isEmpty()) {
       Log.d(TAG, "findSerialPortDevice() usbManager returned empty device list." );
     }

在我的清单上

<uses-feature android:name="android.hardware.usb.host" android:required="true"/>

问题在于UsbManager始终为空,我认为电话没有检测到 USB设备。

我将arduino和计算机都用作USB设备 并尝试使用我的Pocophone,三星平板电脑和其他三星手机。 我用了两种不同的电缆。

我读到问题可能出在我的设备上(即使我使用了3台设备) 我使用了USB主机诊断应用程序,结果如下:

enter image description here

我第一次尝试使用Android中任何形式的通信。 谢谢。

0 个答案:

没有答案
相关问题