update serialPortService.js

main
kavehjamshidi 1 month ago
parent 97c6de259c
commit 6be34a9124
  1. 12
      services/serialPortService.js

@ -21,7 +21,19 @@ async function serialPortList(req, res) {
const buff = Buffer.allocUnsafe(4); const buff = Buffer.allocUnsafe(4);
buff.write(`#0${req.params.id}$`); buff.write(`#0${req.params.id}$`);
serialPort.on('open', () => {
console.log('Serial port opened');
serialPort.write(buff) serialPort.write(buff)
});
serialPort.on('data', (data) => {
console.log('Received data:', data);
// Process the response to check if the box was opened successfully
});
serialPort.on('error', (error) => {
console.error('Error:', error);
});
} }
}) })
.catch((error) => { .catch((error) => {

Loading…
Cancel
Save