Manages serial (eventually RS232, SPI or I2C) communications with expansion boards. It has both a monitoring loop and an “outbox” which it uses for sending information.
Returns a reference to a single SerialManager instance
| Returns SerialManager: | |
|---|---|
| The SerialManager singleton instance | |
Generates a list of available serial ports, mapping their ID to the COM* or /dev/tty* reference. Adapted from http://stackoverflow.com/a/14224477/233608
| Returns: | Nothing |
|---|
Listens for board commands and distributes them to the correct board.
| Parameters: | signal_args – the arguments received from the blinker signal. In the form [‘BOARD ID’, ‘ARGS’, ...] |
|---|
Creates a serial port connection, opens it and returns it. Note if you are using USB serial and an Arduino you may need to put a resistor between 5V or 3.3V and the RESET pin to prevent auto reset. This should only be required during development using a PC. Check the interwebs for the correct resistance value (this is a known issue)
| Parameters: |
|
|---|---|
| Returns: | An open serial port object |
Requests a transmission from the specified board and saves the returned data to the database
| Parameters: | board_id – the ID of the board in hex form, (e.g. “08” for board with ID 8) |
|---|---|
| Returns: | Nothing |
Resets the (Arduino Based) expansion board on the given port by toggling the DTR line. Only works for Arduino based expansion boards
| Parameters: | board_id – the serial port to send the reset command to |
|---|
Sends the given command over the serial port and checks for an ACK response. Returns None if the ACK was received, and the received message otherwise
| Parameters: |
|
|---|---|
| Raises ExpansionBoardNotFound: | |
when a message is sent to an expansion board which doesn’t exist |
|
| Returns: | the board response if an error was received, or None if ACK was received |
Requests an ID from the serial port name and returns it. If no ID is found, return None
| Parameters: | port – the serial port handle to read/write from |
|---|---|
| Returns: | A two digit hex board ID, or None if no ID was found |