|
|
@ -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) => { |
|
|
|