Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid HID USB how to send hexadeсimal data with bulkTransfer or controlTransfer?
    primarykey
    data
    text
    <p>I'm trying to send hexadecimal data to connected USB HID device from my Nexus 7, but Android SDK method can work only with byte[] buffer.</p> <p>How can I send hexadeсimal data that originates as decimal String values with bulkTransfer or controlTransfer?</p> <pre><code>message[0]= 0; message[1]= 166; message[2]= 2; message[3]= 252; message[4]= 255; </code></pre> <p>SDK Methods:</p> <pre><code>bulkTransfer(UsbEndpoint endpoint, byte[] buffer, int length, int timeout) controlTransfer(int requestType, int request, int value, int index, byte[] buffer, int length, int timeout) </code></pre> <p>like this: <a href="http://pure-basic.narod.ru/article/pickit2.html" rel="nofollow">http://pure-basic.narod.ru/article/pickit2.html</a>, PC application with the device works good.</p> <pre><code>OutBuffer(0)=0 OutBuffer(1)=$A6 ; EXECUTE_SCRIPT OutBuffer(2)=2 OutBuffer(3)=$FC ; _VDD_GND_OFF OutBuffer(4)=$FF ; _VDD_ON </code></pre> <p><strong>UPDATE - ANSWER</strong></p> <pre><code>private void sendData() { //byte b = (byte) 129; // (byte) 0x81 Also work int status = connection.bulkTransfer(endPointWrite, toByte(129), 1, 250); } private static byte toByte(int c) { return (byte) (c &lt;= 0x7f ? c : ((c % 0x80) - 0x80)); } // for received data from USB HID device private static int toInt(byte b) { return (int) b &amp; 0xFF; } </code></pre> <p><strong><a href="http://play.google.com/store/apps/details?id=com.appspot.usbhidterminal" rel="nofollow">My application on Google play - USB HID TERMINAL</a></strong></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload