8#include "unordered_map"
9#if ECU_TESTING == FRONT_ECU
17static elapsedMillis timeElapsedHigh;
18static elapsedMillis timeElapsedMidHigh;
19static elapsedMillis timeElapsedMidLow;
20static elapsedMillis timeElapsedLow;
24static void pushCanMessage() {
28 c += Serial.readBytes((
char *)&address, 4);
29 c += Serial.readBytes(buffer, 8);
31 Log.
w(ID,
"Did not read correct number of Bytes, not pushing message", 12);
34 Log.
d(ID,
"Pushing Message", address);
35 Canbus::sendData(address, (uint8_t *)buffer);
38static void toggleCanbusSniffer() {
39 static bool enabled =
false;
40 Canbus::enableCanbusSniffer((enabled = !enabled));
43static void sendEchoMessage() {
48 c += Serial.readBytes((
char *)&delay, 4);
49 c += Serial.readBytes((
char *)&address, 4);
50 c += Serial.readBytes(buffer, 8);
52 Log.
w(ID,
"Did not read correct number of Bytes, not pushing message", 20);
55 Log.
d(ID,
"Pushing Message", address);
59static void toggleMotorDirection() {
60 static bool reverse =
false;
73 Log.
i(ID,
"Teensy 3.6 SAE FRONT ECU Initalizing");
75 Log.
i(ID,
"Setting up Canbus");
77 Log.
i(ID,
"Initalizing Pins");
79#ifndef CONF_LOGGING_ASCII_DEBUG
80 Log.
i(ID,
"Enabling Logging relay");
85 Log.
i(ID,
"Setting commands");
100 static bool hasBeat =
false;
102 Log.
d(ID,
"Delaying 2 sec");
109#if ECU_TESTING == FRONT_ECU
119 if (timeElapsedHigh >= INTERVAL_HIGH_PRIORITY) {
128 if (timeElapsedLow >= INTERVAL_MED_LOW_PRIORITY) {
Configure global build properties.
Echo can messages with a delay.
Make one ECU tell the other it is alive.
const char * LOG_TAG
Type definition of logging tags This typedef is necessary to allow for easier manipulation of code by...
Logging::Log_t Log
The global logging object.
This module allows for the monitoring and modification of each GPIO pin on an ECU.
#define COMMAND_SEND_ECHO
Command to listen for a can message to echo, for Echo.h.
#define COMMAND_UPDATE_SERIALVAR
Command to update a serial variable.
#define COMMAND_TOGGLE_REVERSE
Command to enable reverse motors, for MotorControl.h.
#define COMMAND_TOGGLE_CANBUS_SNIFF
Command used to enable the ASCII canbus sniffer.
#define COMMAND_SEND_CANBUS_MESSAGE
Command used to listen for a canbus message to send.
#define COMMAND_PRINT_LOOKUP
Command to send the compressed lookup table over serial.
#define COMMAND_ENABLE_CHARGING
Command used to enable charging.
SerialCommand functionality.
#define SERIALVAR_TORQUE_VECTORING_AGGRESSION
ID for Torque vectoring aggression serial var.
Basic functions used for testing.
Template of a Serial Variable.
int receiveCommand(void)
receive any command from serial by matching incoming bytes to a callback
void setCommand(uint8_t command, CommandCallback callback)
attach a single callback to a byte value that will be received over serial
void echo(uint32_t delay, const uint32_t address, uint8_t buf[8])
Send a can message to the back ECU from the front to then echo the same message at a set delay.
bool anyFault(void)
Checks both hardFault and softFault.
void logFault(void)
Interprets and logs the last fault that was checked using the Log library.
Name space used solely for front ECU logic.
void setChargeSignal()
Enables the charging signal dependent on the current state.
void run()
Runs front ECU code.
void lowPriorityValues()
Outputs values that are of lower priority.
void highPriorityValues()
Outputs values that are of higher priority.
void updateStartLight(bool hasBeat)
Update the startlight.
void loadStateMap()
Load values that ID each unique state.
void updateCurrentState()
Update and outputs the current state.
void beginReceiving()
Set callback to receive beats over CAN.
int checkBeat()
Poll if a beat has been received.
void enableCanbusRelay()
If a set address is received through canbus, the data will be pushed to a buffer to be printed.
void printLookup()
Print the ZLib compressed string of the current lookup table to serial.
void setup(void)
Setup a listener for going into mirror mode, dependent on which ECU is compiled.
void setPinValue(uint8_t GPIO_Pin, int value)
Set the pin value of a predefined pin.
int getCanPinValue(uint8_t CAN_GPIO_Pin)
Get the pin value of a predefined canbus pin.
void initialize(void)
Initialize all predefined pins.
void setInternalValue(uint8_t Internal_Pin, int value)
Set the value of an internal pin.
void receiveSerialVar()
Receive a variable over serial.
void d(LOG_TAG TAG, LOG_MSG message)
Log a string using a debug tag.
void w(LOG_TAG TAG, LOG_MSG message)
Log a string using a warning tag.
void i(LOG_TAG TAG, LOG_MSG message)
Log a string using an info tag.