google chrome extension - Convert Byte array to Binary in JavaScript -


i have typedarray of bytes in javascript, , need convert binary, in order send usb device in chrome extension using chrome.usb.controltransfer.

simplified example:

var message = new uint8array(3); message[0] = 1; message[1] = 2; message[3] = 3;  var transferinfo = {     direction: 'out',     recipient: 'device',     requesttype: 'standard',     request: 0,     value: 0,     index: 0,     data: message };  // 'device' valid handle device found chrome.usb.finddevices chrome.usb.controltransfer(device, transferinfo, function(r) { console.log(r); }); 

this gives me error:

uncaught error: invalid value argument 2. property 'data': expected 'binary' got 'object'.

i'm not sure how uint8array whatever considered 'binary' in javascript. it's possible chrome-specific, can't find examples of calling function in way either.

i've seen mozilla documentation, appears specific sending data via xmlhttprequest.

it seems missed example within chrome documentation.

var message = new uint8array(3); message[0] = 1; message[1] = 2; message[3] = 3;  var binarymessage = message.buffer; 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -