diff --git a/usb/read-adc.js b/usb/read-adc.js new file mode 100755 index 00000000..d7f69bef --- /dev/null +++ b/usb/read-adc.js @@ -0,0 +1,25 @@ +#!/usr/bin/env node +let uhk = require('./uhk'); +let [endpointIn, endpointOut] = uhk.getUsbEndpoints(); +var arg = process.argv[2] || ''; + +function readMergeSensor() { + var payload = new Buffer([uhk.usbCommands.readAdc]); + console.log('Sending ', uhk.bufferToString(payload)); + endpointOut.transfer(payload, function(err) { + if (err) { + console.error("USB error: %s", err); + process.exit(1); + } + endpointIn.transfer(64, function(err2, receivedBuffer) { + if (err2) { + console.error("USB error: %s", err2); + process.exit(2); + } + console.log('Received', uhk.bufferToString(receivedBuffer)); + setTimeout(readMergeSensor, 500) + }) + }); +} + +readMergeSensor(); diff --git a/usb/uhk.js b/usb/uhk.js index b4659565..110c9ef9 100755 --- a/usb/uhk.js +++ b/usb/uhk.js @@ -117,7 +117,7 @@ exports = module.exports = { uploadConfig: 8, applyConfig: 9, setLedPwm: 10, - getBridgeMessageCounter: 11 + readAdc: 11 }, leftLedDriverAddress: 0b1110100, rightLedDriverAddress: 0b1110111