A class handles all serial communication with the PC. More...
Public Member Functions | |
| def | __init__ (self, startState=0, batchSize=10) |
| A method to initialise a nucleoSerial object. More... | |
| def | runStateMachine (self) |
| A method to run through the serial coms state machine logic once. | |
| def | genData (self, tick) |
| A debugging method to imitate data from an encoder. More... | |
| def | sendData (self, i) |
| A method to write all of the data in self.serVal to serial line by line as comma seperated values. | |
| def | transitionStates (self, st, customMessage="") |
| A method that changes the state machine state, self.state and prints the state transition message. More... | |
Public Attributes | |
| batchSize | |
| The chunk size to send data over serial in, in lines. More... | |
| myuart | |
| pyb.UART object for handling serial communications. | |
| state | |
| The state to start the serial coms task state machine in. More... | |
| lastTransition | |
| The last time (in ms from startup) that the state machine transitioned states. | |
| serVal | |
| A nested List of values to write to serial. More... | |
| currentIndx | |
Static Public Attributes | |
| dictionary | stateMessages |
| A Dictionary of messages to display at each state change. More... | |
A class handles all serial communication with the PC.
The nucleoSerial class is a task that listens for ASCII characters from the PC, writes position data to serial, and updates values in shares.py to interact with the controller tasks.
| def nucleoSerial.nucleoSerial.__init__ | ( | self, | |
startState = 0, |
|||
batchSize = 10 |
|||
| ) |
A method to initialise a nucleoSerial object.
| startState | The state to start the serial coms task state machine in. |
| batchSize | The chunk size to send data over serial in, in lines. |
| def nucleoSerial.nucleoSerial.genData | ( | self, | |
| tick | |||
| ) |
A debugging method to imitate data from an encoder.
genData calculates the value of a decaying sin wave at a given time.
| tick | The time, in ms. |
| def nucleoSerial.nucleoSerial.transitionStates | ( | self, | |
| st, | |||
customMessage = "" |
|||
| ) |
A method that changes the state machine state, self.state and prints the state transition message.
| st | The state to transition to. @customMessage An additional message to print before the state transition message. |
| nucleoSerial.nucleoSerial.batchSize |
The chunk size to send data over serial in, in lines.
nucleoSerial objects are meant to be called as fast as possible, so small (<100) batch sizes are prefered in order to prevent memory allocation errors
| nucleoSerial.nucleoSerial.serVal |
A nested List of values to write to serial.
Format is [[row1], [row2], ...]
| nucleoSerial.nucleoSerial.state |
The state to start the serial coms task state machine in.
The time since last state transition, in floating point seconds.
|
static |
A Dictionary of messages to display at each state change.