add first version.

This commit is contained in:
Yaya4 2021-04-23 02:38:30 +02:00 committed by GitHub
commit 0cf16aebb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 1084 additions and 0 deletions

36
index.js Normal file
View 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

File diff suppressed because it is too large Load Diff

5
package.json Normal file
View File

@ -0,0 +1,5 @@
{
"dependencies": {
"usb": "^1.7.0"
}
}