Add language notifications; Add power door handel

This commit is contained in:
rasta5man 2025-05-31 22:03:23 +02:00
parent d97d90cf95
commit 0876e73c68
12 changed files with 445 additions and 581 deletions

View file

@ -1,6 +1,6 @@
const { exec } = require('child_process');
function openPort(port){
function openPort(port) {
return new Promise((resolve, reject) => {
var callbackError = function(err) {
@ -25,24 +25,24 @@ function openPort(port){
})
}
function runSyncExec(command){
function runSyncExec(command) {
return new Promise((resolve, reject) => {
exec(command, (error, stdout, stderr) => {
if(error == null) resolve(stdout);
if (error == null) resolve(stdout);
reject(error);
});
})
}
async function writeData(port, data, readbytes, timeout){
async function writeData(port, data, readbytes, timeout) {
return new Promise((resolve, reject) => {
// If first item in data array is 255, we just write broadcast command to rsPort
// We wait 3 seconds and resolve(["broadcast"])
// It is important to resolve with array
if(data[0] == 255) {
if (data[0] == 255) {
port.write(Buffer.from(data), function(err) {
if (err) {
@ -55,13 +55,12 @@ async function writeData(port, data, readbytes, timeout){
}
//cmd-manager mame http route POST / terminal a tomu sa tiez nastavuje timeout!!!
var callback = function(data) {
rsPortReceivedData.push(...data);
let l = rsPortReceivedData.length;
if(l >= readbytes)
{
if (l >= readbytes) {
port.removeListener('data', callback);
clearTimeout(t);