Speeduino
|
Modules | |
Serial return codes sent to TS | |
Hard coded response for some TS messages | |
Typedefs | |
using | crc_t = uint32_t |
Functions | |
void | processSerialCommand (void) |
Processes a message once it has been fully received. | |
void | sendToothLog (void) |
Should be called when serialStatusFlag == SERIAL_TRANSMIT_TOOTH_INPROGRESS,. | |
void | sendCompositeLog (void) |
Should be called when serialStatusFlag == LOG_SEND_COMPOSITE. | |
bool | isRxTimeout (void) |
Has the current receive operation timed out? | |
void | flushRXbuffer (void) |
Flush all remaining bytes from the rx serial buffer. | |
static uint32_t | reverse_bytes (uint32_t i) |
Reverse the byte order of a uint32_t. | |
void | writeByteReliableBlocking (byte value) |
static void | readSerialTimeout (char *buffer, size_t length) |
Read from the serial port into the supplied buffer. | |
template<typename TIntegral > | |
static TIntegral | readSerialIntegralTimeout (void) |
Reads an integral type, timing out if necessary. | |
static uint32_t | serialWrite (uint32_t value) |
Write a uint32_t to Serial. | |
static void | serialWrite (uint16_t value) |
Write a uint16_t to Serial. | |
static uint16_t | writeNonBlocking (const byte *buffer, size_t length) |
Send as much data as possible without blocking the caller. | |
static size_t | writeNonBlocking (size_t start, uint32_t value) |
Write a uint32_t to Serial without blocking the caller. | |
static uint16_t | sendBufferAndCrcNonBlocking (const byte *buffer, size_t start, size_t length) |
Send the buffer, followed by it's CRC. | |
static void | sendSerialPayloadNonBlocking (uint16_t payloadLength) |
Start sending the shared serialPayload buffer. | |
static void | sendReturnCodeMsg (byte returnCode) |
Send a message to TS containing only a return code. | |
static bool | updatePageValues (uint8_t pageNum, uint16_t offset, const byte *buffer, uint16_t length) |
Update a pages contents from a buffer. | |
static void | loadPageValuesToBuffer (uint8_t pageNum, uint16_t offset, byte *buffer, uint16_t length) |
Loads a pages contents into a buffer. | |
static void | generateLiveValues (uint16_t offset, uint16_t packetLength) |
Send a status record back to tuning/logging SW. This will "live" information from currentStatus struct. | |
static void | loadO2CalibrationChunk (uint16_t offset, uint16_t chunkSize) |
Update the oxygen sensor table from serialPayload. | |
static uint16_t | toTemperature (byte lo, byte hi) |
Convert 2 bytes into an offset temperature in degrees Celsius. | |
static void | processTemperatureCalibrationTableUpdate (uint16_t calibrationLength, uint8_t calibrationPage, uint16_t *values, uint16_t *bins) |
Update a temperature calibration table from serialPayload. | |
void | serialReceive (void) |
The serial receive pump. Should be called whenever the serial port has data available to read. | |
void | serialTransmit (void) |
The serial transmit pump. Should be called when serialStatusFlag indicates a transmit operation is in progress. | |
Variables | |
static constexpr uint8_t | SEND_OUTPUT_CHANNELS = 48U |
Code for the "send output channels command". | |
static uint16_t | serialBytesRxTx = 0 |
The number of bytes received or transmitted to date during nonblocking I/O. | |
static constexpr uint16_t | SERIAL_TIMEOUT = 400 |
Timeout threshold in milliseconds. | |
uint32_t | serialReceiveStartTime = 0 |
The time in milliseconds at which the serial receive started. Used for calculating whether a timeout has occurred. | |
static FastCRC32 | CRC32_serial |
Support accumulation of a CRC during non-blocking operations. | |
static FastCRC32 | CRC32_calibration |
Support accumulation of a CRC during calibration loads. Must be a separate instance to CRC32_serial due to calibration data being sent in multiple packets. | |
static uint8_t | serialPayload [SERIAL_BUFFER_SIZE] |
Serial payload buffer. | |
static uint16_t | serialPayloadLength = 0 |
How many bytes in serialPayload were received or sent. | |
Stream * | pPrimarySerial |
Flush all remaining bytes from the rx serial buffer.
Send a status record back to tuning/logging SW. This will "live" information from currentStatus struct.
offset | - Start field number |
packetLength | - Length of actual message (after possible ack/confirm headers) E.g. tuning sw command 'A' (Send all values) will send data from field number 0, LOG_ENTRY_SIZE fields. |
Has the current receive operation timed out?
Checks whether the current serial command should be timed out.
Update the oxygen sensor table from serialPayload.
offset | Offset into serialPayload and the table |
chunkSize | Number of bytes available in serialPayload |
|
static |
Loads a pages contents into a buffer.
pageNum | The index of the page to update |
offset | Offset into the page |
buffer | The buffer to read from |
length | The buffer length |
Processes a message once it has been fully received.
|
static |
Update a temperature calibration table from serialPayload.
calibrationLength | The chunk size received from TS |
calibrationPage | Index of the table |
values | The table values |
bins | The table bin values |
Reads an integral type, timing out if necessary.
TIntegral | The integral type. E.g. uint16_t |
Read from the serial port into the supplied buffer.
Reverse the byte order of a uint32_t.
|
static |
Send the buffer, followed by it's CRC.
This is supposed to be called multiple times for the same buffer until it's all sent.
buffer | The buffer |
start | Index into the buffer to start sending at. [0, length) |
length | Total size of the buffer |
Should be called when serialStatusFlag == LOG_SEND_COMPOSITE.
Send a message to TS containing only a return code.
This is used when TS asks for an action to happen (E.g. start a logger) or to signal an error condition to TS
Start sending the shared serialPayload buffer.
serialStatusFlag will be signal the result of the send:
serialStatusFlag == SERIAL_INACTIVE: send is complete
serialStatusFlag == SERIAL_TRANSMIT_INPROGRESS: partial send, subsequent calls to continueSerialTransmission will finish sending serialPayload
payloadLength | How many bytes to send [0, sizeof(serialPayload)) |
Should be called when serialStatusFlag == SERIAL_TRANSMIT_TOOTH_INPROGRESS,.
The serial receive pump. Should be called whenever the serial port has data available to read.
Processes the incoming data on the serial buffer based on the command sent. Can be either data for a new command or a continuation of data for command that is already in progress:
Commands are single byte (letter symbol) commands.
The serial transmit pump. Should be called when serialStatusFlag indicates a transmit operation is in progress.
Write a uint16_t to Serial.
Write a uint32_t to Serial.
Convert 2 bytes into an offset temperature in degrees Celsius.
|
static |
Update a pages contents from a buffer.
pageNum | The index of the page to update |
offset | Offset into the page |
buffer | The buffer to read from |
length | The buffer length |
Send as much data as possible without blocking the caller.
Write a uint32_t to Serial without blocking the caller.
|
static |
Support accumulation of a CRC during calibration loads. Must be a separate instance to CRC32_serial due to calibration data being sent in multiple packets.
|
static |
Support accumulation of a CRC during non-blocking operations.
Stream* pPrimarySerial |
Code for the "send output channels command".
|
static |
The number of bytes received or transmitted to date during nonblocking I/O.
|
static |
Serial payload buffer.
|
static |
How many bytes in serialPayload were received or sent.
uint32_t serialReceiveStartTime = 0 |
The time in milliseconds at which the serial receive started. Used for calculating whether a timeout has occurred.