machine-protocol

0.0.14 • Public • Published

Introduction

This is a simple library for using a simple protocol to communicate with a custom board.

Every message has this format:

VERSION (1byte)

TYPE (1byte)

ID (8byte)

CMD (1byte)

LEN (8byte)

DIN/OUT 1

DIN/OUT 1 (1byte)

DIN/OUT 2

DIN/OUT 2 (1byte)

...

DIN/OUT n

DIN/OUT n (1byte)

VERSION is the protocol version

TYPE is the type of board (input digital board etc...)

ID is the identify of the board.

CMD is the command issued to the board.

LEN is the length of the reamining next bit.

DIN/OUT [1,2..,n] is the reference of the pin.

DIN/OUT 1,2,..,n is the value of the sensor/actuator on pin 1,2..n.

Function

var messageEncoded=encodeMessage(version, type,id,cmd,values);

this function encode the message in a binary format using the parameters.

var messageDecoded=decodeMessage(message);

this function decode the message and returning ad Object.

Output example: { type: 1, id: 1, cmd: 2, values: [ [ 2, 1 ] ] }

License

WTFPL

/machine-protocol/

    Package Sidebar

    Install

    npm i machine-protocol

    Weekly Downloads

    13

    Version

    0.0.14

    License

    none

    Last publish

    Collaborators

    • chiarishow