android:与USB设备通信
2013-01-30 16:48
253 查看
Communicating with a USB device in Android
http://gssdaily.com/forum/viewtopic.php?f=17&t=96084by
jack » Sat Sep 29, 2012 10:18 pm
Communicating with a USB device in Android
Communication with a USB device can be either synchronous or asynchronous. In either case, you should create a new thread on which to carry out all data transmissions, so you don't block the UI thread. To properly set up communication with a device, you need
to obtain the appropriate UsbInterface and UsbEndpoint of the device that you want to communicate on and send requests on this endpoint with a UsbDeviceConnection.
Code:
Select all
rivate Byte[] bytes private static int TIMEOUT = 0; private boolean forceClaim = true; ... UsbInterface intf = device.getInterface(0); UsbEndpoint endpoint = intf.getEndpoint(0); UsbDeviceConnection connection = mUsbManager.openDevice(device); connection.claimInterface(intf, forceClaim); connection.bulkTransfer(endpoint, bytes, bytes.length, TIMEOUT); //do in another thread
jack Posts: 425Joined: Tue Nov 30, 2010 10:29 pm
相关文章推荐
- android usb Host模式下与usb Hid 设备的通信
- 两台android设备间通过OTG-USB连接,实现通信(android设备间的通信)
- 两台android设备间通过OTG-USB连接,实现通信(android设备间的通信)
- PC与Android设备通过USB建立通信连接
- 关于Android设备USBHID通信控制传输相关接口说明
- android 与usb 设备通信(二)
- Android USB HID设备通信controlTransfer 接口参数
- Android UsbManager 获取不到HID设备(实际上就是Input设备)怎样通信的问题(已解决)!
- android的usb作为从设备的程序流程
- Windows主机端与自定义USB HID设备通信详解
- Android设备间USB传输(OTG)
- Android USB Gadget复合设备驱动(打印机)测试方法
- android开发(20) 使用adb建立pc和android设备之间的连接。usb连接方式。
- 【Android开发经验】移动设备的“声波通信/验证”的实现——SinVoice开源项目介绍(一)
- Android 查看 无wifi/usb设备的logcat方法
- Android设备通过usb控制zedboard产生pwm波实验
- Android系统下如何允许奥比中光3D传感摄像头USB设备访问
- Windows主机端与自定义USB HID设备通信详解
- Linux 下串口USB等设备通信编程入门1
- Android USB 设备如何区分是打印机还是U盘