Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
dbc,
base,
num,
canStartTime,
prevMsgEntries,
maxByteStateChangeCount
) {
var messages = {};
const { times, sources, addresses, datas } = await CanApi.fetchCanPart(
base,
num
);
for (var i = 0; i < times.length; i++) {
var t = times[i];
var src = Int64LE(sources, i * 8).toString(10);
var address = Int64LE(addresses, i * 8);
var addressHexStr = address.toString(16);
var id = src + ":" + addressHexStr;
var addressNum = address.toNumber();
var data = datas.slice(i * 8, (i + 1) * 8);
if (messages[id] === undefined)
messages[id] = DbcUtils.createMessageSpec(
dbc,
address.toNumber(),
id,
src
);
const prevMsgEntry =
messages[id].entries.length > 0
readDoubleAndInt64: function () {
var buf = this.readRawLittleEndian64();
var doubleVal = buf.readDoubleLE(0);
var int64LE = new int64buffer.Int64LE(buf);
return { doubleVal: doubleVal, int64LE: int64LE };
},
readInt64: function () {
var buf = this.readRawLittleEndian64();
//https://www.npmjs.com/package/int64-buffer
var int64LE = new int64buffer.Int64LE(buf);
return int64LE;
},
this.compressor = dataView.getUint16(position, true);
position += 2;
this.coder = dataView.getUint16(position, true);
position +=2;
this.version = {};
this.version.major = dataView.getUint8(position);
position += 1;
this.version.minor = dataView.getUint8(position);
position += 1;
this.version.revision = dataView.getUint16(position, true);
position += 2;
this.options = dataView.getUint32(position, true);
position += 4;
this.chunk_size = dataView.getUint32(position, true);
position += 4;
this.number_of_special_evlrs = new Int64LE(buffer.slice(position, position+8));
position += 8;
this.offset_to_special_evlrs = new Int64LE(buffer.slice(position, position+8));
position += 8;
this.num_items = dataView.getUint16(position, true);
position += 2;
this.items = [];
for (let i = 0; i < this.num_items; i++ ) {
let item = {};
item.type = dataView.getUint16(dataView, position);
position +=2;
item.size = dataView.getUint16(dataView, position);
position +=2;
item.version = dataView.getUint16(dataView, position);
position +=2;
this.items[i] = item;
}
doubleToRawLongBits: function (number) {
var buf = new Buffer(8);
buf.fill(0);
buf.writeDoubleLE(number, 0);
var int64 = new int64buffer.Int64LE(buf);
return int64;
}
},
this.coder = dataView.getUint16(position, true);
position +=2;
this.version = {};
this.version.major = dataView.getUint8(position);
position += 1;
this.version.minor = dataView.getUint8(position);
position += 1;
this.version.revision = dataView.getUint16(position, true);
position += 2;
this.options = dataView.getUint32(position, true);
position += 4;
this.chunk_size = dataView.getUint32(position, true);
position += 4;
this.number_of_special_evlrs = new Int64LE(buffer.slice(position, position+8));
position += 8;
this.offset_to_special_evlrs = new Int64LE(buffer.slice(position, position+8));
position += 8;
this.num_items = dataView.getUint16(position, true);
position += 2;
this.items = [];
for (let i = 0; i < this.num_items; i++ ) {
let item = {};
item.type = dataView.getUint16(dataView, position);
position +=2;
item.size = dataView.getUint16(dataView, position);
position +=2;
item.version = dataView.getUint16(dataView, position);
position +=2;
this.items[i] = item;
}
}
base,
num,
canStartTime,
prevMsgEntries,
maxByteStateChangeCount
) {
var messages = {};
const { times, sources, addresses, datas } = await CanApi.fetchCanPart(
base,
num
);
for (var i = 0; i < times.length; i++) {
var t = times[i];
var src = Int64LE(sources, i * 8).toString(10);
var address = Int64LE(addresses, i * 8);
var addressHexStr = address.toString(16);
var id = src + ":" + addressHexStr;
var addressNum = address.toNumber();
var data = datas.slice(i * 8, (i + 1) * 8);
if (messages[id] === undefined)
messages[id] = DbcUtils.createMessageSpec(
dbc,
address.toNumber(),
id,
src
);
const prevMsgEntry =
messages[id].entries.length > 0
? messages[id].entries[messages[id].entries.length - 1]
public readInt64(bigEndian: boolean = false): Int64LE | Int64BE {
if (this.canReadBytes(8) === false) {
throw new Error('Data buffer is too small')
}
const res: Int64LE | Int64BE = bigEndian ?
new Int64BE(this.packetData, this.curOffset) :
new Int64LE(this.packetData, this.curOffset)
this.curOffset += 8
return res
}