|
|
@ -11,7 +11,7 @@ const { ReadlineParser } = require('@serialport/parser-readline')
|
|
|
|
const sport = new SerialPort({ path: '/dev/ttyACM0', baudRate: 115200 })
|
|
|
|
const sport = new SerialPort({ path: '/dev/ttyACM0', baudRate: 115200 })
|
|
|
|
|
|
|
|
|
|
|
|
const parser = sport.pipe(new ReadlineParser({ delimiter: '\r\n' }))
|
|
|
|
const parser = sport.pipe(new ReadlineParser({ delimiter: '\r\n' }))
|
|
|
|
parser.on('data', console.log)
|
|
|
|
//parser.on('data', console.log)
|
|
|
|
|
|
|
|
|
|
|
|
server.listen(port, () => {
|
|
|
|
server.listen(port, () => {
|
|
|
|
console.log("Server is listening at port %d", port);
|
|
|
|
console.log("Server is listening at port %d", port);
|
|
|
@ -37,6 +37,7 @@ var io = require('socket.io')(server);
|
|
|
|
socket.on("message", (message) => {
|
|
|
|
socket.on("message", (message) => {
|
|
|
|
console.log("Received message:", message);
|
|
|
|
console.log("Received message:", message);
|
|
|
|
if (message === "blink") {
|
|
|
|
if (message === "blink") {
|
|
|
|
|
|
|
|
console.log("Blink event received!");
|
|
|
|
io.emit("blink"); // Trigger the blink event to all connected clients
|
|
|
|
io.emit("blink"); // Trigger the blink event to all connected clients
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|