api
¶
This module defines an API of functions which can be used to send commands to the pump.
All functions in this module share the following common arguments:
- connection:
This is a
serial.Serial
instance, which is used to send the command.- pump_on:
If this evaluates to
True
, control bits telling the pump to turn or stay on are added to the telegram. Otherwise receiving the telegram will cause the pump to turn off if it is on.
If a command cannot be sent due to an error in the connection, a
serial.SerialException
will be raised.
The functions return both the query sent to the pump and the reply received
back as TelegramReader
instances.
- turboctl.telegram.api.send(connection, telegram)¶
Send telegram to the pump.
- Parameters:
telegram – A
Telegram
instance.
- turboctl.telegram.api.status(connection, pump_on=None)¶
Request pump status.
This function sends an empty telegram to the pump, which causes it to send back a reply containing some data about the status of the pump.
This can also be used for turning the pump on or off by setting pump_on to
True
orFalse
.
- turboctl.telegram.api.reset_error(connection)¶
Reset the error status of the pump.
This function sends a “reset error” command to the pump.
- turboctl.telegram.api.read_parameter(connection, number, index=0, pump_on=True)¶
Read the value of an index of a parameter.
- Parameters:
number – The number of the parameter.
index – The index of the parameter (0 for unindexed parameters).
- Raises:
ValueError – If number or index have invalid values.
- turboctl.telegram.api.write_parameter(connection, number, value, index=0, pump_on=True)¶
Write a value to an index of a parameter.
- Parameters:
number – The number of the parameter.
value – The value to be written.
index – The index of the parameter (0 for unindexed parameters).
- Raises:
ValueError – If number or index have invalid values.