Table of Contents

Class ShdlcProtocol

Namespace
Iot.Device.Sps30.Shdlc
Assembly
Iot.Device.Sps30.dll

Minimal implementation of the SHDLC protocol used by Sensirion. This implementation is based upon the information available in the SPS30 particulate matter sensor datasheet.

public class ShdlcProtocol
Inheritance
ShdlcProtocol

Remarks

Constructors

ShdlcProtocol(SerialPort, int)

Initializes a new instance of the ShdlcProtocol class.

public ShdlcProtocol(SerialPort serialPort, int timeoutInMillis = 10000)

Parameters

serialPort SerialPort

The serial port to be used.

timeoutInMillis int

Timeout to be used on the serial port and as communication timeout for commands.

Properties

Serial

Gets the SerialPort which is exposed as public property, but should only be used in very specific circumstances. One example is the Sensirion SPS30, for which a raw "0xFF" must be sent to wake the device from its sleep.

public SerialPort Serial { get; }

Property Value

SerialPort

Methods

Execute(byte, byte, byte[], int)

Execute a command on the SHDLC device. Its documentation should describe the address, commands and what data to send/receive.

public byte[] Execute(byte devaddr, byte command, byte[] data, int responseTime = 100)

Parameters

devaddr byte

Address of the device.

command byte

Command to execute.

data byte[]

Data to pass to the command.

responseTime int

Expected (maximum) response time, used to idle the CPU for a bit instead of polling the serial port.

Returns

byte[]

The reply of this command. This may be an empty array if this command has no reply.

Exceptions

ApplicationException

When the frame could not be verified, a timeout occurred or the device indicates a fault status.