@canboat/canboatjs 3.3.3 → 3.3.5

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.
Files changed (73) hide show
  1. package/dist/bin/actisense-file.js +2 -0
  2. package/dist/bin/actisense-file.js.map +1 -1
  3. package/dist/bin/actisense-n2k-tcp.js +2 -0
  4. package/dist/bin/actisense-n2k-tcp.js.map +1 -1
  5. package/dist/bin/actisense-serialjs.js +2 -0
  6. package/dist/bin/actisense-serialjs.js.map +1 -1
  7. package/dist/bin/analyzerjs.js +2 -0
  8. package/dist/bin/analyzerjs.js.map +1 -1
  9. package/dist/bin/candumpjs.js +7 -4
  10. package/dist/bin/candumpjs.js.map +1 -1
  11. package/dist/bin/cansend.js +2 -0
  12. package/dist/bin/cansend.js.map +1 -1
  13. package/dist/bin/to-pgn.js +2 -0
  14. package/dist/bin/to-pgn.js.map +1 -1
  15. package/dist/bin/utils.d.ts +4 -0
  16. package/dist/bin/utils.d.ts.map +1 -0
  17. package/dist/bin/utils.js +15 -0
  18. package/dist/bin/utils.js.map +1 -0
  19. package/dist/bin/ydvr-file.d.ts +3 -0
  20. package/dist/bin/ydvr-file.d.ts.map +1 -0
  21. package/dist/bin/ydvr-file.js +31 -0
  22. package/dist/bin/ydvr-file.js.map +1 -0
  23. package/dist/fromPgn.d.ts.map +1 -1
  24. package/dist/fromPgn.js +1 -0
  25. package/dist/fromPgn.js.map +1 -1
  26. package/package.json +4 -3
  27. package/tsconfig.tsbuildinfo +1 -1
  28. package/.github/workflows/publish.yml +0 -32
  29. package/.github/workflows/release_on_tag.yml +0 -27
  30. package/.github/workflows/require_pr_label.yml +0 -13
  31. package/.github/workflows/test.yml +0 -28
  32. package/.github/workflows/test_canboat_changes.yml +0 -92
  33. package/examples/signalk-device-emulator/index.js +0 -1
  34. package/examples/signalk-device-emulator/package.json +0 -24
  35. package/examples/simpleCan.js +0 -42
  36. package/ios.js +0 -67
  37. package/lib/actisense-serial.ts +0 -644
  38. package/lib/bin/actisense-file.ts +0 -53
  39. package/lib/bin/actisense-n2k-tcp.ts +0 -50
  40. package/lib/bin/actisense-serialjs.ts +0 -55
  41. package/lib/bin/analyzerjs.ts +0 -91
  42. package/lib/bin/candumpjs.ts +0 -100
  43. package/lib/bin/cansend.ts +0 -131
  44. package/lib/bin/ikonvert-serial.ts +0 -44
  45. package/lib/bin/to-pgn.ts +0 -65
  46. package/lib/bin/ydvr-file +0 -33
  47. package/lib/canId.test.js +0 -61
  48. package/lib/canId.ts +0 -84
  49. package/lib/canbus.ts +0 -293
  50. package/lib/candevice.ts +0 -41
  51. package/lib/codes.ts +0 -21
  52. package/lib/discovery.ts +0 -118
  53. package/lib/fromPgn.ts +0 -1217
  54. package/lib/fromPgnStream.ts +0 -54
  55. package/lib/ikonvert.ts +0 -250
  56. package/lib/index.ts +0 -48
  57. package/lib/n2k-actisense.test.js +0 -58
  58. package/lib/n2k-actisense.ts +0 -152
  59. package/lib/n2kDevice.ts +0 -509
  60. package/lib/pgns.test.ts +0 -12
  61. package/lib/pgns.ts +0 -191
  62. package/lib/simpleCan.ts +0 -140
  63. package/lib/stringMsg.test.js +0 -288
  64. package/lib/stringMsg.ts +0 -478
  65. package/lib/toPgn.ts +0 -601
  66. package/lib/utilities.test.js +0 -8
  67. package/lib/utilities.ts +0 -169
  68. package/lib/venus-mqtt.js +0 -118
  69. package/lib/venus.js +0 -88
  70. package/lib/w2k01.ts +0 -142
  71. package/lib/yddevice.ts +0 -48
  72. package/lib/ydgw02.ts +0 -197
  73. package/lib/ydvr.js +0 -138
