16#include "usb_serial.h"
20static LOG_TAG ID =
"Serial Command";
22#define X(value) value,
28static size_t matchCommand(uint8_t val) {
42 if (Serial.available()) {
43 serialData = Serial.read();
44 Log.
d(ID,
"Data received: ", serialData);
46 if ((i = matchCommand(serialData)) != COMMAND_COUNT && callbacks[i]) {
54 for (
size_t i = 0; i < COMMAND_COUNT; i++) {
55 if (cmdMap[i] == command) {
56 callbacks[i] = callback;
57 Log.
i(ID,
"Command set for:", command);
61 Log.
w(ID,
"No Command found for command:", command);
Special logging functionality.
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.
#define SERIAL_COMMANDS
Defines commands that the ECU must react to.
SerialCommand functionality.
void(* CommandCallback)(void)
A function that will be called whenever its corresponding command byte is received.
A simple way to run commands over serial.
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 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.