@canboat/canboatjs 3.0.2 → 3.2.2

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 (222) hide show
  1. package/.github/workflows/publish.yml +18 -9
  2. package/.github/workflows/test.yml +2 -2
  3. package/.github/workflows/test_canboat_changes.yml +91 -0
  4. package/.husky/pre-commit +4 -0
  5. package/.mocharc.js +7 -0
  6. package/.prettierrc.json +5 -0
  7. package/README.md +5 -14
  8. package/dist/actisense-serial.d.ts +17 -0
  9. package/dist/actisense-serial.d.ts.map +1 -0
  10. package/dist/actisense-serial.js +569 -0
  11. package/dist/actisense-serial.js.map +1 -0
  12. package/dist/bin/actisense-file.d.ts +3 -0
  13. package/dist/bin/actisense-file.d.ts.map +1 -0
  14. package/dist/bin/actisense-file.js +49 -0
  15. package/dist/bin/actisense-file.js.map +1 -0
  16. package/dist/bin/actisense-n2k-tcp.d.ts +3 -0
  17. package/dist/bin/actisense-n2k-tcp.d.ts.map +1 -0
  18. package/dist/bin/actisense-n2k-tcp.js +46 -0
  19. package/dist/bin/actisense-n2k-tcp.js.map +1 -0
  20. package/dist/bin/actisense-serialjs.d.ts +3 -0
  21. package/dist/bin/actisense-serialjs.d.ts.map +1 -0
  22. package/dist/bin/actisense-serialjs.js +51 -0
  23. package/dist/bin/actisense-serialjs.js.map +1 -0
  24. package/dist/bin/analyzerjs.d.ts +3 -0
  25. package/dist/bin/analyzerjs.d.ts.map +1 -0
  26. package/dist/bin/analyzerjs.js +61 -0
  27. package/dist/bin/analyzerjs.js.map +1 -0
  28. package/dist/bin/candumpjs.d.ts +3 -0
  29. package/dist/bin/candumpjs.d.ts.map +1 -0
  30. package/dist/bin/candumpjs.js +73 -0
  31. package/dist/bin/candumpjs.js.map +1 -0
  32. package/dist/bin/cansend.d.ts +3 -0
  33. package/dist/bin/cansend.d.ts.map +1 -0
  34. package/dist/bin/cansend.js +123 -0
  35. package/dist/bin/cansend.js.map +1 -0
  36. package/dist/bin/ikonvert-serial.d.ts +3 -0
  37. package/dist/bin/ikonvert-serial.d.ts.map +1 -0
  38. package/dist/bin/ikonvert-serial.js +36 -0
  39. package/dist/bin/ikonvert-serial.js.map +1 -0
  40. package/dist/bin/to-pgn.d.ts +3 -0
  41. package/dist/bin/to-pgn.d.ts.map +1 -0
  42. package/dist/bin/to-pgn.js +57 -0
  43. package/dist/bin/to-pgn.js.map +1 -0
  44. package/dist/canId.d.ts +21 -0
  45. package/dist/canId.d.ts.map +1 -0
  46. package/dist/canId.js +66 -0
  47. package/dist/canId.js.map +1 -0
  48. package/dist/canId.test.d.ts +2 -0
  49. package/dist/canId.test.d.ts.map +1 -0
  50. package/dist/canId.test.js +58 -0
  51. package/dist/canId.test.js.map +1 -0
  52. package/dist/canbus.d.ts +17 -0
  53. package/dist/canbus.d.ts.map +1 -0
  54. package/dist/canbus.js +261 -0
  55. package/dist/canbus.js.map +1 -0
  56. package/dist/candevice.d.ts +23 -0
  57. package/dist/candevice.d.ts.map +1 -0
  58. package/dist/candevice.js +36 -0
  59. package/dist/candevice.js.map +1 -0
  60. package/dist/codes.d.ts +2 -0
  61. package/dist/codes.d.ts.map +1 -0
  62. package/dist/codes.js +24 -0
  63. package/dist/codes.js.map +1 -0
  64. package/dist/discovery.d.ts +17 -0
  65. package/dist/discovery.d.ts.map +1 -0
  66. package/dist/discovery.js +119 -0
  67. package/dist/discovery.js.map +1 -0
  68. package/dist/fromPgn.d.ts +51 -0
  69. package/dist/fromPgn.d.ts.map +1 -0
  70. package/dist/fromPgn.js +989 -0
  71. package/dist/fromPgn.js.map +1 -0
  72. package/dist/fromPgnStream.d.ts +17 -0
  73. package/dist/fromPgnStream.d.ts.map +1 -0
  74. package/dist/fromPgnStream.js +47 -0
  75. package/dist/fromPgnStream.js.map +1 -0
  76. package/dist/ikonvert.d.ts +17 -0
  77. package/dist/ikonvert.d.ts.map +1 -0
  78. package/dist/ikonvert.js +224 -0
  79. package/dist/ikonvert.js.map +1 -0
  80. package/dist/index.d.ts +31 -0
  81. package/dist/index.d.ts.map +1 -0
  82. package/dist/index.js +60 -0
  83. package/dist/index.js.map +1 -0
  84. package/dist/n2k-actisense.d.ts +24 -0
  85. package/dist/n2k-actisense.d.ts.map +1 -0
  86. package/dist/n2k-actisense.js +126 -0
  87. package/dist/n2k-actisense.js.map +1 -0
  88. package/dist/n2k-actisense.test.d.ts +2 -0
  89. package/dist/n2k-actisense.test.d.ts.map +1 -0
  90. package/dist/n2k-actisense.test.js +49 -0
  91. package/dist/n2k-actisense.test.js.map +1 -0
  92. package/dist/n2kDevice.d.ts +44 -0
  93. package/dist/n2kDevice.d.ts.map +1 -0
  94. package/dist/n2kDevice.js +436 -0
  95. package/dist/n2kDevice.js.map +1 -0
  96. package/dist/pgns.d.ts +22 -0
  97. package/dist/pgns.d.ts.map +1 -0
  98. package/dist/pgns.js +157 -0
  99. package/dist/pgns.js.map +1 -0
  100. package/dist/pgns.test.d.ts +2 -0
  101. package/dist/pgns.test.d.ts.map +1 -0
  102. package/dist/pgns.test.js +14 -0
  103. package/dist/pgns.test.js.map +1 -0
  104. package/dist/simpleCan.d.ts +17 -0
  105. package/dist/simpleCan.d.ts.map +1 -0
  106. package/dist/simpleCan.js +125 -0
  107. package/dist/simpleCan.js.map +1 -0
  108. package/dist/stringMsg.d.ts +33 -0
  109. package/dist/stringMsg.d.ts.map +1 -0
  110. package/dist/stringMsg.js +359 -0
  111. package/dist/stringMsg.js.map +1 -0
  112. package/dist/stringMsg.test.d.ts +2 -0
  113. package/dist/stringMsg.test.d.ts.map +1 -0
  114. package/dist/stringMsg.test.js +244 -0
  115. package/dist/stringMsg.test.js.map +1 -0
  116. package/dist/toPgn.d.ts +34 -0
  117. package/dist/toPgn.d.ts.map +1 -0
  118. package/dist/toPgn.js +500 -0
  119. package/dist/toPgn.js.map +1 -0
  120. package/dist/utilities.d.ts +28 -0
  121. package/dist/utilities.d.ts.map +1 -0
  122. package/dist/utilities.js +159 -0
  123. package/dist/utilities.js.map +1 -0
  124. package/dist/utilities.test.d.ts +2 -0
  125. package/dist/utilities.test.d.ts.map +1 -0
  126. package/dist/utilities.test.js +9 -0
  127. package/dist/utilities.test.js.map +1 -0
  128. package/dist/venus-mqtt.d.ts +11 -0
  129. package/dist/venus-mqtt.d.ts.map +1 -0
  130. package/dist/venus-mqtt.js +100 -0
  131. package/dist/venus-mqtt.js.map +1 -0
  132. package/dist/venus.d.ts +11 -0
  133. package/dist/venus.d.ts.map +1 -0
  134. package/dist/venus.js +71 -0
  135. package/dist/venus.js.map +1 -0
  136. package/dist/w2k01.d.ts +17 -0
  137. package/dist/w2k01.d.ts.map +1 -0
  138. package/dist/w2k01.js +119 -0
  139. package/dist/w2k01.js.map +1 -0
  140. package/dist/yddevice.d.ts +25 -0
  141. package/dist/yddevice.d.ts.map +1 -0
  142. package/dist/yddevice.js +43 -0
  143. package/dist/yddevice.js.map +1 -0
  144. package/dist/ydgw02.d.ts +17 -0
  145. package/dist/ydgw02.d.ts.map +1 -0
  146. package/dist/ydgw02.js +163 -0
  147. package/dist/ydgw02.js.map +1 -0
  148. package/dist/ydvr.d.ts +17 -0
  149. package/dist/ydvr.d.ts.map +1 -0
  150. package/dist/ydvr.js +120 -0
  151. package/dist/ydvr.js.map +1 -0
  152. package/eslint.config.js +58 -0
  153. package/jest.config.js +5 -0
  154. package/lib/actisense-serial.ts +644 -0
  155. package/lib/bin/actisense-file.ts +53 -0
  156. package/lib/bin/actisense-n2k-tcp.ts +50 -0
  157. package/lib/bin/actisense-serialjs.ts +55 -0
  158. package/{bin/analyzerjs → lib/bin/analyzerjs.ts} +16 -15
  159. package/{bin/candumpjs → lib/bin/candumpjs.ts} +19 -20
  160. package/lib/bin/cansend.ts +131 -0
  161. package/lib/bin/ikonvert-serial.ts +44 -0
  162. package/{bin/to-pgn → lib/bin/to-pgn.ts} +23 -17
  163. package/lib/bin/ydvr-file +33 -0
  164. package/lib/canId.test.js +35 -15
  165. package/lib/canId.ts +84 -0
  166. package/lib/canbus.ts +293 -0
  167. package/lib/candevice.ts +41 -0
  168. package/lib/codes.ts +21 -0
  169. package/lib/{discovery.js → discovery.ts} +32 -30
  170. package/lib/fromPgn.ts +1207 -0
  171. package/lib/{fromPgnStream.js → fromPgnStream.ts} +17 -12
  172. package/lib/{ikonvert.js → ikonvert.ts} +99 -94
  173. package/lib/index.ts +48 -0
  174. package/lib/n2k-actisense.test.js +31 -32
  175. package/lib/n2k-actisense.ts +152 -0
  176. package/lib/n2kDevice.ts +516 -0
  177. package/lib/pgns.test.ts +12 -0
  178. package/lib/pgns.ts +191 -0
  179. package/lib/simpleCan.ts +140 -0
  180. package/lib/stringMsg.test.js +58 -41
  181. package/lib/stringMsg.ts +464 -0
  182. package/lib/toPgn.ts +597 -0
  183. package/lib/utilities.ts +169 -0
  184. package/lib/venus-mqtt.js +69 -73
  185. package/lib/venus.js +8 -8
  186. package/lib/w2k01.ts +142 -0
  187. package/lib/{yddevice.js → yddevice.ts} +18 -16
  188. package/lib/{ydgw02.js → ydgw02.ts} +58 -51
  189. package/lib/ydvr.js +65 -147
  190. package/package.json +54 -18
  191. package/tsconfig.json +19 -0
  192. package/tsconfig.tsbuildinfo +1 -0
  193. package/CHANGELOG.md +0 -101
  194. package/bin/actisense-file +0 -47
  195. package/bin/actisense-n2k-tcp +0 -45
  196. package/bin/actisense-serialjs +0 -52
  197. package/bin/candumpanalyzerjs +0 -29
  198. package/bin/cansend +0 -130
  199. package/bin/ikonvert-serial +0 -50
  200. package/bin/ydgw-analyzerjs +0 -36
  201. package/bin/ydvr-file +0 -33
  202. package/index.js +0 -53
  203. package/ios_canboat.js/main.js +0 -2
  204. package/ios_canboat.js/main.js.LICENSE.txt +0 -17
  205. package/ios_canboat.js/main.js.map +0 -1
  206. package/lib/canId.js +0 -64
  207. package/lib/canbus.js +0 -278
  208. package/lib/candevice.js +0 -51
  209. package/lib/codes.js +0 -69
  210. package/lib/codes.test.js +0 -17
  211. package/lib/codesMfgs.json +0 -166
  212. package/lib/fromPgn.js +0 -1027
  213. package/lib/n2k-actisense.js +0 -108
  214. package/lib/n2kDevice.js +0 -390
  215. package/lib/pgns.js +0 -196
  216. package/lib/pgns.test.js +0 -13
  217. package/lib/serial.js +0 -647
  218. package/lib/simpleCan.js +0 -105
  219. package/lib/stringMsg.js +0 -339
  220. package/lib/toPgn.js +0 -518
  221. package/lib/utilities.js +0 -111
  222. package/lib/w2k01.js +0 -129
