# isobus-parser

> Isobus to JSON parser

Latest version **1.0.0** (published 2014-12-12) · Apache 2.0 license · 0 weekly downloads

## Install

```sh
npm install isobus-parser
pnpm add isobus-parser
yarn add isobus-parser
bun add isobus-parser
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2014-12-12 |
| First published | 2014-12-12 |
| Weekly downloads | 0 |
| License | Apache 2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Paul Krogmeier, Cyrus Bowman,Devin Rosado |
| Maintainers | d_rosado |

## Links

- npm: https://www.npmjs.com/package/isobus-parser
- Repository: https://github.com/OATS-Group/isobus-parser-js
- Issues: https://github.com/OATS-Group/isobus-parser-js/issues
- npm.io page: https://npm.io/package/isobus-parser

## Recent versions

- 1.0.0 (latest) — 2014-12-12

## README

isobus-parser-js
==============
JavaScript utility that parses Isoblue raw data 

Getting Started
---------------

### Installation ###
The library can be installed with `npm` using
```sh
$ npm install isobus-parser
```

### parse(data, smallbyte,bigbyte,mul,add) ###
Taking data array and extracts a message from data array according to input parameters: smallbyte, bigbyte, mul and add
Function makes no assumption about endianness of data.  Considers the first element of data to be less significant than the second *Function will fail if caller tries to retrieve too many bytes (js uses only 53 bits in numbers)*

#### Parameters ####
`data` {Arrray} of 8 bytes 

[`smallbyte`][] {Number} specify the region of bytes to parse; represents the lowest byte to use

`bigbyte` {Number} specify the region of bytes to parse; respresents the end byte 

respresents the range for the consecutive bytes that comprise the message

*i.e.: smallbyte=0, bigbyte=2 would parse the first 3 bytes in the data word*

* `mult` {Number} Represent factor to multipy the parsed byte sequence

`add` {Function} Represent factor to add to the parsed byte sequence

#### Usage Example ####
```javascript
var data = [0x01, 0x01, 0x01, 0x01, 0x0, 0x0, 0xFF, 0xFF];
function test_parse () {
  parse(data, 1, 3, 3, 2);

Output: 
 197381.0
```

### parseArray(input, config) ###
Parses raw input array from IsoBlue

#### Parameters ####
`input` {Array} of objects comprised of PGNS, a 8 byte data array, and a time stamp. *Requires a JSON configuration file* Ine the following format:
input=[
{pgn:XXXXX,
 data: [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0]
 timestamp=XX
},
{pgn:XXXXX,
 data:[0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0] 
 timstamp=XX
},
...
...
]

[`config`][] {File} Required file that contains extraction information for a given message in the following format:
config = {
  'parameter': {
    pgn: ##,
    low: ##, 
    high: ##,
    mul: ##,
    add: ##
  }
 ...
 ... 
}

#### Usage Example ####
```javascript
  config = {
  'enginespeed': {
    signed: false,
    pgn: 61444,
    low: 3, 
    high: 4,
    mul: 0.125,
    add: 0
  }
};

input=[
{pgn:61444,
 data: [0xFF, 0xFF, 0xFF, 0x95, 0x47, 0xFF, 0xFF, 0xFF],
 timestamp:.94
},
{pgn:61444,
 data: [0xFF, 0xFF, 0xFF, 0x01, 0x1C, 0xFF, 0xFF, 0xFF],
 timestamp:.94
},
{pgn:61444,
 data: [0xFF, 0xFF, 0xFF, 0x0E, 0x1C, 0xFF, 0xFF, 0xFF],
 timestamp:.94
},
{pgn:61444,
 data: [0xFF, 0xFF, 0xFF, 0xF8, 0x1B, 0xFF, 0xFF, 0xFF],
 timestamp:.94
}
];
parseArray(input,config);

Output:
{enginespeed=[{timestamp=0.94, measurement=2290.625}, {timestamp=0.94, measurement=896.125}, {timestamp=0.94, measurement=897.75}, {timestamp=0.94, measurement=895.0}]}
```
### getBytes(payload) ###
Parses a 16 character hex string into an array of 8 bytes, assuming the first charcter in the string is the least significant byte.

#### Parameters ####
`payload` {String} 16 character hex string (padded with 0 bytes if necessary)


#### Usage Example ####
```javascript
payload= 'FFFFFFFFFFFFFF22';
getBytes(payload);

Output:
[255.0, 255.0, 255.0, 255.0, 255.0, 255.0, 255.0, 34.0]

```
### getPgn(canString) ###
converts  Isobus formatted string hex value from speadsheet into decimal PGN number

#### Parameters ####
`canString` {String} Isobus formatted string hex value 

#### Usage Example ####
```javascript
canString= '0ff46x';
getPgn(canString);

Output:
65350.0
```
### h2d(h) ###
Converts hex string into decimal number

#### Parameters ####
`h` {String} hex string to be converted to decimal


#### Usage Example ####
```javascript
hval= "FFFF";
h2d(hval);

Output:
 65535.0
```

---
_Source: https://npm.io/package/isobus-parser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
