Speeduino
Loading...
Searching...
No Matches
Macros | Functions | Variables
comms_legacy.cpp File Reference
#include "globals.h"
#include "comms.h"
#include "comms_legacy.h"
#include "comms_secondary.h"
#include "storage.h"
#include "maths.h"
#include "utilities.h"
#include "decoders.h"
#include "TS_CommandButtonHandler.h"
#include "pages.h"
#include "page_crc.h"
#include "logger.h"
#include "table3d_axis_io.h"
#include <BOARD_H>

Macros

#define serial_print_space_delimited_array(array)   serial_print_space_delimited(array, _end_range_address(array))
 

Functions

static bool isMap (void)
 
void legacySerialCommand (void)
 
void legacySerialHandler (byte cmd, Stream &targetPort, SerialStatus &targetStatusFlag)
 
void sendValues (uint16_t offset, uint16_t packetLength, byte cmd, Stream &targetPort, SerialStatus &targetStatusFlag)
 
void sendValues (uint16_t offset, uint16_t packetLength, byte cmd, Stream &targetPort, SerialStatus &targetStatusFlag, uint8_t(*logFunction)(uint16_t))
 
void sendValuesLegacy (void)
 
void sendPage (void)
 
void sendPageASCII (void)
 
void receiveCalibration (byte tableID)
 
void sendToothLog_legacy (byte startOffset)
 
void sendCompositeLog_legacy (byte startOffset)
 
void testComm (void)
 

Variables

static byte currentPage = 1
 
bool firstCommsRequest = true
 
static byte currentCommand
 
static bool chunkPending = false
 
static uint16_t chunkComplete = 0
 
static uint16_t chunkSize = 0
 
static int valueOffset
 
byte logItemsTransmitted
 
byte inProgressLength
 
SerialStatus serialStatusFlag
 Current status of serial comms.
 
SerialStatus serialSecondaryStatusFlag
 

Detailed Description

Process Incoming and outgoing serial communications.

Macro Definition Documentation

◆ serial_print_space_delimited_array

#define serial_print_space_delimited_array (   array)    serial_print_space_delimited(array, _end_range_address(array))

Function Documentation

◆ isMap()

static bool isMap ( void  )
static
Here is the caller graph for this function:

◆ legacySerialCommand()

void legacySerialCommand ( void  )

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:

  • cmdPending = If a command has started but is waiting on further data to complete
  • chunkPending = Specifically for the new receive value method where TS will send a known number of contiguous bytes to be written to a table

Commands are single byte (letter symbol) commands.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ legacySerialHandler()

void legacySerialHandler ( byte  cmd,
Stream targetPort,
SerialStatus targetStatusFlag 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ receiveCalibration()

void receiveCalibration ( byte  tableID)

Processes an incoming stream of calibration data (for CLT, IAT or O2) from TunerStudio. Result is store in EEPROM and memory.

Parameters
tableID- calibration table to process. 0 = Coolant Sensor. 1 = IAT Sensor. 2 = O2 Sensor.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendCompositeLog_legacy()

void sendCompositeLog_legacy ( byte  startOffset)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendPage()

void sendPage ( void  )

Pack the data within the current page (As set with the 'P' command) into a buffer and send it.

Creates a page iterator by page_begin() (See: pages.cpp). Sends page given in currentPage.

Note that some translation of the data is required to lay it out in the way Megasquirt / TunerStudio expect it. Data is sent in binary format, as defined by in each page in the speeduino.ini.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendPageASCII()

void sendPageASCII ( void  )

Send page as ASCII for debugging purposes. Similar to sendPage(), however data is sent in human readable format. Sends page given in currentPage.

This is used for testing only (Not used by TunerStudio) in order to see current map and config data without the need for TunerStudio.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendToothLog_legacy()

void sendToothLog_legacy ( byte  startOffset)

Send 256 tooth log entries to primarySerial. if useChar is true, the values are sent as chars to be printed out by a terminal emulator if useChar is false, the values are sent as a 2 byte integer which is readable by TunerStudios tooth logger

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendValues() [1/2]

void sendValues ( uint16_t  offset,
uint16_t  packetLength,
byte  cmd,
Stream targetPort,
SerialStatus targetStatusFlag 
)

Send a status record back to tuning/logging SW. This will "live" information from currentStatus struct.

Parameters
offset- Start field number
packetLength- Length of actual message (after possible ack/confirm headers)
cmd- ??? - Will be used as some kind of ack on secondarySerial
targetPort- The HardwareSerial device that will be transmitted to
targetStatusFlag- The status flag that will be set to indicate the status of the transmission
logFunction- The function that should be called to retrieve the log value E.g. tuning sw command 'A' (Send all values) will send data from field number 0, LOG_ENTRY_SIZE fields.
Returns
the current values of a fixed group of variables
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendValues() [2/2]

void sendValues ( uint16_t  offset,
uint16_t  packetLength,
byte  cmd,
Stream targetPort,
SerialStatus targetStatusFlag,
uint8_t(*)(uint16_t logFunction 
)
Here is the call graph for this function:

◆ sendValuesLegacy()

void sendValuesLegacy ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ testComm()

void testComm ( void  )
Here is the caller graph for this function:

Variable Documentation

◆ chunkComplete

uint16_t chunkComplete = 0
static

The number of bytes in a chunk write that have been written so far

◆ chunkPending

bool chunkPending = false
static

Whether or not the current chunk write is complete or not

◆ chunkSize

uint16_t chunkSize = 0
static

The complete size of the requested chunk write

◆ currentCommand

byte currentCommand
static

The serial command that is currently being processed. This is only useful when cmdPending=True

◆ currentPage

byte currentPage = 1
static

◆ firstCommsRequest

bool firstCommsRequest = true

The number of times the A command has been issued. This is used to track whether a reset has recently been performed on the controller

◆ inProgressLength

byte inProgressLength

◆ logItemsTransmitted

byte logItemsTransmitted

◆ serialSecondaryStatusFlag

SerialStatus serialSecondaryStatusFlag

◆ serialStatusFlag

SerialStatus serialStatusFlag

Current status of serial comms.

◆ valueOffset

int valueOffset
static

The memory offset within a given page for a value to be read from or written to. Note that we cannot use 'offset' as a variable name, it is a reserved word for several teensy libraries