package/lib/canId.js DELETED
@@ -1,64 +0,0 @@
1
- const { flow } = require('lodash/fp')
2
-
3
- // Decode CAN Identifier (canId). ISO 11783 (CAN 2.0 B Extended Frame Format)
4
- exports.parseCanId = (id) => {
5
- const res = {
6
- canId: id, // Include original canId in return object.
7
- prio: ((id >> 26) & 0x7), // Priority
8
- src: id & 0xff, // Source Address (SA)
9
- }
10
- const PF = (id >> 16) & 0xff // PDU Format
11
- const PS = (id >> 8) & 0xff // PDU Specific
12
- const DP = (id >> 24) & 1 // Data Page
13
-
14
- if (PF < 240) {
15
- /* PDU1 format, the PS contains the destination address */
16
- res.dst = PS;
17
- res.pgn = (DP << 16) + (PF << 8);
18
- } else {
19
- /* PDU2 format, the destination is implied global and the PGN is extended */
20
- res.dst = 0xff
21
- res.pgn = (DP << 16) + (PF << 8) + PS
22
- }
23
- return res
24
- }
25
- // canId should be a hex encoded string without spaces or commas.
26
- exports.parseCanIdStr = canId => exports.parseCanId(parseInt(canId, 16))
27
-
28
- exports.buildCanId = (prio, pgn, dst, src) => ({
29
- prio: Number(prio),
30
- pgn: Number(pgn),
31
- dst: Number(dst),
32
- src: Number(src),
33
- })
34
-
35
- // Encode CAN Identifier (canId)
36
- exports.encodeCanId = ({ dst, pgn, prio, src }) => {
37
- let canId = src & 0xff
38
-
39
- //I can't get this to work, but things seem ok??
40
- //let canId = ((src & 0xff) | 0x80000000)) // src bits are the lowest ones of the CAN ID. Also set the highest bit to 1 as n2k uses
41
- // only extended frames (EFF bit).
42
-
43
- const PF = (pgn >> 8) & 0xff
44
-
45
- if (PF < 240)
46
- { // PDU 1
47
- canId = (canId | ((dst & 0xff) << 8))
48
- canId = (canId | (pgn << 8))
49
- }
50
- else
51
- { // PDU 2
52
- canId = (canId | pgn << 8)
53
- }
54
- canId = (canId | prio << 26)
55
-
56
- return canId
57
- }
58
- exports.canIdString = canId => canId.toString(16).padStart(8, '0')
59
- exports.encodeCanIdString = flow(
60
- exports.encodeCanId,
61
- exports.canIdString,
62
- )
63
- // Utility function that parses and re-encodes. Compare result to original.
64
- exports.parseEncode = x => exports.encodeCanId(exports.parseCanId(x))
package/lib/canbus.js DELETED
@@ -1,278 +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
- const debug = require('debug')('canboatjs:canbus')
18
- const Transform = require('stream').Transform
19
- const isArray = require('lodash').isArray
20
- const BitStream = require('bit-buffer').BitStream
21
- const BitView = require('bit-buffer').BitView
22
- const { toPgn } = require('./toPgn')
23
- const Parser = require('./fromPgn').Parser
24
- const _ = require('lodash')
25
- const CanDevice = require('./candevice')
26
- const { getPlainPGNs, binToActisense } = require('./utilities')
27
- const { encodeCanId, parseCanId } = require('./canId')
28
- const { toActisenseSerialFormat, parseActisense } = require('./stringMsg')
29
-
30
- const MSG_BUF_SIZE = 2000
31
- const CANDUMP_DATA_INC_3 = 3
32
- const CANDUMP_DATA_INC_2 = 2
33
- const MAX_DATA_BYTES = 223
34
-
35
- // There are at least three variations in candump output
36
- // format which are currently handled...
37
- //
38
- const FMT_TBD = 0
39
- const FMT_1 = 1 // Angstrom ex: "<0x18eeff01> [8] 05 a0 be 1c 00 a0 a0 c0"
40
- const FMT_2 = 2 // Debian ex: " can0 09F8027F [8] 00 FC FF FF 00 00 FF FF"
41
- const FMT_3 = 3 // candump log ex: "(1502979132.106111) slcan0 09F50374#000A00FFFF00FFFF"
42
-
43
-
44
- function CanbusStream (options) {
45
- if (!(this instanceof CanbusStream)) {
46
- return new CanbusStream(options)
47
- }
48
-
49
- Transform.call(this, {
50
- objectMode: true
51
- })
52
-
53
- this.plainText = false
54
- this.options = options
55
- this.start()
56
-
57
- this.setProviderStatus = options.app && options.app.setProviderStatus
58
- ? (msg) => {
59
- options.app.setProviderStatus(options.providerId, msg)
60
- }
61
- : () => {}
62
- this.setProviderError = options.app && options.app.setProviderError
63
- ? (msg) => {
64
- options.app.setProviderError(options.providerId, msg)
65
- }
66
- : () => {}
67
-
68
- if ( options.fromStdIn ) {
69
- return
70
- }
71
-
72
- try {
73
- this.socketcan = require('socketcan')
74
- } catch ( err ) {
75
- console.error(err)
76
- var msg = 'unable to load native socketcan interface'
77
- console.error(msg)
78
- }
79
-
80
- var that = this
81
-
82
- if ( options.app ) {
83
- options.app.on(options.outEvent || 'nmea2000out', (msg) => {
84
- that.sendPGN(msg)
85
- })
86
- options.app.on(options.jsonOutEvent || 'nmea2000JsonOut', (msg) => {
87
- that.sendPGN(msg)
88
- })
89
- }
90
-
91
- var canDevice = options.canDevice || 'can0'
92
-
93
- if ( this.connect() == false ) {
94
- return
95
- }
96
-
97
- const noDataReceivedTimeout = typeof options.noDataReceivedTimeout !== 'undefined' ? options.noDataReceivedTimeout : -1
98
- if ( noDataReceivedTimeout > 0 ) {
99
- this.noDataInterval = setInterval(() => {
100
- if ( this.channel && this.lastDataReceived && Date.now() - this.lastDataReceived > noDataReceivedTimeout * 1000 ) {
101
- let channel = this.channel
102
- delete this.channel
103
- try {
104
- channel.stop()
105
- } catch ( error ) {
106
- }
107
- this.setProviderError('No data received, retrying...')
108
- if ( this.options.app ) {
109
- console.error('No data received, retrying...')
110
- }
111
- this.connect()
112
- }
113
- }, noDataReceivedTimeout * 1000)
114
- }
115
- }
116
-
117
- CanbusStream.prototype.connect = function() {
118
- try {
119
- if ( this.socketcan === undefined ) {
120
- this.setProviderError('unable to load native socketcan interface')
121
- return false
122
- }
123
-
124
- var that = this
125
- var canDevice = this.options.canDevice || 'can0'
126
- this.channel = this.socketcan.createRawChannelWithOptions(canDevice, { non_block_send: true} );
127
- this.channel.addListener('onStopped', (msg) => {
128
- if ( this.channel ) { // stoped by us?
129
- delete this.channel
130
- this.setProviderError('Stopped, Retrying...')
131
- if ( this.options.app ) {
132
- console.error('socketcan stopped, retrying...')
133
- }
134
- setTimeout(() => {
135
- this.setProviderError('Reconnecting...')
136
- this.connect()
137
- }, 2000)
138
- }
139
- })
140
- this.channel.addListener('onMessage', (msg) => {
141
- var pgn = parseCanId(msg.id)
142
-
143
- if ( this.noDataInterval ) {
144
- this.lastDataReceived = Date.now()
145
- }
146
-
147
- //always send address claims through
148
- if ( pgn.pgn != 60928 && that.candevice && that.candevice.cansend && pgn.src == that.candevice.address ) {
149
- return
150
- }
151
-
152
- pgn.timestamp = new Date().toISOString()
153
- if ( that.plainText ) {
154
- this.push(binToActisense(pgn, msg.data, msg.data.length))
155
- } else {
156
- that.push({ pgn, length: msg.data.length, data: msg.data })
157
- }
158
- })
159
- this.channel.start()
160
- this.setProviderStatus('Connected to socketcan')
161
- this.candevice = new CanDevice(this, this.options)
162
- this.candevice.start()
163
- return true
164
- } catch (e) {
165
- console.error(`unable to open canbus ${canDevice}: ${e}`)
166
- console.error(e.stack)
167
- this.setProviderError(e.message)
168
- return false
169
- }
170
- }
171
-
172
- require('util').inherits(CanbusStream, Transform)
173
-
174
- CanbusStream.prototype.start = function () {
175
- }
176
-
177
- CanbusStream.prototype.sendPGN = function (msg, force) {
178
- if ( this.candevice ) {
179
- //if ( !this.candevice.cansend && (_.isString(msg) || msg.pgn !== 59904) ) {
180
- if ( !this.candevice.cansend && force !== true ) {
181
- //we have not completed address claim yet
182
- return
183
- }
184
-
185
- debug('sending %j', msg)
186
-
187
- if ( this.options.app ) {
188
- this.options.app.emit('connectionwrite', { providerId: this.options.providerId })
189
- }
190
-
191
- let src = msg.pgn === 59904 || msg.forceSrc ? msg.src : this.candevice.address
192
- if ( _.isString(msg) ) {
193
- var split = msg.split(',')
194
- split[3] = src
195
- msg = split.join(',')
196
- } else {
197
- msg.src = src
198
- if ( _.isUndefined(msg.prio) ) {
199
- msg.prio = 3
200
- }
201
- if ( _.isUndefined(msg.dst) ) {
202
- msg.dst = 255
203
- }
204
- }
205
-
206
- if ( this.socketCanWriter ) {
207
- if ( _.isString(msg) ) {
208
- this.socketCanWriter.stdin.write(msg + '\n')
209
- } else {
210
- var str = toActisenseSerialFormat(msg.pgn, toPgn(msg), msg.dst, msg.src)
211
- this.socketCanWriter.stdin.write(str + '\n')
212
- }
213
- } else if ( this.channel ) {
214
- var canid
215
- var buffer
216
-
217
- var pgn
218
- if ( _.isObject(msg) ) {
219
- canid = encodeCanId(msg)
220
- buffer = toPgn(msg)
221
- pgn = msg
222
- } else {
223
- pgn = parseActisense(msg)
224
- canid = encodeCanId(pgn)
225
- buffer = pgn.data
226
- }
227
-
228
- if ( debug.enabled ) {
229
- var str = toActisenseSerialFormat(pgn.pgn, buffer, pgn.dst, pgn.src)
230
- debug(str)
231
- }
232
-
233
- //seems as though 126720 should always be encoded this way
234
- if ( buffer.length > 8 || pgn.pgn == 126720 ) {
235
- var pgns = getPlainPGNs(buffer)
236
- pgns.forEach(pbuffer => {
237
- this.channel.send({id: canid, ext:true, data: pbuffer})
238
- })
239
- } else {
240
- this.channel.send({id: canid, ext:true, data: buffer})
241
- }
242
- }
243
- }
244
- }
245
-
246
-
247
- CanbusStream.prototype._transform = function (chunk, encoding, done) {
248
- done()
249
- }
250
-
251
- CanbusStream.prototype.end = function () {
252
- if ( this.channel ) {
253
- let channel = this.channel
254
- delete this.channel
255
- channel.stop()
256
- }
257
- if ( this.noDataInterval ) {
258
- clearInterval(this.noDataInterval)
259
- }
260
- }
261
-
262
-
263
- CanbusStream.prototype.pipe = function (pipeTo) {
264
- if ( !pipeTo.fromPgn ) {
265
- this.plainText = true
266
- }
267
- /*
268
- pipeTo.fromPgn.on('pgn', (pgn) => {
269
- if ( this.candevice ) {
270
- this.candevice.n2kMessage(pgn)
271
- }
272
- })
273
- */
274
- return CanbusStream.super_.prototype.pipe.call(this, pipeTo)
275
- }
276
-
277
-
278
- module.exports = CanbusStream
package/lib/candevice.js DELETED
@@ -1,51 +0,0 @@
1
- /**
2
- * Copyright 2018 Scott Bender (scott@scottbender.net) and Jouni Hartikainen (jouni.hartikainen@iki.fi)
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
- const debug = require('debug')('canboatjs:candevice')
18
- const EventEmitter = require('events')
19
- const _ = require('lodash')
20
- const Uint64LE = require('int64-buffer').Uint64LE
21
- const { defaultTransmitPGNs, getIndustryCode, getManufacturerCode, getDeviceClassCode } = require('./codes')
22
- const { toPgn } = require('./toPgn')
23
- const N2kDevice = require('./n2kDevice')
24
-
25
- let packageJson
26
- try
27
- {
28
- packageJson = require('../' + 'package.json')
29
- } catch (ex) {
30
- }
31
-
32
- const deviceTransmitPGNs = [ 60928, 59904, 126996, 126464 ]
33
-
34
- class CanDevice extends N2kDevice {
35
- constructor (canbus, options) {
36
- super(options)
37
- this.canbus = canbus
38
-
39
- if ( options.app ) {
40
- options.app.on(options.analyzerOutEvent || 'N2KAnalyzerOut', this.n2kMessage.bind(this))
41
- }
42
- }
43
-
44
- sendPGN(pgn, src) {
45
- pgn.src = src || this.address
46
- debug('Sending PGN %j', pgn)
47
- this.canbus.sendPGN(pgn, true)
48
- }
49
- }
50
-
51
- module.exports = CanDevice
package/lib/codes.js DELETED
@@ -1,69 +0,0 @@
1
- const { invert, propertyOf } = require('lodash/fp')
2
- const manufacturerNames = require('./codesMfgs.json')
3
-
4
- const industryCodes = {
5
- 0: 'Global',
6
- 1: 'Highway',
7
- 2: 'Agriculture',
8
- 3: 'Construction',
9
- 4: 'Marine Industry',
10
- 5: 'Industrial'
11
- }
12
-
13
- const deviceClassCodes = {
14
- 0: 'Reserved for 2000 Use',
15
- 10: 'System tools',
16
- 20: 'Safety systems',
17
- 25: 'Internetwork device',
18
- 30: 'Electrical Distribution',
19
- 35: 'Electrical Generation',
20
- 40: 'Steering and Control surfaces',
21
- 50: 'Propulsion',
22
- 60: 'Navigation',
23
- 70: 'Communication',
24
- 75: 'Sensor Communication Interface',
25
- 80: 'Instrumentation/general systems',
26
- 85: 'External Environment',
27
- 90: 'Internal Environment',
28
- 100: 'Deck + cargo + fishing equipment systems',
29
- 120: 'Display',
30
- 125: 'Entertainment'
31
- }
32
-
33
- const deviceClassNames = invert(deviceClassCodes)
34
- const industryNames = invert(industryCodes)
35
- industryNames['Marine'] = 4
36
-
37
- const defaultTransmitPGNs = [
38
- 126992,
39
- 128267,
40
- 129794,
41
- 129038,
42
- 129041,
43
- 127505,
44
- 127506,
45
- 127508,
46
- 129026,
47
- 129025,
48
- 129029,
49
- 127250,
50
- 130306,
51
- 126720,
52
- 127489,
53
- 127488,
54
- 130311,
55
- 130312,
56
- 127257,
57
- 128259,
58
- 127502
59
- ]
60
-
61
- const manufacturerCodes = invert(manufacturerNames)
62
- module.exports.manufacturerCodes = manufacturerCodes
63
- module.exports.getIndustryName = propertyOf(industryCodes)
64
- module.exports.getManufacturerName = propertyOf(manufacturerCodes)
65
- module.exports.getIndustryCode = propertyOf(industryNames)
66
- module.exports.getManufacturerCode = propertyOf(manufacturerNames)
67
- module.exports.getDeviceClassCode = propertyOf(deviceClassNames)
68
- module.exports.getDeviceClassName = propertyOf(deviceClassCodes)
69
- module.exports.defaultTransmitPGNs = defaultTransmitPGNs
package/lib/codes.test.js DELETED
@@ -1,17 +0,0 @@
1
- const { getManufacturerCode, getManufacturerName } = require('./codes')
2
-
3
- describe('getManufacturerCode', () => {
4
- test('Return mfg number from name string', () => {
5
- expect(getManufacturerCode('Furuno')).toBe(1855)
6
- expect(getManufacturerCode('Yacht Devices')).toBe(717)
7
- expect(getManufacturerCode('TJC Micro')).toBe(963)
8
- })
9
- })
10
-
11
- describe('getManufacturerName', () => {
12
- test('Return name string from mfg number', () => {
13
- expect(getManufacturerName(1855)).toBe('Furuno')
14
- expect(getManufacturerName(717)).toBe('Yacht Devices')
15
- expect(getManufacturerName(963)).toBe('TJC Micro')
16
- })
17
- })
@@ -1,166 +0,0 @@
1
- {
2
- "AEM Power": 735,
3
- "Actia": 199,
4
- "Actisense - Active Research Ltd": 273,
5
- "Advansea": 578,
6
- "Aetna Engineering/Fireboy/Xintex": 215,
7
- "Airmar": 135,
8
- "Alltek Marine Electronics Corp": 459,
9
- "Amphenol LTW Technology": 274,
10
- "Aquatic AV": 600,
11
- "Arlt Tecnologies": 614,
12
- "Attwood Marine": 502,
13
- "Au Electronics Group": 735,
14
- "Autonnic": 715,
15
- "Aventics GmbH": 605,
16
- "B&G": 381,
17
- "BEP Marine": 295,
18
- "Bavaria Yacts": 637,
19
- "Beede Instruments": 185,
20
- "Beyond Measure": 396,
21
- "Blue Water Data": 148,
22
- "Blue Water Desalination": 811,
23
- "Broyda Industries": 795,
24
- "Böning Automationstechnologie GmbH & Co. KG": 341,
25
- "CPAC Systems AB": 165,
26
- "Camano Light": 384,
27
- "Canadian Automotive": 796,
28
- "Capi 2": 394,
29
- "Carling Technologies Inc. (Moritz Aerospace)": 176,
30
- "Chetco Digitial Instruments": 481,
31
- "Clarion US": 773,
32
- "Coelmo SRL Italy": 286,
33
- "ComNav": 404,
34
- "Comar Systems Limited": 438,
35
- "Cummins": 440,
36
- "DNA Group": 211,
37
- "DaeMyung": 743,
38
- "Dief": 329,
39
- "Digital Switching Systems": 211,
40
- "Digital Yacht": 437,
41
- "DisenosY Technolgia": 201,
42
- "Diverse Yacht Services": 641,
43
- "EMMI NETWORK S.L.": 224,
44
- "Egersund Marine Electronics AS": 426,
45
- "Electronic Design": 373,
46
- "Empir Bus": 304,
47
- "Eride": 243,
48
- "Evinrude/BRP": 163,
49
- "FLIR": 815,
50
- "FW Murphy/Enovation Controls": 78,
51
- "Faria Instruments": 1863,
52
- "Fell Marine": 844,
53
- "Fischer Panda DE": 785,
54
- "Fischer Panda Generators": 356,
55
- "Floscan Instrument Co. Inc.": 192,
56
- "Furuno": 1855,
57
- "Fusion Electronics": 419,
58
- "GME aka Standard Communications Pty LTD": 475,
59
- "Garmin": 229,
60
- "GeoNav": 385,
61
- "Gill Sensors": 803,
62
- "Glendinning": 378,
63
- "Groco": 272,
64
- "HMI Systems": 776,
65
- "Hamilton Jet": 283,
66
- "Hemisphere GPS Inc": 88,
67
- "Honda Motor Company LTD": 257,
68
- "Humminbird Marine Electronics": 467,
69
- "ICOM": 315,
70
- "Intellian": 606,
71
- "JL Audio": 740,
72
- "Japan Radio Co": 1853,
73
- "Johnson Outdoors Marine Electronics Inc Geonav": 385,
74
- "KUS Manufacturer": 644,
75
- "KVH": 579,
76
- "Kohler Power Systems": 85,
77
- "Korean Maritime University": 345,
78
- "Kvasar AB": 1859,
79
- "Lcj Capteurs": 499,
80
- "Litton": 1858,
81
- "Livorsi Marine": 400,
82
- "Lowarnce": 140,
83
- "Lowrance": 140,
84
- "Lumishore": 798,
85
- "LxNav": 739,
86
- "MBW Technologies (formerly MAS)": 307,
87
- "MMP": 1860,
88
- "Maretron": 137,
89
- "Marinecraft (South Korea)": 571,
90
- "Marinesoft Co. LTD": 510,
91
- "Mastervolt": 355,
92
- "McMurdo Group aka Orolia LTD": 573,
93
- "Mercury Marine": 144,
94
- "Moritz Aerospace": 176,
95
- "Mystic Valley Communications": 198,
96
- "National Instruments Korea": 529,
97
- "Nautibus Electronic GmbH": 147,
98
- "Navico": 275,
99
- "Navionics": 1852,
100
- "Naviop S.R.L.": 503,
101
- "NoLand Engineering": 517,
102
- "Nobletec": 193,
103
- "Northstar Technologies": 1854,
104
- "Nothern Lights": 374,
105
- "NovAtel": 305,
106
- "Ocean Sat BV": 478,
107
- "Ocean Signal": 777,
108
- "Oceanvolt": 847,
109
- "Offshore Systems (UK) Ltd.": 161,
110
- "Onwa Marine": 532,
111
- "Parker Hannnifin aka Village Marine Tech": 451,
112
- "Poly Planar": 781,
113
- "Prospec": 862,
114
- "Qwerty": 328,
115
- "REAP Systems": 734,
116
- "Raymarine": 1851,
117
- "Rockford Corp": 688,
118
- "Rolls Royce Marine": 370,
119
- "Rose Point Navigation Systems": 384,
120
- "SAN GIORGIO S.E.I.N": 460,
121
- "SI-TEX Marine Electronics": 470,
122
- "Sailormade Marine Telmetry/Tetra Technology LTD": 235,
123
- "SamwonIT": 612,
124
- "San Jose Technology": 580,
125
- "Sea Cross Marine AB": 471,
126
- "Sea Recovery": 285,
127
- "Seekeeper": 778,
128
- "Shenzhen Jiuzhou Himunication": 658,
129
- "Ship Module aka Customware": 595,
130
- "Simrad": 1857,
131
- "Sleipner Motor AS": 306,
132
- "Standard Horizon": 421,
133
- "Still Water Designs and Audto": 799,
134
- "Suzuki Motor Corporation": 586,
135
- "TeamSurv": 838,
136
- "Teleflex Marine (SeaStar Solutions)": 1850,
137
- "Thrane and Thrane": 351,
138
- "Tides Marine": 797,
139
- "TJC Micro": 963,
140
- "Tohatsu Co, JP": 431,
141
- "Transas USA": 518,
142
- "Trimble": 1856,
143
- "True Heading AB": 422,
144
- "Twin Disc": 80,
145
- "US Coast Guard": 591,
146
- "Undheim Systems": 824,
147
- "VDO (aka Continental-Corporation)": 443,
148
- "Vector Cantech": 1861,
149
- "Veethree Electronics & Marine": 466,
150
- "Vesper Marine Ltd": 504,
151
- "Victron Energy": 358,
152
- "Volvo Penta": 174,
153
- "Watcheye": 493,
154
- "Wema U.S.A dba KUS": 644,
155
- "Westerbeke": 154,
156
- "Woosung": 744,
157
- "Xantrex Technology Inc.": 168,
158
- "Xintex/Atena": 215,
159
- "Yacht Control": 583,
160
- "Yacht Devices": 717,
161
- "Yacht Monitoring Solutions": 233,
162
- "Yamaha Marine": 1862,
163
- "Yanmar Marine": 172,
164
- "ZF Marine Electronics": 228,
165
- "em-trak Marine Electronics": 427
166
- }