Notifications
Clear all

Remote Serial/Debug

5 Posts
2 Users
0 Reactions
836 Views
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7641
Topic starter  

I have a challenge. I have a sketch that appears to just stop looping.

Inside of the "void loop() {" there are NO other looping constructs, nothing but some if's testing various variables and the significant parts are checking the state of 3 push buttons. I have tested with several button libraries, as well as my own and a fellow forum member. The external symptom is the sketch is NOT responding to a button press.

Take as a given I cannot connect my laptop to the board.

The issue then is how do I watch debug messages when I have no physical connection.

Obviously I prefer a library approach with a simple interface like RemotePrint(" I did this ");

I have installed a bunch of libraries that claim this ability including mqtt and wifi but would like to hear recommendations from folks that have used one of these techniques.

At the moment, I can't even leave a USB cable plugged into the board so I can then see what is in the Serial buffer after a failure as that is how I am powering the board. My plan B is to resolder the perf board to get 5V power another way and leave the USB port for local debug but a remote option will also be useful for future projects and more fun!

NO I am not showing the code, it's a transient error so the code works most of the time and all the code is exercised multiple times prior to failing. I KNOW the code is solid. I have also used 4 different boards. Perhaps the only tricky bit is the following.

portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED;
void IRAM_ATTR TimerKitchen_ISR()  { portENTER_CRITICAL_ISR(&timerMux); ISRTimerKitchen  = true; portEXIT_CRITICAL_ISR(&timerMux);}
void IRAM_ATTR TimerBathroom_ISR() { portENTER_CRITICAL_ISR(&timerMux); ISRTimerBathroom = true; portEXIT_CRITICAL_ISR(&timerMux);}
void IRAM_ATTR TimerWasher_ISR()   { portENTER_CRITICAL_ISR(&timerMux); ISRTimerWasher   = true; portEXIT_CRITICAL_ISR(&timerMux);}

The setup code for a timer is

void SetupTimer(hw_timer_t * Timer, uint64_t Duration, void (* Timer_ISR)(void), int HW_Timer){
 
  const bool Edge    = true;
  const bool OneShot = false;

  LOG("Set up timer for " + String(HW_Timer));

  timerEnd(Timer);
  Timer = timerBegin(HW_Timer, 40000, true);    // timer is now 1/2000 or every 2ms tick
  timerAttachInterrupt(Timer, Timer_ISR, Edge);
  timerAlarmWrite(Timer, Duration, OneShot);
  timerAlarmEnable(Timer);        
}

and the call is 

    else{                   // was OFF so toggle ON
      TimerKitchenOn = true;
      LOG(" Kitchen ON ");
      ledcWrite(LedChanYellow[Kitchen], DutyCycleYellow[Kitchen]);
      SetupTimer(TimerKitchen, DurationK, &TimerKitchen_ISR, 0);
    }

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
Quote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@zander

    "I KNOW the code is solid.🙂

Posted by: @zander

I have installed a bunch of libraries that claim this ability including mqtt and wifi but would like to hear recommendations from folks that have used one of these techniques.

If you're using a PI with MQTT, you can publish debug information to an appropriate debug topic that you set up.  You can access that via another client subscribed to the topic to receive the debug information as it occurs, and from your laptop with a WiFi connection too.

Another option could be to just add a simple I2C OLED that you write your debug info to - You could also toggle it on of off with a button, etc.

In future, please specify the board from which you wish to check its debug info messages.

Also look at the following:

ESP32 WebSerial Library

Cheers


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7641
Topic starter  

@frogandtoad I got the MQTT working fairly quickly, but am appalled at how much it slowed down my sketch. I am on a poor WiFi (free) setup so I need to get my Pi4 server set up with mosquitto before I blame MQTT entirely. I expect some slow down but what I am getting now is a show stopper without adding a mechanical switch on a pin to toggle MQTT on and off. The Mac client I am using is MQTTAnalyzer, it's ok but is there something better? Or should I plan on building my own at some point. I don't have a need for a dashboard type, just logging/debug output, basically I am just redirecting Serial to Log which is an MQTT connected thing (sorry I don't know the lingo)

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@zander

Posted by: @zander

@frogandtoad I got the MQTT working fairly quickly, but am appalled at how much it slowed down my sketch. I am on a poor WiFi (free) setup so I need to get my Pi4 server set up with mosquitto before I blame MQTT entirely. I expect some slow down but what I am getting now is a show stopper without adding a mechanical switch on a pin to toggle MQTT on and off. The Mac client I am using is MQTTAnalyzer, it's ok but is there something better? Or should I plan on building my own at some point. I don't have a need for a dashboard type, just logging/debug output, basically I am just redirecting Serial to Log which is an MQTT connected thing (sorry I don't know the lingo)

MQTT is supposed to be a light weight and fast communication protocol, so not really sure it is the client problem.  Anyway, I don't know anything about that client for MAC, but I have previously seen that you can actually install and use the "mosquitto" client on a MAC.

By the way... you haven't told us which device you are running the MQTT server from, or what client (esp32?) you are running to send serial debug information to the MQTT server topic and to check from which device.

Also, you shouldn't be attempting to toggle the MQTT server service on or off - That doesn't make much sense at all.

Your poor WiFi is more likely to do with your WiFi configuration settings..., so may be worth spending some time investigating that.

Cheers


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7641
Topic starter  

@frogandtoad There are a few Mac clients, they obviously are not the issue as they are passive. I will look into mosquitto on the Mac but will also add it to one of my Pi's and eliminate the internet.

The application is running on an ESP32. All I am doing is changing the Serial.println to Log.println where the Log function is from an Arduino library.

My WiFi is fast (802.11ax), it's the free part after the router I connect to outside the RV that is the issue. Most of the time it's fine (we watch 4K movies no problem) but at certain times it's not.

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote