Skip to content

Commit

Permalink
feature: add ability to add to the list of transmitted pgns
Browse files Browse the repository at this point in the history
  • Loading branch information
sbender9 committed Feb 2, 2018
1 parent d52906d commit a3acace
Showing 1 changed file with 25 additions and 17 deletions.
42 changes: 25 additions & 17 deletions lib/candevice.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@ const addressClaim = {
"Reserved2": 2
}

const defaultTransmitPGNs = [
60928,
59904,
126996,
126464,
128267,
129794,
129038,
129041,
127506,
127508,
129026,
129025,
129029,
127250,
13030
]

class CanDevice extends EventEmitter {
constructor (canbus, options) {
super()
Expand All @@ -47,6 +65,12 @@ class CanDevice extends EventEmitter {
this.cansend = false
this.foundConflict = false
this.devices = {}

this.transmitPGNs = defaultTransmitPGNs
if ( this.options.transmitPGNs ) {
this.transmitPGNs = _.union(this.transmitPGNs,
this.options.transmitPGNs)
}
}

start() {
Expand Down Expand Up @@ -269,23 +293,7 @@ function sendPGNList(device, src) {
pgn: 126464,
dst: src,
"Function Code": 0,
list: [
{ PGN: 60928 },
{ PGN: 59904 },
{ PGN: 126996 },
{ PGN: 126464 },
{ PGN: 128267 },
{ PGN: 129794 },
{ PGN: 129038 },
{ PGN: 129041 },
{ PGN: 127506 },
{ PGN: 127508 },
{ PGN: 129026 },
{ PGN: 129025 },
{ PGN: 129029 },
{ PGN: 127250 },
{ PGN: 130306 }
]
list: device.transmitPGNs
}
sendPGN(device, pgnList)
}
Expand Down

0 comments on commit a3acace

Please sign in to comment.