Tag: CDC

Android USB主机从设备读取

我试图从连接到主机模式的Android手机的USB设备中获取一些数据。 我能够发送数据,但读取失败。 我已经看过几个 例子 ,尽我所能,但我没有任何的USB通信经验,虽然现在我知道了一些,我一直坚持这一点,我不愿意承认。 我对端点configuration不是很熟悉,但是我知道我的设备使用CDCtypes的通信方法,并且输出(从电话到设备)和input都被注册。 这是全class人员用连接到手机上的唯一设备来pipe理USB连接,但没有任何手段完成,但是我希望在进一步学习之前让阅读部分工作。 public class UsbCommunicationManager { static final String ACTION_USB_PERMISSION = "com.android.example.USB_PERMISSION"; UsbManager usbManager; UsbDevice usbDevice; UsbInterface intf = null; UsbEndpoint input, output; UsbDeviceConnection connection; PendingIntent permissionIntent; Context context; byte[] readBytes = new byte[64]; public UsbCommunicationManager(Context context) { this.context = context; usbManager = (UsbManager) context.getSystemService(Context.USB_SERVICE); // ask permission from user […]