Parser
Direct Subclass:
Parser creation helper class. Any subclasses should reimplement the parse method, calling super.parse in the beginning. You have useful methods for reading regular C datatypes from the buffer: readInt, readFloat, readChar... To use it in node-serialport or the serial wrapper just pass in ::Parser.parse Keep in mind not initialize this class as is. RE-IMPLEMENT Parser.parse!
Constructor Summary
Public Constructor | ||
public |
constructor(endianess: String) |
Member Summary
Public Members | ||
public |
Raw packet byte endianess (Little Endian (LE) for the Arduino). |
|
public |
Parsed output container. |
Protected Members | ||
protected |
Current position in the packet being parsed. |
|
protected |
Current packet being parsed. |
Method Summary
Public Methods | ||
public |
Parses a packet. |
|
public |
readBoolean(key: String, converter: Function): Boolean Reads a boolean. |
|
public |
Reads a char. |
|
public |
Reads a 32-bit float. |
|
public |
Reads a signed integer of 1-6 bytes. |
|
public |
Reads an unsigned integer of 1-6 bytes. |
|
public |
The value setter called by read* helper functions. |
Public Constructors
Public Members
public endianess: String source
Raw packet byte endianess (Little Endian (LE) for the Arduino). Acceptable values: LE, BE.
Protected Members
Public Methods
public parse(rawPacket: Buffer): Object source
Parses a packet. Default implementation resets state and calculates and extracts the CRC32 checksum before parsing the new packet. That's why, if you want any parsing at all to be performed, YOU MUST RE-IMPLEMENT THIS METHOD. Preferrably calling this implementation before any parsing(but after any decoding wink wink quasi-binary decoder).
Params:
Name | Type | Attribute | Description |
rawPacket | Buffer | The packet to be parsed. |
public readInt(key: String, size: Number, converter: Function): Number source
Reads a signed integer of 1-6 bytes.
public readUInt(key: String, size: Number, converter: Function): Number source
Reads an unsigned integer of 1-6 bytes.