Skip to content

Commit

Permalink
chore: upgrade the serialport library to use version 11.0.0 (#1565)
Browse files Browse the repository at this point in the history
The serialport library being used was using 9.0.1, which is no longer maintained. Upgrading to version 11 allows users installing signalk-server on node-18 to use the prebuilt binaries.
  • Loading branch information
gkoreman committed Jun 18, 2023
1 parent 9201b6a commit 39e75a0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
"@signalk/vesselpositions": "^1.0.0",
"@signalk/zones": "^1.0.0",
"mdns": "^2.5.1",
"serialport": "^9.0.1"
"serialport": "^11.0.0"
},
"devDependencies": {
"@types/busboy": "^1.5.0",
Expand All @@ -157,7 +157,7 @@
"@types/node-fetch": "^2.5.3",
"@types/rmfr": "^2.0.1",
"@types/semver": "^7.1.0",
"@types/serialport": "^8.0.1",
"@types/serialport": "^8.0.2",
"@types/split": "^1.0.0",
"@types/swagger-ui-express": "^4.1.3",
"@types/unzipper": "^0.10.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/streams/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"stream-throttle": "^0.1.3"
},
"optionalDependencies": {
"serialport": "^9.0.1"
"serialport": "^11.0.0"
},
"devDependencies": {
"prettier": "2.5.1"
Expand Down
8 changes: 5 additions & 3 deletions packages/streams/serialport.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
const Transform = require('stream').Transform
const child_process = require('child_process')
const shellescape = require('any-shell-escape')
const SerialPort = require('serialport')
const { SerialPort } = require('serialport')
const { ReadlineParser } = require('@serialport/parser-readline')
const isArray = require('lodash').isArray
const isBuffer = require('lodash').isBuffer

Expand Down Expand Up @@ -104,7 +105,8 @@ SerialStream.prototype.start = function () {
)
}

this.serial = new SerialPort(this.options.device, {
this.serial = new SerialPort({
path: this.options.device,
baudRate: this.options.baudrate,
})

Expand All @@ -117,7 +119,7 @@ SerialStream.prototype.start = function () {
`Connected to ${this.options.device}`
)
this.isFirstError = true
const parser = new SerialPort.parsers.Readline()
const parser = new ReadlineParser()
this.serial.pipe(parser).pipe(this)
}.bind(this)
)
Expand Down
3 changes: 2 additions & 1 deletion src/serialports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import { Ports } from '@signalk/server-api'
import fs from 'fs'
import { SerialPort } from 'serialport'

export const listAllSerialPorts = (): Promise<Ports> => {
return new Promise((resolve, reject) => {
Expand All @@ -36,7 +37,7 @@ export const listAllSerialPorts = (): Promise<Ports> => {
function listSerialPorts() {
try {
// eslint-disable-next-line @typescript-eslint/no-var-requires
return require('serialport').list()
return SerialPort.list()
} catch (err) {
return Promise.resolve([])
}
Expand Down

0 comments on commit 39e75a0

Please sign in to comment.