chffr: support npy datatype that showed up in b3d5e3f72b5e6a76|2017-10-14--13-23-03

main
Andy Haden 2017-10-16 20:05:50 -07:00
parent 74841b81e7
commit f33a1504f1
3 changed files with 11 additions and 1 deletions

View File

@ -19,6 +19,7 @@
"hls.js": "^0.7.9",
"int64-buffer": "^0.1.9",
"js-cookie": "^2.1.4",
"left-pad": "^1.1.3",
"moment": "^2.18.1",
"prop-types": "^15.5.10",
"raven-js": "^3.16.0",

View File

@ -1,5 +1,6 @@
const UINT64 = require('cuint').UINT64
import Bitarray from '../bitarray';
import leftPad from 'left-pad';
require('core-js/fn/array/from');
require('core-js/fn/number/is-integer');
require('core-js/es6/map');
@ -510,7 +511,12 @@ export default class DBC {
}
getSignalValues(messageId, data) {
const buffer = Buffer.from(data);
let buffer = Buffer.from(data);
if (data.length % 8 !== 0) {
// pad data it's 64 bits long
const paddedDataHex = leftPad(buffer.toString('hex'), 16, '0');
buffer = Buffer.from(paddedDataHex);
}
const hexData = buffer.toString('hex');
const bufferSwapped = Buffer.from(buffer).swap64();

View File

@ -57,6 +57,9 @@ const NumpyLoader = (function NumpyLoader() {
} else if (info.descr === "<i8") {
// 8 byte int64s
data = new Uint8Array(buf, offsetBytes);
} else if (info.descr === "|s5") {
// 5 byte string
data = new Uint8Array(buf, offsetBytes);
} else if (info.descr === "|s8") {
// 8 byte strings
data = new Uint8Array(buf, offsetBytes);