@canboat/canboatjs 1.28.0 → 1.28.1
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/fromPgn.js +18 -4
- package/package.json +1 -1
package/lib/fromPgn.js
CHANGED
|
@@ -40,6 +40,7 @@ const maxInt64 = new Int64LE(0x7fffffff, 0xffffffff)
|
|
|
40
40
|
|
|
41
41
|
const FORMAT_PLAIN = 0
|
|
42
42
|
const FORMAT_COALESCED = 1
|
|
43
|
+
const RES_BINARY = 'Binary data'
|
|
43
44
|
|
|
44
45
|
const FASTPACKET_INDEX = 0
|
|
45
46
|
const FASTPACKET_SIZE = 1
|
|
@@ -568,7 +569,7 @@ function readField(options, runPostProcessor, pgn, field, bs) {
|
|
|
568
569
|
if ( reader ) {
|
|
569
570
|
value = reader(pgn, field, bs)
|
|
570
571
|
} else {
|
|
571
|
-
if ( bs.bitsLeft < field.BitLength ) {
|
|
572
|
+
if ( field.Type !== RES_BINARY && bs.bitsLeft < field.BitLength ) {
|
|
572
573
|
//no more data
|
|
573
574
|
bs.readBits(bs.bitsLeft, false)
|
|
574
575
|
return
|
|
@@ -697,12 +698,25 @@ function readValue(options, pgn, field, bs, bitLength) {
|
|
|
697
698
|
} else {
|
|
698
699
|
value = x === 0xffffffff && y == 0xffffffff ? null : new Uint64LE(y,x)
|
|
699
700
|
}
|
|
700
|
-
} else {
|
|
701
|
+
} else if ( bitLength <= 64 ) {
|
|
701
702
|
value = bs.readBits(bitLength, field.Signed)
|
|
702
703
|
if ( bitLength > 1 && isMax(bitLength, value, field.Signed) ) {
|
|
703
704
|
value = null
|
|
704
705
|
}
|
|
705
|
-
|
|
706
|
+
} else {
|
|
707
|
+
if ( bs.bitsLeft < field.BitLength ) {
|
|
708
|
+
bitLength = bs.bitsLeft
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
value = bs.readArrayBuffer(bitLength/8, field.Signed)
|
|
712
|
+
value = new Uint32Array(value)
|
|
713
|
+
.reduce(function(acc, i) {
|
|
714
|
+
acc.push(i.toString(16));
|
|
715
|
+
return acc;
|
|
716
|
+
}, [])
|
|
717
|
+
.map(x => (x.length === 1 ? "0" + x : x))
|
|
718
|
+
.join(" ")
|
|
719
|
+
return value
|
|
706
720
|
}
|
|
707
721
|
|
|
708
722
|
if ( value != null && typeof value !== 'undefined' && typeof value !== 'number' ) {
|
|
@@ -911,7 +925,7 @@ fieldTypePostProcessors['Pressure'] = (field, value) => {
|
|
|
911
925
|
return value
|
|
912
926
|
}
|
|
913
927
|
|
|
914
|
-
fieldTypePostProcessors[
|
|
928
|
+
fieldTypePostProcessors[RES_BINARY] = (field, value) => {
|
|
915
929
|
return value.toString()
|
|
916
930
|
}
|
|
917
931
|
|