add first version.
This commit is contained in:
commit
0cf16aebb2
36
index.js
Normal file
36
index.js
Normal file
@ -0,0 +1,36 @@
|
||||
const usb = require('usb')
|
||||
const args = process.argv.slice(2).join(' ');
|
||||
|
||||
const pongoOSDevice = usb.findByIds(0x05ac, 0x4141);
|
||||
|
||||
function checkRoot() {
|
||||
return process.getuid && process.getuid() === 0
|
||||
}
|
||||
|
||||
if (!checkRoot()) {
|
||||
console.error("Please run as root!")
|
||||
process.exit()
|
||||
}
|
||||
|
||||
if (!pongoOSDevice) {
|
||||
console.error('pongoOS Device not found !');
|
||||
process.exit();
|
||||
}
|
||||
if (!args) {
|
||||
console.error('No command provided.');
|
||||
process.exit();
|
||||
}
|
||||
try {
|
||||
pongoOSDevice.open(true)
|
||||
} catch(e) {
|
||||
console.error('An error as occured while i was opening the device.' + e)
|
||||
process.exit()
|
||||
}
|
||||
pongoOSDevice.controlTransfer(0x21, 3, 0, 0, new Buffer.from(`${args} \n`), (error) => {
|
||||
if (error) {
|
||||
console.error("An error as occured while sending cmd error :" + error);
|
||||
process.exit();
|
||||
}
|
||||
console.log('Command sent: ' + args);
|
||||
process.exit();
|
||||
})
|
1043
package-lock.json
generated
Normal file
1043
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
5
package.json
Normal file
5
package.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"usb": "^1.7.0"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user