Welcome to Motor Teststand SerialComm’s documentation!

  • Author: Austin Stover
  • Date: July-August 2017
  • This program performs transmission and reception of serial data from the SerialComm class with the stated protocol
Useful Links:
class SerialComm.SerialComm(serialPort, dictLength=100)[source]

A Serial Communication Class to communicate with an Arduino

Parameters:
  • serialPort – A PySerial object
  • dictLength – The max # of messages of each type to store

This class receives and transmits messages with the following protocol:

Protocol
Byte number:
Description: [ Magic Number ] [ Type Identifier Key ] [ Data Payload ] [ Data Payload ] etc [ Error Check (LRC) Byte ]

To Use:

  • Send messages with the send…() methods
  • Receive messages by putting processData() in a loop–This data will be stored in the dict variable, with a key for each message type and a deque with the messages for each key
dict = None

A Dictionary to hold messages

Each key is a message type which holds a fixed-length deque with recent messages of that type

processData(numLoops=1)[source]

Processes the next byte of data received; if this byte is the beginning of a message, adds the message to dict

Parameters:numLoops – The # of times to do this
sendDebug(stringToSend)[source]

Sends a debug message

Parameters:stringToSend – The message
sendError(stringToSend)[source]

Sends an error message

Parameters:stringToSend – The message
sendMaxCurrent(floatToSend)[source]

Sends the max current

Parameters:floatToSend – The max current as a floating-point # in the range of an Arduino double/float
sendMaxVoltage(floatToSend)[source]

Sends the max voltage

Parameters:floatToSend – The max current as a floating-point # in the range of an Arduino double/float
sendPowerSetting(boolToSend)[source]

Sends the power-setting

Parameters:boolToSend – True for on, False for off
Raises:ValueError
sendThrottleSetting(shortToSend)[source]

Sends the throttle setting

Parameters:shortToSend – An integer between 0 and 100, inclusive
sendTimestamp(intToSend)[source]

Sends a timestamp message

Parameters:intToSend – The timestamp as an integer, in the range of a valid Arduino long
SerialComm.main()[source]

Demo Program: prints a dictionary of messages after some # received

Indices and tables