0.0.2 • Published 6 years ago
can-dbc-decode v0.0.2
can-dbc-decode
Decode CAN DBC data
Install
npm install can-dbc-decodeUsage
const decode = require('can-dbc-decode')
const input = {
rawData: '46220000FFFFFFFF',
start: 0,
size: 32,
factor: 0.05,
offset: 0,
precision: 5,
endianness: 0
}
decode(input)
// => 438.7Concept
Assuming the rawData in HEX is 0x0000047900000033, grouped HEX data is 00 00 04 79 00 00 00 33
In Motorola(big endian) format, The bit map of this rawData is
If have below input:
start: 60,
size: 4,
factor: 1,
offset: 0,
precision: 5,
endianness: 1It will decode the data in red frame
Input params
rawData
String, the input Hex data without 0x, rawData should be no signed.
* required
start
Integer, the start bit position.
* required
size
Integer, the length of bits.
* required
factor
Number, factor of the returned data.
default: 1
offset
Number, offset of the returned data.
default: 0
precision
Interger, Max precesion of returned data.
default: undifined // no limitation
endianness
0 or 1, 0 - Intel(little endian) and 1 - Motorola(big endian).
default: 0 - Intel(little endian)
License
MIT License
Copyright (c) 2019 intecessor