From 0259ff53fced3b1b760f3e213ec9c320dc4eff7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Mon, 7 Aug 2017 03:03:07 +0200 Subject: [PATCH] Add read-debug-info.js --- usb/read-debug-info.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 usb/read-debug-info.js diff --git a/usb/read-debug-info.js b/usb/read-debug-info.js new file mode 100755 index 00000000..0eeaa60b --- /dev/null +++ b/usb/read-debug-info.js @@ -0,0 +1,25 @@ +#!/usr/bin/env node +let uhk = require('./uhk'); +let [endpointIn, endpointOut] = uhk.getUsbEndpoints(); +var arg = process.argv[2] || ''; + +function readDebugInfo() { + var payload = new Buffer([uhk.usbCommands.readDebugInfo]); + 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(readDebugInfo, 500) + }) + }); +} + +readDebugInfo();