@canboat/canboatjs 2.8.1 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/candevice.js CHANGED
@@ -96,6 +96,7 @@ class CanDevice extends EventEmitter {
96
96
  this.address = _.isUndefined(options.preferredAddress) ? 100 : options.preferredAddress
97
97
  this.cansend = false
98
98
  this.foundConflict = false
99
+ this.heartbeatCounter = 0
99
100
  this.devices = {}
100
101
 
101
102
  if ( !options.disableDefaultTransmitPGNs ) {
@@ -271,6 +272,23 @@ function handleProductInformation(device, n2kMsg) {
271
272
  device.devices[n2kMsg.src].productInformation = n2kMsg
272
273
  }
273
274
 
275
+ function sendHeartbeat(device)
276
+ {
277
+ device.heartbeatCounter = device.heartbeatCounter + 1
278
+ if ( device.heartbeatCounter > 252 )
279
+ {
280
+ device.heartbeatCounter = 0
281
+ }
282
+ sendPGN(device,{
283
+ pgn: 126993,
284
+ dst: 255,
285
+ prio:7,
286
+ "Data transmit offset": "00:01:00",
287
+ "Sequence Counter": device.heartbeatCounter,
288
+ "Controller 1 State":"Error Active"
289
+ })
290
+ }
291
+
274
292
 
275
293
  function sendAddressClaim(device) {
276
294
  if ( device.devices[device.address] ) {
@@ -287,6 +305,9 @@ function sendAddressClaim(device) {
287
305
  device.options.app.emit('nmea2000OutAvailable')
288
306
  }
289
307
  sendISORequest(device, 126996)
308
+ device.heartbeatInterval = setInterval(() => {
309
+ sendHeartbeat(device)
310
+ }, 60*1000)
290
311
  /*
291
312
  _.keys(device.devices).forEach((address) => {
292
313
  sendISORequest(device, 126996, undefined, address)
@@ -73,7 +73,6 @@ describe('parseMultiLineCandumpV3', () => {
73
73
  msgs.forEach((msg) => {
74
74
  res = parseCandump3(msg)
75
75
  })
76
- console.log(res.data.toString('hex'))
77
76
  expect(res).toEqual({
78
77
  bus: "vcan0",
79
78
  canId: 166854913,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canboat/canboatjs",
3
- "version": "2.8.1",
3
+ "version": "2.9.0",
4
4
  "description": "Native javascript version of canboat",
5
5
  "main": "index.js",
6
6
  "scripts": {