CALPOLY MECHATRONICS
Documentation for all Mechatronics Labs
nucleoSerial.nucleoSerial Class Reference

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ __init__()

def nucleoSerial.nucleoSerial.__init__ (   self,
  startState = 0,
  batchSize = 10 
)

A method to initialise a nucleoSerial object.

Parameters
startStateThe state to start the serial coms task state machine in.
batchSizeThe chunk size to send data over serial in, in lines.

Member Function Documentation

◆ genData()

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.

Parameters
tickThe time, in ms.
Returns
A tupel of the form (time t, (seconds), f(t))

◆ transitionStates()

def nucleoSerial.nucleoSerial.transitionStates (   self,
  st,
  customMessage = "" 
)

A method that changes the state machine state, self.state and prints the state transition message.

Parameters
stThe state to transition to. @customMessage An additional message to print before the state transition message.

Member Data Documentation

◆ batchSize

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

◆ serVal

nucleoSerial.nucleoSerial.serVal

A nested List of values to write to serial.

Format is [[row1], [row2], ...]

◆ state

nucleoSerial.nucleoSerial.state

The state to start the serial coms task state machine in.

The time since last state transition, in floating point seconds.

◆ stateMessages

dictionary nucleoSerial.nucleoSerial.stateMessages
static
Initial value:
= {
0 : "NUCLEO: Waiting for serial input.",
1 : "NUCLEO: collecting data.",
2 : "NUCLEO: Transmiting data."
}

A Dictionary of messages to display at each state change.


The documentation for this class was generated from the following file: