API¶
specMech¶
- class yao.mech_controller.MechController(address, port=23, log=None, log_path=None)[source]¶
Bases:
objectController for the spectrograph mechanics.
The
MechControllerhandles the connection to the spectrograph mechanics microcontroller. A description of the communication protocol is available here.- Parameters:
- async pneumatic_move(mechanism, open=True, command=None)[source]¶
Opens/closes a pneumatic mechanism.
- async read_data()[source]¶
Awaits responses from specMech until the EOM character ‘>’ is seen.
- Returns:
mech_reply – A
SpecMechReplyobject with the reply received.
- async send_data(command, timeout=None)[source]¶
Sends the given string to the specMech and then awaits a response.
Currently when a command is sent the controller is locked and any new command is blocked until a reply for the currenly running command arrives or a timeout happens.
- Parameters:
- Returns:
replies – A tuple in which the first element is bytes array with the raw reply, and successive items are tuples with the data associated with each reply. If a timeout occurred before
- class yao.mech_controller.SpecMechReply(raw)[source]¶
Bases:
objectA valid response to a command to the specMech.
- Parameters:
raw (bytes)
- static calculate_checksum(message)[source]¶
Computes the checksum field for the NMEA protocol.
The checksum is simple, just an XOR of all the bytes between the
$and the*(not including the delimiters themselves), and written in hexadecimal.- Parameters:
message (bytes)
- yao.mech_controller.check_reply(reply)[source]¶
Checks a specMech reply.
- Parameters:
reply (SpecMechReply)