npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

isobus-parser

v1.0.0

Published

Isobus to JSON parser

Downloads

5

Readme

isobus-parser-js

JavaScript utility that parses Isoblue raw data

Getting Started

Installation

The library can be installed with npm using

$ 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

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

  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

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

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

hval= "FFFF";
h2d(hval);

Output:
 65535.0