Skip to content

Commit 3ce4bd0

Browse files
committed
Update serialport dependancy to use version 12.0.0
The previous dependancy failed to compile with node v24
1 parent 75aa7f1 commit 3ce4bd0

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"node-hid": "2.1.1",
2020
"node-static": "*",
2121
"request": "*",
22-
"serialport": "9.x",
22+
"serialport": "^12.0.0",
2323
"socket.io": "4.x",
2424
"ws": "8.x"
2525
},

server.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@
2626
*/
2727

2828
const config = require('./config');
29-
const serialport = require('serialport');
30-
var SerialPort = serialport;
31-
const Readline = SerialPort.parsers.Readline;
29+
const { SerialPort } = require('serialport');
30+
const { ReadlineParser } = require('@serialport/parser-readline');
3231
const websockets = require('socket.io');
3332
const http = require('http');
3433
const WebSocket = require('ws');
@@ -224,7 +223,7 @@ io.sockets.on('connection', function (appSocket) {
224223
appSocket.emit('interfaces', supportedInterfaces);
225224

226225
// check available ports
227-
serialport.list().then(ports => {
226+
SerialPort.list().then(ports => {
228227
portsList = ports;
229228
let portPaths= new Array();
230229
for (var i = 0; i < ports.length; i++) {
@@ -236,7 +235,7 @@ io.sockets.on('connection', function (appSocket) {
236235
// reckeck ports every 2s
237236
if (!listPortsLoop) {
238237
listPortsLoop = setInterval(function () {
239-
serialport.list().then(ports => {
238+
SerialPort.list().then(ports => {
240239
if (JSON.stringify(ports) != JSON.stringify(portsList)) {
241240
portsList = ports;
242241
io.sockets.emit('ports', portsList);
@@ -278,7 +277,7 @@ io.sockets.on('connection', function (appSocket) {
278277
writeLog(chalk.yellow('INFO: ') + chalk.blue('FirstLoad called'), 1);
279278
appSocket.emit('serverConfig', config);
280279
appSocket.emit('interfaces', supportedInterfaces);
281-
serialport.list().then(ports => {
280+
SerialPort.list().then(ports => {
282281
appSocket.emit('ports', ports);
283282
});
284283
if (isConnected) {
@@ -318,7 +317,7 @@ io.sockets.on('connection', function (appSocket) {
318317

319318
appSocket.on('getPorts', function () { // Refresh serial port list
320319
writeLog(chalk.yellow('INFO: ') + chalk.blue('Requesting Ports list '), 1);
321-
serialport.list().then(ports => {
320+
SerialPort.list().then(ports => {
322321
appSocket.emit('ports', ports);
323322
});
324323
});
@@ -382,10 +381,11 @@ io.sockets.on('connection', function (appSocket) {
382381
firmware = false;
383382
switch (connectionType) {
384383
case 'usb':
385-
port = new SerialPort(data[1], {
384+
port = new SerialPort({
385+
path: data[1],
386386
baudRate: parseInt(data[2].replace('baud',''))
387387
});
388-
const parser = port.pipe(new Readline({ delimiter: '\n' }))
388+
const parser = port.pipe(new ReadlineParser({ delimiter: '\n' }))
389389
// parser.on('data', console.log) // uncomment to dump raw data from the connected port
390390
io.sockets.emit('connectStatus', 'opening:' + port.path);
391391

0 commit comments

Comments
 (0)