API Reference

ShdlcSerialFrameBuilder

ShdlcPort

class sensirion_shdlc_driver.port.ShdlcPort[source]

Common interface for all communication ports for transceiving SHDLC frames.

Concrete implementations may use the serial port or another interface for transceiving SHDLC frames. All methods must be implemented thread-safe, i.e. allowing them to be called from multiple threads at the same time.

class sensirion_shdlc_driver.port.ShdlcSerialPort(port, baudrate, additional_response_time=0.1, do_open=True)[source]

SHDLC transceiver for the serial port (e.g. UART/RS232/RS485).

This class implements the ShdlcPort interface for the serial port.

Note

This class can be used in a “with”-statement, and it’s recommended to do so as it automatically closes the port after using it.

class sensirion_shdlc_driver.port.ShdlcTcpPort(ip, port, socket_timeout=5.0, do_open=True)[source]

SHDLC transceiver for a TCP/IP port in client connection mode.

This class implements the ShdlcPort interface for a client connection on a TCP/IP port.

Note

This class can be used in a “with”-statement, and it’s recommended to do so as it automatically closes the port after using it.

ShdlcConnection

class sensirion_shdlc_driver.connection.ShdlcConnection(port)[source]

This class represents the connection to an SHDLC bus. So you need to instantiate one object per bus, no matter how many devices are connected to that bus system.

The basic functionality of the class is to send SHDLC frames to devices and receive their response. Handling of communication errors (e.g. timeout or checksum errors) and device errors is done in this class.

ShdlcDevice

class sensirion_shdlc_driver.device_base.ShdlcDeviceBase(connection, slave_address)[source]

Base class for all SHDLC devices, providing only the basic functionality without implementing any SHDLC commands. The main purpose of this class is to allow derived classes to register their device-specific errors and to allow executing SHDLC commands.

class sensirion_shdlc_driver.device.ShdlcDevice(connection, slave_address)[source]

Generic SHDLC device, providing only common SHDLC commands. This class is intended only to communicate with devices which do not provide a corresponding device driver (yet). With this class you can for example read the serial number of a device even if no device specific driver exists. But if there exists a device specific driver, you should always use it instead of this driver.

This is a low-level driver which just provides all SHDLC commands as Python methods. Typically, calling a method sends one SHDLC request to the device and interprets its response. There is no higher level functionality available, please look for other drivers if you need a higher level interface.

There is no (or very few) caching functionality in this driver. For example if you call get_serial_number() 100 times, it will send the command 100 times over the SHDLC interface to the device. This makes the driver (nearly) stateless.

ShdlcFirmwareImage

ShdlcFirmwareUpdate

ShdlcCommand

class sensirion_shdlc_driver.command.ShdlcCommand(id, data, max_response_time, min_response_length=0, max_response_length=255, post_processing_time=0.0)[source]

Base class for all SHDLC commands.

Types

class sensirion_shdlc_driver.types.FirmwareVersion(major, minor, debug)[source]

Class representing the firmware version of an SHDLC device.

class sensirion_shdlc_driver.types.HardwareVersion(major, minor)[source]

Class representing the hardware version of an SHDLC device.

class sensirion_shdlc_driver.types.ProtocolVersion(major, minor)[source]

Class representing the SHDLC protocol version of an SHDLC device.

class sensirion_shdlc_driver.types.Version(firmware, hardware, protocol)[source]

Class representing all version numbers of an SHDLC device. This is used for the “Get Version” command.

Exceptions

digraph inheritance42b56db99d { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "sensirion_shdlc_driver.errors.ShdlcAccessRightError" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="SHDLC device error for wrong access right."]; "sensirion_shdlc_driver.errors.ShdlcDeviceError" -> "sensirion_shdlc_driver.errors.ShdlcAccessRightError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "sensirion_shdlc_driver.errors.ShdlcChecksumError" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="SHDLC device error for wrong checksum."]; "sensirion_shdlc_driver.errors.ShdlcDeviceError" -> "sensirion_shdlc_driver.errors.ShdlcChecksumError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "sensirion_shdlc_driver.errors.ShdlcCommandDataSizeError" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="SHDLC device error for wrong data size."]; "sensirion_shdlc_driver.errors.ShdlcDeviceError" -> "sensirion_shdlc_driver.errors.ShdlcCommandDataSizeError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "sensirion_shdlc_driver.errors.ShdlcCommandParameterError" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="SHDLC device error for illegal command parameter."]; "sensirion_shdlc_driver.errors.ShdlcDeviceError" -> "sensirion_shdlc_driver.errors.ShdlcCommandParameterError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "sensirion_shdlc_driver.errors.ShdlcDeviceError" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="SHDLC device error (communication was successful, but slave failed to"]; "sensirion_shdlc_driver.errors.ShdlcError" -> "sensirion_shdlc_driver.errors.ShdlcDeviceError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "sensirion_shdlc_driver.errors.ShdlcError" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Base class for all SHDLC related exceptions."]; "sensirion_shdlc_driver.errors.ShdlcFirmwareImageIncompatibilityError" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="SHDLC firmware image incompatibility error."]; "sensirion_shdlc_driver.errors.ShdlcError" -> "sensirion_shdlc_driver.errors.ShdlcFirmwareImageIncompatibilityError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "sensirion_shdlc_driver.errors.ShdlcFirmwareImageSignatureError" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="SHDLC firmware image signature error."]; "sensirion_shdlc_driver.errors.ShdlcError" -> "sensirion_shdlc_driver.errors.ShdlcFirmwareImageSignatureError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "sensirion_shdlc_driver.errors.ShdlcFirmwareUpdateError" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="SHDLC device error for firmware update failure."]; "sensirion_shdlc_driver.errors.ShdlcDeviceError" -> "sensirion_shdlc_driver.errors.ShdlcFirmwareUpdateError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "sensirion_shdlc_driver.errors.ShdlcResponseError" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="SHDLC response error (slave response contains invalid data)"]; "sensirion_shdlc_driver.errors.ShdlcError" -> "sensirion_shdlc_driver.errors.ShdlcResponseError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "sensirion_shdlc_driver.errors.ShdlcTimeoutError" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="SHDLC timeout exception (device did not respond to command)."]; "sensirion_shdlc_driver.errors.ShdlcError" -> "sensirion_shdlc_driver.errors.ShdlcTimeoutError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "sensirion_shdlc_driver.errors.ShdlcUnknownCommandError" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="SHDLC device error for unknown command."]; "sensirion_shdlc_driver.errors.ShdlcDeviceError" -> "sensirion_shdlc_driver.errors.ShdlcUnknownCommandError" [arrowsize=0.5,style="setlinewidth(0.5)"]; }