@canboat/canboatjs 2.5.4 → 2.5.6

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/README.md CHANGED
@@ -8,8 +8,7 @@ Canboatjs is a port of the canboat project (https://github.com/canboat/canboat)
8
8
 
9
9
  # Contributors
10
10
 
11
- Canboajs js is built on the backs of a few people whithout whom it would not be possible.
12
-
11
+ - Scott Bender <scott@scottbender.net>
13
12
  - Kees Verruijt <kees@verruijt.net>
14
13
  - Jouni Hartikainen <jouni.hartikainen@iki.fi>
15
14
  - Teppo Kurki <teppo.kurki@iki.fi>
@@ -55,7 +54,7 @@ Example: `candump can0 | candumpanalyzerjs`
55
54
 
56
55
  Read directly from a socketcan device without the need to install can-utils
57
56
 
58
- Example: candumpjs can0
57
+ Example: `candumpjs can0`
59
58
 
60
59
  ## ydvr-file
61
60
 
package/lib/canbus.js CHANGED
@@ -54,14 +54,16 @@ function CanbusStream (options) {
54
54
  this.options = options
55
55
  this.start()
56
56
 
57
+ console.trace()
58
+ console.log(options.app.ssetProviderStatus)
57
59
  this.setProviderStatus = options.app && options.app.setProviderStatus
58
60
  ? (msg) => {
59
- options.app.setPluginStatus(options.providerId, msg)
61
+ options.app.setProviderStatus(options.providerId, msg)
60
62
  }
61
63
  : () => {}
62
64
  this.setProviderError = options.app && options.app.setProviderError
63
65
  ? (msg) => {
64
- options.app.setPluginError(options.providerId, msg)
66
+ options.app.setProviderError(options.providerId, msg)
65
67
  }
66
68
  : () => {}
67
69
 
package/lib/fromPgn.js CHANGED
@@ -611,6 +611,7 @@ function readField(options, runPostProcessor, pgn, field, bs, fields) {
611
611
  }
612
612
  if ( options.checkForInvalidFields !== false && max !== 'undefined' &&
613
613
  field.FieldType !== 'LOOKUP' &&
614
+ field.FieldType !== 'FIELDTYPE_LOOKUP' &&
614
615
  field.BitLength > 1 &&
615
616
  max - value <= 0 ) {
616
617
  //console.log(`Bad field ${field.Name} ${max - value}`)
@@ -633,7 +634,8 @@ function readField(options, runPostProcessor, pgn, field, bs, fields) {
633
634
  value = Number.parseFloat(value.toFixed(precision))
634
635
  }
635
636
 
636
- if (field.FieldType === 'LOOKUP' &&
637
+ if ((field.FieldType === 'LOOKUP' ||
638
+ field.FieldType === 'FIELDTYPE_LOOKUP') &&
637
639
  runPostProcessor &&
638
640
  (_.isUndefined(options.resolveEnums) ||
639
641
  options.resolveEnums)) {
package/lib/stringMsg.js CHANGED
@@ -112,10 +112,26 @@ exports.encodeYDRAW = ({ data, ...canIdInfo }) => {
112
112
  return pgns.map(buffer => canId + ' ' + byteString(buffer, ' '))
113
113
  }
114
114
 
115
+ const get0183Sentence = (msg) => {
116
+ let sentence = msg
117
+ if (sentence.charAt(0) === '\\') {
118
+ split = sentence.split('\\')
119
+ if ( split.length < 3 ) {
120
+ return false
121
+ }
122
+ sentence = split[2]
123
+ }
124
+ return sentence
125
+ }
126
+
115
127
  // $PCDIN,01F119,00000000,0F,2AAF00D1067414FF*59
116
- exports.isPCDIN = startsWith('$PCDIN,')
128
+ exports.isPCDIN = (msg) => {
129
+ const sentence = get0183Sentence(msg)
130
+ return sentence.startsWith('$PCDIN,')
131
+ }
117
132
  exports.parsePCDIN = (input) => {
118
- const [ prefix, pgn, timeHex, src, data ] = input.split(',')
133
+ const sentence = get0183Sentence(input)
134
+ const [ prefix, pgn, timeHex, src, data ] = sentence.split(',')
119
135
  let timer = parseInt(timeHex, 32)
120
136
 
121
137
  timer = timer / 1024
@@ -136,9 +152,13 @@ exports.encodePCDIN = ({ prefix = '$PCDIN', pgn, data, dst = 255}) => {
136
152
  }
137
153
 
138
154
  // $MXPGN,01F801,2801,C1308AC40C5DE343*19
139
- exports.isMXPGN = startsWith('$MXPGN,')
155
+ exports.isMXPGN = (msg) => {
156
+ const sentence = get0183Sentence(msg)
157
+ return sentence.startsWith('$MXPGN,')
158
+ }
140
159
  exports.parseMXPGN = (input) => {
141
- const [ prefix, pgn, attr_word, data ] = input.split(',')
160
+ const sentence = get0183Sentence(input)
161
+ const [ prefix, pgn, attr_word, data ] = sentence.split(',')
142
162
 
143
163
  const send_prio_len = (parseInt(attr_word.substr(0,2), 16).toString(2)).padStart(8, '0');
144
164
  const addr = (parseInt(attr_word.substr(2,2), 16));
package/lib/toPgn.js CHANGED
@@ -190,7 +190,8 @@ function writeField(bs, pgn_number, field, data, value, fields, bitLength) {
190
190
  }
191
191
  } else if ( type && fieldTypeMappers[type] ) {
192
192
  value = fieldTypeMappers[type](field, value)
193
- } else if (field.FieldType === 'LOOKUP' && _.isString(value)) {
193
+ } else if ((field.FieldType === 'LOOKUP' ||
194
+ field.FieldType === 'FIELDTYPE_LOOKUP') && _.isString(value)) {
194
195
  if (!(field.Id === "timeStamp" && value < 60)) {
195
196
  value = lookup(field, value)
196
197
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canboat/canboatjs",
3
- "version": "2.5.4",
3
+ "version": "2.5.6",
4
4
  "description": "Native javascript version of canboat",
5
5
  "main": "index.js",
6
6
  "scripts": {