Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hiqnet

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hiqnet

Parsing library for HiQnet communication protocol

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
increased by125%
Maintainers
1
Weekly downloads
 
Created
Source

platform npm package version license Npm package weekly downloads Npm package monthly downloads Npm package total downloads github-issues

HiQnet

Parsing library for HiQnet communication protocol

Installation

npm install hiqnet

Version History

VersionRelease Notes
0.0.1Initial beta release

Usage

Sending Commands

Before sending a command to a Blu device, use hiqnet.encapsulatCommand(buf: Buffer). This function will byte substitute, add checksum, and prepend/append STX/ETX respectively.

const hiqnet = require('hiqnet');

let cmd_id = Buffer.from([0x88]);
let address = Buffer.from([0x00, 0x09, 0x03, 0x00, 0x01, 0x00, 0x4e, 0x20]);
let data = hiqnet.encDiscrete(10);

let cmd = hiqnet.encapsulateCommand(Buffer.concat([cmd_id, address, data]));

// send encapsulated command to Blu device via TCP or Serial.

There are several functions to facilitate encoding data types:

  • encDiscrete(v: number)
  • encPercent(v: number)
  • encGain(v: number)
  • encScalarLinear(v: number)
  • encDelay(v: number)
  • encFrequencyOrSpeed(v: number)

Parsing Responses

To parse incomming messages, use hiqnet.decapsulateCommand(buf: Buffer). This function will strip STX/ETX, verify and remove checksum, and byte unsubstitute.

const hiqnet = require('hiqnet');

let cmd = hiqnet.decapsulateCommand(rx$);

let cmd_id = hiqnet.getCommandIdBuffer(cmd);
let address = hiqnet.getAddressBuffer(cmd);
let data = hiqnet.getDateBuffer(cmd);

// decode data buffer
let dataValue = hiqnet.decDiscrete(data);

There are several functions to facilitate decoding data types:

  • decDiscrete(b: Buffer)
  • decPercent(b: Buffer)
  • decGain(b: Buffer)
  • decScalarLinear(b: Buffer)
  • decDelay(b: Buffer)
  • decFrequencyOrSpeed(b: Buffer)

Resources

Address Property

The address property is a buffer of exactly 8 bytes. it is comprised of:

  • Node Address (2 bytes)
  • Virtual Device (1 byte)
  • Object ID (3 bytes)
  • Parameter ID (2 bytes)

The following bytes have special meanings. The node suite will automatically handle replacement when commands are encapsulated and decapsulated. Be mindfull on nodes requiring an address property that the non replaced character is needed in decimal format.

TYPEHEXHEX replacementDECDEC replacement
STX0x020x1B, 0x82227, 130
ETX0x030x1B, 0x83327, 131
ACK0x060x1B, 0x86627, 134
NAK0x150x1B, 0x952127, 149
Escape0x1B0x1B, 0x9B2727, 155

Feature Requests / Bug Reporting

Please report any bugs or issues to the repository here.

Keywords

FAQs

Package last updated on 21 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc