Expose uhk.sendUsbPacket() and vastly simplify {write,read}-eeprom.js by using it. Make led_pwm.js use uhk.js instead of the obsoleted util.js file.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env node
|
||||
let uhk = require('./uhk');
|
||||
let [endpointIn, endpointOut] = uhk.getUsbEndpoints();
|
||||
var arg = process.argv[2] || '';
|
||||
|
||||
if (arg.length === 0) {
|
||||
@@ -8,18 +7,4 @@ if (arg.length === 0) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
var payload = Buffer.concat([new Buffer([uhk.usbCommands.writeEeprom, arg.length+2, 0x00, 0x00]), new Buffer(arg, 'utf8')]);
|
||||
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));
|
||||
})
|
||||
});
|
||||
uhk.sendUsbPacket(Buffer.concat([new Buffer([uhk.usbCommands.writeEeprom, arg.length+2, 0x00, 0x00]), new Buffer(arg, 'utf8')]))
|
||||
|
||||
Reference in New Issue
Block a user