Generic Serial Controller¶
This is a generic controller for Serial devices (like Arduino). It includes serial write and query methods. Higher level stuff could (should?) be done at Instrument level. Extra methods could however also be added to this controller, as long as they don’t break the existing functionality.
This controller is however intended to be agnostic of what code/firmware/sketch is running on the device. I suggest to keep it that way and put device specific functionality in a dedicated instrument. This also means Dummy mode needs to be implemented mostly at Instrument level.
Development note: I’ve added the experimental decorator _wait_while_busy_and_after. If it turns out not to work desirably it can be removed: remove the application of the decorator on methods initialize, write and read_serial_buffer_in remove the decorator function itself remove self._busy and self._additional_timeout from the __init__
-
class
hyperion.controller.generic.generic_serial_contr.
GenericSerialController
(settings)¶ Generic Serial Controller
Parameters: settings (dict) – This includes all the settings needed to connect to the device in question. -
finalize
()¶ This method closes the connection to the device. It is ran automatically if you use a with block.
-
idn
()¶ Identify command.
Returns: identification for the device Return type: string
-
query
(message)¶ Writes message in the device Serial buffer and Reads the response. Note, it clears the input buffer before sending out the query.
Parameters: message (str) – command to send to the device Returns: list of responses received from the device Return type: list of strings
-
read_lines
(remove_leading_trailing_empty_line=True)¶ - Reads all lines the device has sent and returns list of strings. It interprets both
and combinations as a newline character.
param remove_leading_trailing_empty_line: defaults to True type remove_leading_trailing_empty_line: bool return: list of lines received from the device rtype: list of strings
-
-
class
hyperion.controller.generic.generic_serial_contr.
GenericSerialControllerDummy
(settings)¶ A dummy version of the Generic Serial Controller.
Note that because Generic Serial Controller is supposed to be device agnostic this dummy can’t simulate every device. For devices using this Controller, simulation has to be done at Instrument level. This Dummy only stores write messages in a buffer and returns this buffer with the read_serial_buffer_in method.
All other methods are are kept from GenericSerialController.
-
finalize
()¶ Finalizes Generic Serial Controller Dummy device.
-
initialize
()¶ Initializes Generic Serial Controller Dummy device.
-
query
(message)¶ Simulates query to dummy device. Clears the internal buffer. Performs a write, followed by a read_lines(). Note, it clears the input buffer before sending out the query.
Parameters: message (str) – command to send to the device Returns: response from the device Return type: str
-
read_serial_buffer_in
(wait_for_termination_char=True)¶ Simulates read from dummy device (returns internal buffer).
-
write
(message)¶ Simulates write to dummy device (adds message to an internal buffer). :param message: message to write :type message: string
-