Skip to content

Instantly share code, notes, and snippets.

@defunctzombie
Created July 18, 2021 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save defunctzombie/02ef57b02342d5461fbc122ce397db6c to your computer and use it in GitHub Desktop.
Save defunctzombie/02ef57b02342d5461fbc122ce397db6c to your computer and use it in GitHub Desktop.
const HID = require("node-hid");
const vendorId = 4617;
const productId = 17185;
async function main() {
const device = new HID.HID(vendorId, productId);
device.on("error", (err) => {
console.error(err);
});
device.setNonBlocking(0);
// flush read buffer
device.readTimeout(500);
// send flip bit reset
{
const buff = new Uint8Array([0x00, 0xff, 0xff]);
console.log(device.write(buff));
/*
const data = await deviceRead(device);
console.log(data);
*/
}
// get platform info
{
const buff = new Uint8Array([0x00, 0x44, 0x00, 0x00, 0x03, 0x00, 0x00]);
console.log(device.write(buff));
const data = await deviceRead(device);
console.log(data);
}
}
async function deviceRead(device) {
return await new Promise((resolve, reject) => {
device.read((err, data) => {
if (err) {
reject(err);
return;
}
resolve(data);
});
});
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment