Hi Simon
Thank you. I found an interesting behavior when I troubleshoot the "VMDPE issue."
Behavior of the application is different in Debug mode to Release mode.
Below please find a code snippet that I am using to read serial messages. Instead of using
Serial.readStringUntil('\n')
, a non-blocking method is applied to read each character one-by-one on every iteration of the function.
There is an interesting observation by running this function in an infinite loop of 250ms under FreeRTOS. The system crashed whenever I entered "wind\n" to Serial|COM3 (COM3 == Silicon labs CP210x USB port). It was OK with "acc\n" though. Please take a look at a screencapture file
What_happens_in_Vmicro.png.
There are annotations on them so you know what I mean. The funniest behavior is that, it crashed whenever I entered "wind\n"

. That means, I could enter an arbitrary string like "somethingelse\n" the application just return "Command not correct, please try again." as expected.
The problem described above is solved when I change it to Release mode.
The interesting behavior comes when I open Arduino IDE 2.0.4 and reprogram the same code to target. Everything is fine under Arduino IDE (All_OK_under_ArduinoIDE.png).
Any clue on this?
John
/*
* @brief Get value from Serial Monitor at a sampling rate of DAQTask loop.
*/
daq_data_t DAQSimDataGet(void) {
daq_data_t result = { 0 };
static char inBuf[256]; ///static char is mandatory to keep inBuf intact when function exits
static uint8_t index = 0; ///don't forget it is a nonblocking function!!!
if (Serial.available()) {
char c = Serial.read();
if (c != '\n') {
inBuf[index++] = c;
}
else {
inBuf[index] = '\0';
String str = String(inBuf);
if (str == "acc") {
Serial.println(F("It is acc"));
}
else if (str == "wind") {
Serial.println(F("it is wind"));
}
else {
Serial.println(F("Command not correct, please try again."));
}
index = 0;
}
}
return result;
}