Created
July 18, 2021 19:56
-
-
Save defunctzombie/02ef57b02342d5461fbc122ce397db6c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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