logs
This commit is contained in:
@@ -878,7 +878,7 @@ String Board320_240::menuItemCaption(int16_t menuItemId, String title) {
|
||||
case MENU_SDCARD: sprintf(tmpStr1, "[%d] %lluMB", SD.cardType(), SD.cardSize() / (1024 * 1024)); suffix = tmpStr1; break;
|
||||
case MENU_SERIAL_CONSOLE: suffix = (liveData->settings.serialConsolePort == 255) ? "[off]" : "[on]"; break;
|
||||
case MENU_DEBUG_LEVEL: switch (liveData->settings.debugLevel) {
|
||||
case 0: suffix = "[none]" ; break;
|
||||
case 0: suffix = "[all]" ; break;
|
||||
case 1: suffix = "[comm]" ; break;
|
||||
case 2: suffix = "[gsm]" ; break;
|
||||
case 3: suffix = "[sdcard]" ; break;
|
||||
@@ -1049,7 +1049,7 @@ void Board320_240::menuItemClick() {
|
||||
case MENU_GPRS: liveData->settings.gprsHwSerialPort = (liveData->settings.gprsHwSerialPort == 2) ? 255 : liveData->settings.gprsHwSerialPort + 1; showMenu(); return; break;
|
||||
case MENU_GPS: liveData->settings.gpsHwSerialPort = (liveData->settings.gpsHwSerialPort == 2) ? 255 : liveData->settings.gpsHwSerialPort + 1; showMenu(); return; break;
|
||||
case MENU_SERIAL_CONSOLE: liveData->settings.serialConsolePort = (liveData->settings.serialConsolePort == 0) ? 255 : liveData->settings.serialConsolePort + 1; showMenu(); return; break;
|
||||
case MENU_DEBUG_LEVEL: liveData->settings.debugLevel = (liveData->settings.debugLevel == 3) ? 0 : liveData->settings.debugLevel + 1; showMenu(); return; break;
|
||||
case MENU_DEBUG_LEVEL: liveData->settings.debugLevel = (liveData->settings.debugLevel == 3) ? 0 : liveData->settings.debugLevel + 1; syslog->setDebugLevel(liveData->settings.debugLevel); showMenu(); return; break;
|
||||
// Wifi menu
|
||||
case MENU_WIFI_ENABLED: liveData->settings.wifiEnabled = (liveData->settings.wifiEnabled == 1) ? 0 : 1; showMenu(); return; break;
|
||||
case MENU_WIFI_SSID: return; break;
|
||||
|
||||
@@ -211,6 +211,8 @@ void BoardInterface::loadSettings() {
|
||||
// Apply settings from flash if needed
|
||||
liveData->settings = liveData->tmpSettings;
|
||||
}
|
||||
|
||||
syslog->setDebugLevel(liveData->settings.debugLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,7 +24,7 @@ void CommInterface::mainLoop() {
|
||||
if (ch == '\r' || ch == '\n') {
|
||||
board->customConsoleCommand(response);
|
||||
response = response + ch;
|
||||
syslog->println(response);
|
||||
syslog->info(DEBUG_COMM, response);
|
||||
executeCommand(response);
|
||||
response = "";
|
||||
} else {
|
||||
@@ -59,8 +59,8 @@ bool CommInterface::doNextQueueCommand() {
|
||||
liveData->currentAtshRequest = liveData->commandRequest;
|
||||
}
|
||||
|
||||
syslog->print(">>> ");
|
||||
syslog->println(liveData->commandRequest);
|
||||
syslog->infoNolf(DEBUG_COMM, ">>> ");
|
||||
syslog->info(DEBUG_COMM, liveData->commandRequest);
|
||||
liveData->responseRowMerged = "";
|
||||
executeCommand(liveData->commandRequest);
|
||||
liveData->commandQueueIndex++;
|
||||
@@ -72,7 +72,7 @@ bool CommInterface::doNextQueueCommand() {
|
||||
bool CommInterface::parseResponse() {
|
||||
|
||||
// 1 frame data
|
||||
syslog->println(liveData->responseRow);
|
||||
syslog->info(DEBUG_COMM, liveData->responseRow);
|
||||
|
||||
// Merge frames 0:xxxx 1:yyyy 2:zzzz to single response xxxxyyyyzzzz string
|
||||
if (liveData->responseRow.length() >= 2 && liveData->responseRow.charAt(1) == ':') {
|
||||
|
||||
@@ -129,8 +129,8 @@ static void notifyCallback (BLERemoteCharacteristic * pBLERemoteCharacteristic,
|
||||
liveDataObj->responseRow += ch;
|
||||
if (liveDataObj->responseRow == ">") {
|
||||
if (liveDataObj->responseRowMerged != "") {
|
||||
syslog->print("merged:");
|
||||
syslog->println(liveDataObj->responseRowMerged);
|
||||
syslog->infoNolf(DEBUG_COMM, "merged:");
|
||||
syslog->info(DEBUG_COMM, liveDataObj->responseRowMerged);
|
||||
boardObj->parseRowMerged();
|
||||
}
|
||||
liveDataObj->responseRowMerged = "";
|
||||
|
||||
@@ -90,7 +90,7 @@ void CommObd2Can::mainLoop() {
|
||||
delay(1);
|
||||
// apply timeout for next frames loop too
|
||||
if (lastDataSent != 0 && (unsigned long)(millis() - lastDataSent) > 100) {
|
||||
syslog->print("CAN execution timeout (multiframe message).\n");
|
||||
syslog->info(DEBUG_COMM, "CAN execution timeout (multiframe message).");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -101,7 +101,7 @@ void CommObd2Can::mainLoop() {
|
||||
}
|
||||
}
|
||||
if (lastDataSent != 0 && (unsigned long)(millis() - lastDataSent) > 100) {
|
||||
syslog->print("CAN execution timeout. Continue with next command.\n");
|
||||
syslog->info(DEBUG_COMM, "CAN execution timeout. Continue with next command.");
|
||||
liveData->canSendNextAtCommand = true;
|
||||
return;
|
||||
}
|
||||
@@ -112,8 +112,8 @@ void CommObd2Can::mainLoop() {
|
||||
*/
|
||||
void CommObd2Can::executeCommand(String cmd) {
|
||||
|
||||
syslog->print("executeCommand ");
|
||||
syslog->println(cmd);
|
||||
syslog->infoNolf(DEBUG_COMM, "executeCommand ");
|
||||
syslog->info(DEBUG_COMM, cmd);
|
||||
|
||||
if (cmd.equals("") || cmd.startsWith("AT")) { // skip AT commands as not used by direct CAN connection
|
||||
lastDataSent = 0;
|
||||
@@ -184,17 +184,17 @@ void CommObd2Can::sendPID(const uint16_t pid, const String& cmd) {
|
||||
const uint8_t sndStat = CAN->sendMsgBuf(pid, 0, 8, txBuf); // 11 bit
|
||||
// uint8_t sndStat = CAN->sendMsgBuf(0x7e4, 1, 8, tmp); // 29 bit extended frame
|
||||
if (sndStat == CAN_OK) {
|
||||
syslog->print("SENT ");
|
||||
syslog->infoNolf(DEBUG_COMM, "SENT ");
|
||||
lastDataSent = millis();
|
||||
} else {
|
||||
syslog->print("Error sending PID ");
|
||||
syslog->infoNolf(DEBUG_COMM, "Error sending PID ");
|
||||
}
|
||||
syslog->print(pid);
|
||||
syslog->infoNolf(DEBUG_COMM, pid);
|
||||
for (uint8_t i = 0; i < 8; i++) {
|
||||
sprintf(msgString, " 0x%.2X", txBuf[i]);
|
||||
syslog->print(msgString);
|
||||
syslog->infoNolf(DEBUG_COMM, msgString);
|
||||
}
|
||||
syslog->println("");
|
||||
syslog->info(DEBUG_COMM, "");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,16 +212,16 @@ void CommObd2Can::sendFlowControlFrame() {
|
||||
|
||||
const uint8_t sndStat = CAN->sendMsgBuf(lastPid, 0, 8, txBuf); // 11 bit
|
||||
if (sndStat == CAN_OK) {
|
||||
syslog->print("Flow control frame sent ");
|
||||
syslog->infoNolf(DEBUG_COMM, "Flow control frame sent ");
|
||||
} else {
|
||||
syslog->print("Error sending flow control frame ");
|
||||
syslog->infoNolf(DEBUG_COMM, "Error sending flow control frame ");
|
||||
}
|
||||
syslog->print(lastPid);
|
||||
syslog->infoNolf(DEBUG_COMM, lastPid);
|
||||
for (auto txByte : txBuf) {
|
||||
sprintf(msgString, " 0x%.2X", txByte);
|
||||
syslog->print(msgString);
|
||||
syslog->infoNolf(DEBUG_COMM, msgString);
|
||||
}
|
||||
syslog->println("");
|
||||
syslog->info(DEBUG_COMM, "");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -232,7 +232,7 @@ uint8_t CommObd2Can::receivePID() {
|
||||
if (!digitalRead(pinCanInt)) // If CAN0_INT pin is low, read receive buffer
|
||||
{
|
||||
lastDataSent = millis();
|
||||
syslog->print(" CAN READ ");
|
||||
syslog->infoNolf(DEBUG_COMM, " CAN READ ");
|
||||
CAN->readMsgBuf(&rxId, &rxLen, rxBuf); // Read data: len = data length, buf = data byte(s)
|
||||
// mockupReceiveCanBuf(&rxId, &rxLen, rxBuf);
|
||||
|
||||
@@ -241,22 +241,22 @@ uint8_t CommObd2Can::receivePID() {
|
||||
else
|
||||
sprintf(msgString, "Standard ID: 0x%.3lX DLC: %1d Data:", rxId, rxLen);
|
||||
|
||||
syslog->print(msgString);
|
||||
syslog->infoNolf(DEBUG_COMM, msgString);
|
||||
|
||||
if ((rxId & 0x40000000) == 0x40000000) { // Determine if message is a remote request frame.
|
||||
sprintf(msgString, " REMOTE REQUEST FRAME");
|
||||
syslog->print(msgString);
|
||||
syslog->infoNolf(DEBUG_COMM, msgString);
|
||||
} else {
|
||||
for (uint8_t i = 0; i < rxLen; i++) {
|
||||
sprintf(msgString, " 0x%.2X", rxBuf[i]);
|
||||
syslog->print(msgString);
|
||||
syslog->infoNolf(DEBUG_COMM, msgString);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if this packet shall be discarded due to its length.
|
||||
// If liveData->expectedPacketLength is set to 0, accept any length.
|
||||
if(liveData->expectedMinimalPacketLength != 0 && rxLen < liveData->expectedMinimalPacketLength) {
|
||||
syslog->println(" [Ignored packet]");
|
||||
syslog->info(DEBUG_COMM, " [Ignored packet]");
|
||||
return 0xff;
|
||||
}
|
||||
|
||||
@@ -265,12 +265,12 @@ uint8_t CommObd2Can::receivePID() {
|
||||
long unsigned int atsh_response = liveData->hexToDec(liveData->currentAtshRequest.substring(4), 2, false) + 8;
|
||||
|
||||
if(rxId != atsh_response) {
|
||||
syslog->println(" [Filtered packet]");
|
||||
syslog->info(DEBUG_COMM, " [Filtered packet]");
|
||||
return 0xff;
|
||||
}
|
||||
}
|
||||
|
||||
syslog->println();
|
||||
syslog->info(DEBUG_COMM, "");
|
||||
processFrameBytes();
|
||||
//processFrame();
|
||||
} else {
|
||||
@@ -287,11 +287,11 @@ static void printHexBuffer(uint8_t* pData, const uint16_t length, const bool bAd
|
||||
|
||||
for (uint8_t i = 0; i < length; i++) {
|
||||
sprintf(str, " 0x%.2X", pData[i]);
|
||||
syslog->print(str);
|
||||
syslog->infoNolf(DEBUG_COMM, str);
|
||||
}
|
||||
|
||||
if (bAddNewLine) {
|
||||
syslog->println();
|
||||
syslog->info(DEBUG_COMM, "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -407,7 +407,8 @@ bool CommObd2Can::processFrameBytes() {
|
||||
break;
|
||||
|
||||
default:
|
||||
syslog->print("Unknown frame type within CommObd2Can::processFrameBytes(): "); syslog->println((uint8_t)frameType);
|
||||
syslog->infoNolf(DEBUG_COMM, "Unknown frame type within CommObd2Can::processFrameBytes(): ");
|
||||
syslog->info(DEBUG_COMM, (uint8_t)frameType);
|
||||
return false;
|
||||
break;
|
||||
} // \switch (frameType)
|
||||
@@ -467,11 +468,11 @@ bool CommObd2Can::processFrame() {
|
||||
break;
|
||||
}
|
||||
|
||||
syslog->print("> frametype:");
|
||||
syslog->print(frameType);
|
||||
syslog->print(", r: ");
|
||||
syslog->print(rxRemaining);
|
||||
syslog->print(" ");
|
||||
syslog->infoNolf(DEBUG_COMM, "> frametype:");
|
||||
syslog->infoNolf(DEBUG_COMM, frameType);
|
||||
syslog->infoNolf(DEBUG_COMM, ", r: ");
|
||||
syslog->infoNolf(DEBUG_COMM, rxRemaining);
|
||||
syslog->infoNolf(DEBUG_COMM, " ");
|
||||
|
||||
for (uint8_t i = start; i < rxLen; i++) {
|
||||
sprintf(msgString, "%.2X", rxBuf[i]);
|
||||
@@ -479,14 +480,14 @@ bool CommObd2Can::processFrame() {
|
||||
rxRemaining--;
|
||||
}
|
||||
|
||||
syslog->print(", r: ");
|
||||
syslog->print(rxRemaining);
|
||||
syslog->println(" ");
|
||||
syslog->infoNolf(DEBUG_COMM, ", r: ");
|
||||
syslog->infoNolf(DEBUG_COMM, rxRemaining);
|
||||
syslog->info(DEBUG_COMM, " ");
|
||||
|
||||
//parseResponse();
|
||||
// We need to sort frames
|
||||
// 1 frame data
|
||||
syslog->println(liveData->responseRow);
|
||||
syslog->info(DEBUG_COMM, liveData->responseRow);
|
||||
// Merge frames 0:xxxx 1:yyyy 2:zzzz to single response xxxxyyyyzzzz string
|
||||
if (liveData->responseRow.length() >= 2 && liveData->responseRow.charAt(1) == ':') {
|
||||
//liveData->responseRowMerged += liveData->responseRow.substring(2);
|
||||
@@ -494,7 +495,7 @@ bool CommObd2Can::processFrame() {
|
||||
uint16_t startPos = (rowNo * 14) - ((rowNo > 0) ? 2 : 0);
|
||||
uint16_t endPos = ((rowNo + 1) * 14) - ((rowNo > 0) ? 2 : 0);
|
||||
liveData->responseRowMerged = liveData->responseRowMerged.substring(0, startPos) + liveData->responseRow.substring(2) + liveData->responseRowMerged.substring(endPos);
|
||||
syslog->println(liveData->responseRowMerged);
|
||||
syslog->info(DEBUG_COMM, liveData->responseRowMerged);
|
||||
}
|
||||
|
||||
// Send response to board module
|
||||
@@ -510,8 +511,8 @@ bool CommObd2Can::processFrame() {
|
||||
processMergedResponse
|
||||
*/
|
||||
void CommObd2Can::processMergedResponse() {
|
||||
syslog->print("merged:");
|
||||
syslog->println(liveData->responseRowMerged);
|
||||
syslog->infoNolf(DEBUG_COMM, "merged:");
|
||||
syslog->info(DEBUG_COMM, liveData->responseRowMerged);
|
||||
board->parseRowMerged();
|
||||
liveData->responseRowMerged = "";
|
||||
liveData->canSendNextAtCommand = true;
|
||||
|
||||
@@ -206,7 +206,7 @@ typedef struct {
|
||||
// === settings version 6
|
||||
// =================================
|
||||
byte serialConsolePort; // 255-off, 0 - hw serial (std)
|
||||
byte debugLevel; // 0 - info only, 1 - debug communication (BLE/CAN), 2 - debug GSM, 3 - debug SDcard
|
||||
uint8_t debugLevel; // 0 - info only, 1 - debug communication (BLE/CAN), 2 - debug GSM, 3 - debug SDcard
|
||||
uint16_t sdcardLogIntervalSec; // every x seconds
|
||||
uint16_t gprsLogIntervalSec; // every x seconds
|
||||
//
|
||||
|
||||
@@ -6,3 +6,10 @@
|
||||
LogSerial::LogSerial() : HardwareSerial(0) {
|
||||
HardwareSerial::begin(115200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set debug level
|
||||
*/
|
||||
void LogSerial::setDebugLevel(uint8_t aDebugLevel) {
|
||||
debugLevel = aDebugLevel;
|
||||
}
|
||||
|
||||
53
LogSerial.h
53
LogSerial.h
@@ -5,23 +5,54 @@
|
||||
// DEBUG LEVEL
|
||||
#define DEBUG_NONE 0
|
||||
#define DEBUG_COMM 1 // filter comm
|
||||
#define DEBUG_GPS 2 // filter gps messages
|
||||
#define DEBUG_GSM 2 // filter gsm messages
|
||||
#define DEBUG_SDCARD 3 // filter sdcard
|
||||
|
||||
//
|
||||
class LogSerial: public HardwareSerial {
|
||||
protected:
|
||||
|
||||
uint8_t debugLevel;
|
||||
public:
|
||||
LogSerial();
|
||||
/*virtual void infoNolfType(String msg, uint8_t debugLevel = TYPE_NONE);
|
||||
virtual void infoType(String msg, uint8_t debugLevel = TYPE_NONE);
|
||||
/*
|
||||
template <class T, typename... Args> void infoNolf(String msg, uint8_t debugLevel = TYPE_NONE);
|
||||
template <class T, typename... Args> void info(String msg, uint8_t debugLevel = DEBUG_ALL);
|
||||
template <class T, typename... Args> void warnNolf(String msg, uint8_t debugLevel = DEBUG_ALL);
|
||||
template <class T, typename... Args> void warn(String msg, uint8_t debugLevel = DEBUG_ALL);
|
||||
template <class T, typename... Args> void errNolf(String msg, uint8_t debugLevel = DEBUG_ALL);
|
||||
template <class T, typename... Args> void err(String msg, uint8_t debugLevel = DEBUG_ALL);*/
|
||||
//
|
||||
void setDebugLevel(uint8_t aDebugLevel);
|
||||
// info
|
||||
template <class T, typename... Args> void info(uint8_t aDebugLevel, T msg) {
|
||||
if (debugLevel != DEBUG_NONE && aDebugLevel != DEBUG_NONE && aDebugLevel != debugLevel)
|
||||
return;
|
||||
println(msg);
|
||||
}
|
||||
template <class T, typename... Args> void infoNolf(uint8_t aDebugLevel, T msg) {
|
||||
if (debugLevel != DEBUG_NONE && aDebugLevel != DEBUG_NONE && aDebugLevel != debugLevel)
|
||||
return;
|
||||
print(msg);
|
||||
}
|
||||
// warning
|
||||
template <class T, typename... Args> void warn(uint8_t aDebugLevel, T msg) {
|
||||
if (debugLevel != DEBUG_NONE && aDebugLevel != DEBUG_NONE && aDebugLevel != debugLevel)
|
||||
return;
|
||||
print("WARN ");
|
||||
println(msg);
|
||||
}
|
||||
template <class T, typename... Args> void warnNolf(uint8_t aDebugLevel, T msg) {
|
||||
if (debugLevel != DEBUG_NONE && aDebugLevel != DEBUG_NONE && aDebugLevel != debugLevel)
|
||||
return;
|
||||
print("WARN ");
|
||||
print(msg);
|
||||
}
|
||||
|
||||
// error
|
||||
template <class T, typename... Args> void err(uint8_t aDebugLevel, T msg) {
|
||||
if (debugLevel != DEBUG_NONE && aDebugLevel != DEBUG_NONE && aDebugLevel != debugLevel)
|
||||
return;
|
||||
print("ERR ");
|
||||
println(msg);
|
||||
}
|
||||
template <class T, typename... Args> void errNolf(uint8_t aDebugLevel, T msg) {
|
||||
if (debugLevel != DEBUG_NONE && aDebugLevel != DEBUG_NONE && aDebugLevel != debugLevel)
|
||||
return;
|
||||
print("ERR ");
|
||||
print(msg);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
20
evDash.ino
20
evDash.ino
@@ -1,16 +1,16 @@
|
||||
/*
|
||||
/*
|
||||
Project renamed from eNiroDashboard to evDash
|
||||
|
||||
Serial console commands
|
||||
|
||||
serviceUUID=xxx
|
||||
charTxUUID=xxx
|
||||
charRxUUID=xxx
|
||||
wifiSsid=xxx
|
||||
wifiPassword=xxx
|
||||
gprsApn=xxx
|
||||
remoteApiUrl=xxx
|
||||
remoteApiKey=xxx
|
||||
serviceUUID=xxx
|
||||
charTxUUID=xxx
|
||||
charRxUUID=xxx
|
||||
wifiSsid=xxx
|
||||
wifiPassword=xxx
|
||||
gprsApn=xxx
|
||||
remoteApiUrl=xxx
|
||||
remoteApiKey=xxx
|
||||
|
||||
Required libraries
|
||||
- esp32 board support
|
||||
@@ -66,7 +66,7 @@ void setup(void) {
|
||||
// Serial console
|
||||
syslog = new LogSerial();
|
||||
syslog->println("\nBooting device...");
|
||||
|
||||
|
||||
// Init settings/params
|
||||
liveData = new LiveData();
|
||||
liveData->initParams();
|
||||
|
||||
Reference in New Issue
Block a user