Some fixes.
This commit is contained in:
parent
46751b5b7b
commit
57804f3ce8
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
node_modules
|
49
index.js
49
index.js
@ -3,34 +3,49 @@ const args = process.argv.slice(2).join(' ');
|
|||||||
|
|
||||||
const pongoOSDevice = usb.findByIds(0x05ac, 0x4141);
|
const pongoOSDevice = usb.findByIds(0x05ac, 0x4141);
|
||||||
|
|
||||||
|
function log(message, type) {
|
||||||
|
switch (type) {
|
||||||
|
case 'success':
|
||||||
|
console.log("[+] " + message)
|
||||||
|
break;
|
||||||
|
case 'error':
|
||||||
|
console.error("[-] " + message)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function checkRoot() {
|
function checkRoot() {
|
||||||
return process.getuid && process.getuid() === 0
|
return process.getuid && process.getuid() === 0
|
||||||
}
|
};
|
||||||
|
|
||||||
if (!checkRoot()) {
|
if (!checkRoot()) {
|
||||||
console.error("Please run as root!")
|
log("Please run ass root", "error");
|
||||||
process.exit()
|
process.exit(1);
|
||||||
}
|
};
|
||||||
|
|
||||||
if (!pongoOSDevice) {
|
if (!pongoOSDevice) {
|
||||||
console.error('pongoOS Device not found !');
|
log("No device with pongoOS Booted has been found.", "error");
|
||||||
process.exit();
|
process.exit(1);
|
||||||
}
|
};
|
||||||
if (!args) {
|
if (!args) {
|
||||||
console.error('No command provided.');
|
log("No argumment has been provided.", "error");
|
||||||
process.exit();
|
process.exit(1);
|
||||||
}
|
};
|
||||||
try {
|
try {
|
||||||
pongoOSDevice.open(true)
|
pongoOSDevice.open(true)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('An error as occured while i was opening the device.' + e)
|
log("An error as occured while i was opening the device.", "error");
|
||||||
process.exit()
|
process.exit(1)
|
||||||
}
|
};
|
||||||
|
if (args.length > 510) {
|
||||||
|
log("You reached the length of the argumment.", "error");
|
||||||
|
process.exit(1)
|
||||||
|
};
|
||||||
pongoOSDevice.controlTransfer(0x21, 3, 0, 0, new Buffer.from(`${args} \n`), (error) => {
|
pongoOSDevice.controlTransfer(0x21, 3, 0, 0, new Buffer.from(`${args} \n`), (error) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error("An error as occured while sending cmd error :" + error);
|
log(`An error as occured while sending cmd error: ${error}`, "error")
|
||||||
process.exit();
|
process.exit(1);
|
||||||
}
|
}
|
||||||
console.log('Command sent: ' + args);
|
log(`Success, command "${args}" has been sent.`, "success")
|
||||||
process.exit();
|
process.exit(0);
|
||||||
})
|
})
|
6
package-lock.json
generated
6
package-lock.json
generated
@ -1,9 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "cum",
|
"name": "pongoos-cmd-sender",
|
||||||
|
"version": "1.0.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
|
"name": "pongoos-cmd-sender",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"license": "unlicensed",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"usb": "^1.7.0"
|
"usb": "^1.7.0"
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "pongoos-cmd-sender",
|
"name": "pongoos-cmd-sender",
|
||||||
"version": "1.0.0",
|
"version": "1.1.0",
|
||||||
"description": "Send command to a device connected and running pongOS.",
|
"description": "Send command to a device connected and running pongOS.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
Loading…
Reference in New Issue
Block a user