package/lib/ydgw02.ts DELETED
@@ -1,197 +0,0 @@
1
- /**
2
- * Copyright 2018 Scott Bender (scott@scottbender.net)
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
-
17
- import { PGN } from '@canboat/ts-pgns'
18
- import { createDebug } from './utilities'
19
- import { Transform } from 'stream'
20
- import { Parser as FromPgn } from './fromPgn'
21
- import { YdDevice } from './yddevice'
22
- import {
23
- pgnToYdgwRawFormat,
24
- pgnToYdgwFullRawFormat,
25
- actisenseToYdgwRawFormat,
26
- actisenseToYdgwFullRawFormat
27
- } from './toPgn'
28
- import util from 'util'
29
-
30
- //const pgnsSent = {}
31
-
32
- export function Ydgw02Stream(this: any, options: any, type: string) {
33
- if (this === undefined) {
34
- return new (Ydgw02Stream as any)(options, type)
35
- }
36
-
37
- Transform.call(this, {
38
- objectMode: true
39
- })
40
-
41
- this.debug = createDebug('canboatjs:ydgw02', options)
42
- this.sentAvailable = false
43
- this.options = options
44
- this.outEvent = options.ydgwOutEvent || 'ydwg02-out'
45
- this.device = undefined
46
-
47
- this.fromPgn = new FromPgn(options)
48
-
49
- this.fromPgn.on('warning', (_pgn: any, _warning: string) => {
50
- //debug(`[warning] ${pgn.pgn} ${warning}`)
51
- })
52
-
53
- this.fromPgn.on('error', (pgn: PGN, error: any) => {
54
- this.debug(`[error] ${pgn.pgn} ${error}`)
55
- })
56
-
57
- if (options.app) {
58
- options.app.on(this.options.outEevent || 'nmea2000out', (msg: string) => {
59
- if (typeof msg === 'string') {
60
- this.sendYdgwPGN(msg)
61
- } else {
62
- this.sendPGN(msg)
63
- }
64
- options.app.emit('connectionwrite', { providerId: options.providerId })
65
- })
66
-
67
- options.app.on(options.jsonOutEvent || 'nmea2000JsonOut', (msg: PGN) => {
68
- this.sendPGN(msg)
69
- options.app.emit('connectionwrite', { providerId: options.providerId })
70
- })
71
-
72
- options.app.on('ydFullRawOut', (msgs: string[]) => {
73
- this.sendYdgwFullPGN(msgs)
74
- options.app.emit('connectionwrite', { providerId: options.providerId })
75
- })
76
-
77
- //this.sendString('$PDGY,N2NET_OFFLINE')
78
-
79
- if (type === 'usb') {
80
- // set ydnu to RAW mode
81
- options.app.emit(this.outEvent, Buffer.from([0x30, 0x0a]))
82
- }
83
-
84
- this.debug('started')
85
- }
86
- }
87
-
88
- Ydgw02Stream.prototype.cansend = function (_msg: any) {
89
- return this.options.createDevice
90
- ? this.device && this.device.cansend
91
- : this.sentAvailable
92
- }
93
-
94
- Ydgw02Stream.prototype.sendString = function (msg: string, forceSend: boolean) {
95
- if (this.cansend() || forceSend === true) {
96
- this.debug('sending %s', msg)
97
- this.options.app.emit(this.outEvent, msg)
98
- }
99
- }
100
-
101
- Ydgw02Stream.prototype.sendPGN = function (pgn: PGN) {
102
- if (this.cansend() || (pgn as any).forceSend === true) {
103
- //let now = Date.now()
104
- //let lastSent = pgnsSent[pgn.pgn]
105
- let msgs
106
- if ((pgn as any).ydFullFormat === true || this.device !== undefined) {
107
- pgn.src = this.device.address
108
- msgs = pgnToYdgwFullRawFormat(pgn)
109
- } else {
110
- msgs = pgnToYdgwRawFormat(pgn)
111
- }
112
- msgs.forEach((raw) => {
113
- this.sendString(raw + '\r\n', (pgn as any).forceSend)
114
- })
115
- //pgnsSent[pgn.pgn] = now
116
- }
117
- }
118
-
119
- Ydgw02Stream.prototype.sendYdgwFullPGN = function (msgs: string[]) {
120
- msgs.forEach((raw) => {
121
- this.sendString(raw + '\r\n')
122
- })
123
- }
124
-
125
- Ydgw02Stream.prototype.sendYdgwPGN = function (msg: string) {
126
- let msgs
127
-
128
- if (this.device != undefined) {
129
- msgs = actisenseToYdgwFullRawFormat(msg)
130
- } else {
131
- msgs = actisenseToYdgwRawFormat(msg)
132
- }
133
-
134
- msgs.forEach((raw) => {
135
- this.sendString(raw + '\r\n')
136
- })
137
-
138
- /*
139
- if ( !this.parser ) {
140
- this.parser = new Parser()
141
-
142
- let that = this
143
- this.parser.on('error', (pgn, error) => {
144
- console.error(`Error parsing ${pgn.pgn} ${error}`)
145
- console.error(error.stack)
146
- })
147
-
148
-
149
- this.parser.on('pgn', (pgn) => {
150
- let now = Date.now()
151
- let lastSent = pgnsSent[pgn.pgn]
152
- if ( !lastSent || now - lastSent > rateLimit ) {
153
- pgnToYdwgRawFormat(pgn).forEach(raw => {
154
- this.sendString(raw)
155
- })
156
- pgnsSent[pgn.pgn] = now
157
- }
158
- })
159
- }
160
- this.parser.parseString(msg)
161
- */
162
- }
163
-
164
- util.inherits(Ydgw02Stream, Transform)
165
-
166
- Ydgw02Stream.prototype._transform = function (
167
- chunk: any,
168
- encoding: any,
169
- done: any
170
- ) {
171
- const line = chunk.toString().trim()
172
- //line = line.substring(0, line.length) // take off the \r
173
-
174
- if (this.device === undefined && !this.sentAvailable) {
175
- this.debug('emit nmea2000OutAvailable')
176
- this.options.app.emit('nmea2000OutAvailable')
177
- this.sentAvailable = true
178
-
179
- if (this.options.createDevice === true) {
180
- this.device = new YdDevice(this.options)
181
- this.device.start()
182
- }
183
- }
184
-
185
- const pgn = this.fromPgn.parseYDGW02(line)
186
- if (pgn !== undefined) {
187
- this.push(pgn)
188
- this.options.app.emit(
189
- this.options.analyzerOutEvent || 'N2KAnalyzerOut',
190
- pgn
191
- )
192
- }
193
-
194
- done()
195
- }
196
-
197
- Ydgw02Stream.prototype.end = function () {}
package/lib/ydvr.js DELETED
@@ -1,138 +0,0 @@
1
- const BitStream = require('bit-buffer').BitStream
2
- const Transform = require('stream').Transform
3
- const FromPgn = require('./fromPgn').Parser
4
- const parseCanId = require('./canId').parseCanId
5
-
6
- // https://www.yachtd.com/downloads/ydvr04.pdf Appendix D
7
- var sequencePgns = new Set([
8
- 65240, 126208, 126464, 126720, 126983, 126984, 126985, 126986, 126987, 126988,
9
- 126996, 126998, 127233, 127237, 127489, 127496, 127497, 127498, 127503,
10
- 127504, 127506, 127507, 127509, 127510, 127511, 127512, 127513, 127514,
11
- 128275, 128520, 129029, 129038, 129039, 129040, 129041, 129044, 129045,
12
- 129284, 129285, 129301, 129302, 129538, 129540, 129541, 129542, 129545,
13
- 129547, 129549, 129551, 129556, 129792, 129793, 129794, 129795, 129796,
14
- 129797, 129798, 129799, 129800, 129801, 129802, 129803, 129804, 129805,
15
- 129806, 129807, 129808, 129809, 129810, 130052, 130053, 130054, 130060,
16
- 130061, 130064, 130065, 130066, 130067, 130068, 130069, 130070, 130071,
17
- 130072, 130073, 130074, 130320, 130321, 130322, 130323, 130324, 130567,
18
- 130577, 130578, 130816
19
- ])
20
-
21
- function YdvrStream(options) {
22
- if (!(this instanceof YdvrStream)) {
23
- return new YdvrStream(options)
24
- }
25
-
26
- this.parser = new FromPgn(options)
27
-
28
- this.messageCount = 0
29
- this.errorCount = 0
30
- this.timerResetCount = 0
31
-
32
- this.parser.on('error', (pgn, error) => {
33
- console.error(`Error parsing ${pgn.pgn} ${error}`)
34
- console.error(error.stack)
35
- })
36
-
37
- this.parser.on('warning', (_pgn, _error) => {
38
- //console.error(`Warning parsing ${pgn.pgn} ${error}`)
39
- })
40
-
41
- // this.parser.on('pgn', (pgn) => {
42
- // console.log(JSON.stringify(pgn));
43
- // });
44
-
45
- Transform.call(this, {
46
- objectMode: true
47
- })
48
- }
49
-
50
- require('util').inherits(YdvrStream, Transform)
51
-
52
- YdvrStream.prototype.end = function () {
53
- // console.log('end');
54
- }
55
-
56
- YdvrStream.prototype.parseNextRecord = function () {
57
- if (this.bs.bitsLeft < 6 * 8) {
58
- return false
59
- }
60
-
61
- var time = this.bs.readUint16()
62
- //let timeAbsolute;
63
- if (this.lastTime != null && time < this.lastTime) {
64
- this.timeOffset = (this.timeOffset || 0) + 60000
65
- //timeAbsolute = time + this.timeOffset;
66
- this.timerResetCount += 1
67
- } /*else {
68
- timeAbsolute = time;
69
- }
70
- */
71
- this.lastTime = time
72
-
73
- var identifier = this.bs.readUint32()
74
- if (identifier === 0xffffffff) {
75
- // service record
76
- if (this.bs.bitsLeft < 8 * 8) {
77
- return false
78
- }
79
- var _srData = this.bs.readArrayBuffer(8)
80
- } else {
81
- const pgn = parseCanId(identifier)
82
-
83
- var bodyLen
84
- if (pgn.pgn == 59904) {
85
- bodyLen = 3
86
- } else if (sequencePgns.has(pgn.pgn)) {
87
- var _seq = this.bs.readUint8()
88
- bodyLen = this.bs.readUint8()
89
- } else {
90
- bodyLen = 8
91
- }
92
- if (this.bs.bitsLeft < bodyLen * 8) {
93
- return false
94
- }
95
- var body = this.bs.readArrayBuffer(bodyLen)
96
-
97
- const parsed = this.parser.parsePgnData(
98
- pgn,
99
- bodyLen,
100
- Buffer.from(body),
101
- false,
102
- undefined
103
- )
104
- if (parsed) {
105
- parsed.time = new Date(time).toISOString().slice(11, 23)
106
- this.push(parsed)
107
- }
108
- }
109
-
110
- this.messageCount += 1
111
- return true
112
- }
113
-
114
- YdvrStream.prototype._transform = function (chunk, encoding, done) {
115
- if (this.bs == null) {
116
- this.bs = new BitStream(chunk)
117
- } else {
118
- var remainingBuffer = this.bs.view.buffer.subarray(this.bs.byteIndex)
119
- this.bs = new BitStream(Buffer.concat([remainingBuffer, chunk]))
120
- }
121
- while (true) {
122
- var startIndex = this.bs.byteIndex
123
- let parsed = false
124
- try {
125
- parsed = this.parseNextRecord()
126
- } catch (ex) {
127
- console.error(ex)
128
- this.errorCount += 1
129
- }
130
- if (!parsed) {
131
- this.bs.byteIndex = startIndex
132
- break
133
- }
134
- }
135
- done()
136
- }
137
-
138
- module.exports = YdvrStream