SAE Teensy ECU
IIT SAE Microcontroller programming
|
Base class used to log things over serial. More...
#include <Log.h>
Public Member Functions | |
void | operator() (LOG_TAG TAG, LOG_MSG message) |
Log a string usb serial. | |
void | d (LOG_TAG TAG, LOG_MSG message) |
Log a string using a debug tag. | |
void | i (LOG_TAG TAG, LOG_MSG message) |
Log a string using an info tag. | |
void | w (LOG_TAG TAG, LOG_MSG message) |
Log a string using a warning tag. | |
void | e (LOG_TAG TAG, LOG_MSG message) |
Log a string using an error tag. | |
void | f (LOG_TAG TAG, LOG_MSG message) |
Log a string using a fatal tag. | |
void | operator() (LOG_TAG TAG, LOG_MSG message, const uint32_t number, int mediate=false) |
Log a string and a variable number to usb serial. | |
void | d (LOG_TAG TAG, LOG_MSG message, const uint32_t number, int mediate=false) |
Log a string and a variable number using a debug tag. | |
void | i (LOG_TAG TAG, LOG_MSG message, const uint32_t number, int mediate=false) |
Log a string and a variable number using an info tag. | |
void | w (LOG_TAG TAG, LOG_MSG message, const uint32_t number, int mediate=false) |
Log a string and a variable number using a warning tag. | |
void | e (LOG_TAG TAG, LOG_MSG message, const uint32_t number, int mediate=false) |
Log a string and a variable number using an error tag. | |
void | f (LOG_TAG TAG, LOG_MSG message, const uint32_t number, int mediate=false) |
Log a string and a variable number using a fatal tag. | |
void | p (LOG_TAG name, LOG_MSG prettyName, const uint32_t number, int mediate=false) |
Post a monitored value. | |
Base class used to log things over serial.
Logging is centered around communicating with the companion app.
In its default mode, logging does not send ASCII strings but integer numbers which represent a set of defined strings.
The actual messages that are sent over serial are as follows.
Bytes 0-1 represent a State Code, or in other works, a unique number that is mapped to a unique string representing the name of what is making this log entry.
Bytes 2-3 represent a String ID, a unique number that is mapped to a unique string.
Bytes 4-7 represent a 32 bit value, by default it is zero, every log entry has this number sent.
Calls to the global Log
can be done as follows.
TAG
can be staticly defined using a LOG_TAG
.
message
must be a string literal as such.
Unless TAG2NUM() is used.
And number
can be any unsigned 32 bit integer.
The companion app received this messages as an 8 byte integer and decodes them by first splitting them into the structure shown, and then matching those number that Pre_Build.py generates in log_lookup.json
When the prebuild script Pre_Build.py is skipped, calls to Log
still function, however the message sent is instead a formatted ASCII string, no string mapping or anything else occurs.
This mode also has the option to prepend a time stamp
Logging has different levels which can be logged to, this is used to differentiate between how important different log entries are.
The current types are as follows.
Func Call | Log Type |
---|---|
Log.d() | Debug log |
Log.i() | Info log |
Log() | Normal log |
Log.w() | Warning log |
Log.e() | Error log |
Log.f() | Fatal Log |
The front ECU can easily communicate with the companion app as it is connected directly with USB serial.
However, the back ECU is only connected to the front ECU through CanBus.
To enable logging on the back ECU, it has to send messages over Canbus. This method is only supported when Logging is in it's default mode.
Running Logging::enableCanbusRelay() once on the front ECU ensure that it receives and relays messages from the back ECU to the companion app.
Log a string using a debug tag.
TAG | Variable of type LOG_TAG |
message | Inline string that should be printed |
Log a string and a variable number using a debug tag.
TAG | Variable of type LOG_TAG |
message | Inline string that should be printed |
number | Any number that should be printed next to the string |
mediate | Indicate whether this message should only print when the number changes, only works in non-ASCII mode |
Log a string using an error tag.
TAG | Variable of type LOG_TAG |
message | Inline string that should be printed |
Log a string and a variable number using an error tag.
TAG | Variable of type LOG_TAG |
message | Inline string that should be printed |
number | Any number that should be printed next to the string |
mediate | Indicate whether this message should only print when the number changes, only works in non-ASCII mode |
Log a string using a fatal tag.
TAG | Variable of type LOG_TAG |
message | Inline string that should be printed |
Log a string and a variable number using a fatal tag.
TAG | Variable of type LOG_TAG |
message | Inline string that should be printed |
number | Any number that should be printed next to the string |
mediate | Indicate whether this message should only print when the number changes, only works in non-ASCII mode |
Log a string using an info tag.
TAG | Variable of type LOG_TAG |
message | Inline string that should be printed |
Log a string and a variable number using an info tag.
TAG | Variable of type LOG_TAG |
message | Inline string that should be printed |
number | Any number that should be printed next to the string |
mediate | Indicate whether this message should only print when the number changes, only works in non-ASCII mode |
Log a string usb serial.
TAG | Variable of type LOG_TAG |
message | Inline string that should be printed |
void Logging::Log_t::operator() | ( | LOG_TAG | TAG, |
LOG_MSG | message, | ||
const uint32_t | number, | ||
int | mediate = false |
||
) |
Log a string and a variable number to usb serial.
TAG | Variable of type LOG_TAG |
message | Inline string that should be printed |
number | Any number that should be printed next to the string |
mediate | Indicate whether this message should only print when the number changes, only works in non-ASCII mode |
void Logging::Log_t::p | ( | LOG_TAG | name, |
LOG_MSG | prettyName, | ||
const uint32_t | number, | ||
int | mediate = false |
||
) |
Post a monitored value.
name | Code safe name of this value |
prettyName | Pretty, human readable name of this value |
number | Integer number associated with this value |
mediate | Indicate whether this message should only print when the number changes, only works in non-ASCII mode |
Log a string using a warning tag.
TAG | Variable of type LOG_TAG |
message | Inline string that should be printed |
Log a string and a variable number using a warning tag.
TAG | Variable of type LOG_TAG |
message | Inline string that should be printed |
number | Any number that should be printed next to the string |
mediate | Indicate whether this message should only print when the number changes, only works in non-ASCII mode |