diff --git a/services/serialPortService.js b/services/serialPortService.js index c9eb386..e56683a 100644 --- a/services/serialPortService.js +++ b/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) => {