update serialPortService.js

main
kavehjamshidi 4 weeks ago
parent 97c6de259c
commit 6be34a9124
  1. 14
      services/serialPortService.js

@ -21,7 +21,19 @@ async function serialPortList(req, res) {
const buff = Buffer.allocUnsafe(4);
buff.write(`#0${req.params.id}$`);
serialPort.write(buff)
serialPort.on('open', () => {
console.log('Serial port opened');
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) => {

Loading…
Cancel
Save