Add the async uhk.writeDevice() and use it in get-i2c-baud-rate.js
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
const util = require('util');
|
||||
const HID = require('node-hid');
|
||||
// const debug = process.env.DEBUG;
|
||||
const debug = true;
|
||||
@@ -26,6 +27,11 @@ function uint32ToArray(value) {
|
||||
return [(value >> 0) & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, (value >> 24) & 0xff];
|
||||
}
|
||||
|
||||
function writeDevice(device, data, options={}) {
|
||||
device.write(getTransferData(new Buffer(data)));
|
||||
return util.promisify(device.read.bind(device))();
|
||||
}
|
||||
|
||||
function getUhkDevice() {
|
||||
const foundDevice = HID.devices().find(device =>
|
||||
device.vendorId === 0x1d50 && device.productId === 0x6122 &&
|
||||
@@ -72,6 +78,7 @@ exports = module.exports = moduleExports = {
|
||||
getUint16,
|
||||
getUint32,
|
||||
uint32ToArray,
|
||||
writeDevice,
|
||||
getUhkDevice,
|
||||
getBootloaderDevice,
|
||||
getTransferData,
|
||||
|
||||
Reference in New Issue
Block a user