Class ShdlcProtocol
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
Datasheet can be found at https://sensirion.com/media/documents/8600FF88/616542B5/Sensirion_PM_Sensors_Datasheet_SPS30.pdf Information about SHDLC can be found at https://sensirion.github.io/python-shdlc-driver/shdlc.html.
Constructors
ShdlcProtocol(SerialPort, int)
Initializes a new instance of the ShdlcProtocol class.
public ShdlcProtocol(SerialPort serialPort, int timeoutInMillis = 10000)
Parameters
serialPortSerialPortThe serial port to be used.
timeoutInMillisintTimeout 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
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
devaddrbyteAddress of the device.
commandbyteCommand to execute.
databyte[]Data to pass to the command.
responseTimeintExpected (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.