trs_interface.protocol package¶
The protocol
package deals with the encoding and decoding of messages passed between the
host computer and the device, but does not deal with any of the aspects of the transport
layer (for example, the USB serial connection itself).
The majority of this module contains constant definitions autogenerated from the firmware’s
TRSInterface.h
c header file.
These definitions can aid in writing more readable code, for example:
from trs_interface import TRSInterface
from trs_interface.protocol import *
trsi = TRSInterface()
trsi.camera_trig_polarity = Polarity.HIGH
# ...
if msg.id == ID.GOT_UNKNOWN_MESSAGE:
raise RuntimeError("Device received an unknown message.")
- class trs_interface.protocol.Direction(value)[source]¶
Bases:
enum.IntEnum
Enumeration of quadrature counting direction.
- FORWARD = 0¶
- REVERSE = 1¶
- class trs_interface.protocol.ID(value)[source]¶
Bases:
enum.IntEnum
Enumeration of known message IDs.
- ARM = 8200¶
- GET_CAMERA_SYNC_DELAY = 4384¶
- GET_CAMERA_SYNC_DURATION = 4400¶
- GET_CAMERA_TRIG_POLARITY = 4176¶
- GET_CHOPPER_DIVIDER = 4608¶
- GET_CHOPPER_SYNCIN_POLARITY = 4112¶
- GET_CHOPPER_SYNCOUT_POLARITY = 4128¶
- GET_CHOPPER_SYNC_DELAY = 4352¶
- GET_CHOPPER_SYNC_DURATION = 4368¶
- GET_DELAY_TRIG_POLARITY = 4144¶
- GET_LASER_SYNC_PERIOD = 16640¶
- GET_LASER_SYNC_POLARITY = 4096¶
- GET_PING = 0¶
- GET_QUADRATURE_DIRECTION = 4208¶
- GET_QUADRATURE_POLARITY = 4192¶
- GET_QUADRATURE_VALUE = 4624¶
- GET_VERSION = 32¶
- GOT_CAMERA_SYNC_DELAY = 4385¶
- GOT_CAMERA_SYNC_DURATION = 4401¶
- GOT_CAMERA_TRIG_POLARITY = 4177¶
- GOT_CHOPPER_DIVIDER = 4609¶
- GOT_CHOPPER_SYNCIN_POLARITY = 4113¶
- GOT_CHOPPER_SYNCOUT_POLARITY = 4129¶
- GOT_CHOPPER_SYNC_DELAY = 4353¶
- GOT_CHOPPER_SYNC_DURATION = 4369¶
- GOT_DATA = 49153¶
- GOT_DELAY_TRIG_POLARITY = 4145¶
- GOT_LASER_SYNC_PERIOD = 16641¶
- GOT_LASER_SYNC_POLARITY = 4097¶
- GOT_PING = 1¶
- GOT_QUADRATURE_DIRECTION = 4209¶
- GOT_QUADRATURE_POLARITY = 4193¶
- GOT_QUADRATURE_VALUE = 4625¶
- GOT_UNKNOWN_MSG = 17¶
- GOT_VERSION = 32801¶
- SET_CAMERA_SYNC_DELAY = 4386¶
- SET_CAMERA_SYNC_DURATION = 4402¶
- SET_CAMERA_TRIG_POLARITY = 4178¶
- SET_CHOPPER_DIVIDER = 4610¶
- SET_CHOPPER_SYNCIN_POLARITY = 4114¶
- SET_CHOPPER_SYNCOUT_POLARITY = 4130¶
- SET_CHOPPER_SYNC_DELAY = 4354¶
- SET_CHOPPER_SYNC_DURATION = 4370¶
- SET_DELAY_TRIG_POLARITY = 4146¶
- SET_LASER_SYNC_POLARITY = 4098¶
- SET_QUADRATURE_DIRECTION = 4210¶
- SET_QUADRATURE_POLARITY = 4194¶
- SET_QUADRATURE_VALUE = 4626¶
- START = 8216¶
- STOP = 8217¶
- STORE_SETTINGS = 2050¶
- TRIGGER = 8196¶
- class trs_interface.protocol.Polarity(value)[source]¶
Bases:
enum.IntEnum
Enumeration of signal or edge polarities.
- FALLING = 2¶
- HIGH = 1¶
- LOW = 0¶
- RISING = 3¶
- trs_interface.protocol.HEADER_SIZE = 10¶
Size (in bytes) of a message header, or a basic (header only) message type.
- trs_interface.protocol.LONG_FORM = 32768¶
The most significant bit of a message ID indicates whether the message is a “long form” message, which contains additional “payload” data. This is a bit mask which can be used to test for long form messages by way of a logical AND operation.