I have a program built that started acting funny today out of nowhere. Things were humming along nicely when all of a sudden the device appears to have gone into an infinite loop that caused it to spew out a mixture of Particle OS debug information and my own debug information. I came back to my desk about 1 hour after it started and it had spewed about 300 MB of this...
Here is the relevant debug log snippet that shows the debug output just before and just after entering the spew loop of doom:
[2023-10-03 08:18:42.326] Link measurements:
[2023-10-03 08:18:42.326] Bus Voltage: 24938 mV | Charging power: 33.9 W | MPPT: -0.3 A (-8.0 W)
[2023-10-03 08:18:42.326]
[2023-10-03 08:18:42.326] 0042030142 [app.linknet] TRACE: Checking for new LinkNet nodes...
[2023-10-03 08:18:42.326] 0042030143 [app.linknet] TRACE: linknet transaction - cmd = DIRECTORY_BROADCAST (0X01) | addr = 0XFE | pyld_tx_size = 18 | pyld_rx_size = 18 | timeout = 1000 ms
[2023-10-03 08:18:43.323]
[2023-10-03 08:18:43.326] 0042031147 [app.linknet] TRACE: linknet_rsp_wait returned NO_RESPONSE (0xE0) - delay of 1001 ms
[2023-10-03 08:18:43.326] 0042031147 [app.linknet] INFO: No unadressed linknet nodes detected
[2023-10-03 08:18:43.326] 0042031148 [app.boss] TRACE: Updating Boss 0 (update #20842)
[2023-10-03 08:18:43.329] 0042031148 [app.linknet] TRACE: linknet transaction - cmd = WEBHOOK_GET_TRACKER (0X30) | addr = 0X00 | pyld_tx_size = 0 | pyld_rx_size = 16 | timeout = 2000 ms
[2023-10-03 08:18:43.447] 0042031270 [app.linknet] TRACE: linknet_rsp_wait returned NONE (0x00) - delay of 120 ms
[2023-10-03 08:18:43.449] 0042031270 [app.linknet] TRACE: linknet transaction - cmd = APP_GET_ANALOG_READINGS (0X10) | addr = 0X00 | pyld_tx_size = 0 | pyld_rx_size = 1928 | timeout = 2000 ms
[2023-10-03 08:18:43.800] 0042031613 [app.linknet] TRACE: linknet_rsp_wait returned NONE (0x00) - delay of 340 ms
[2023-10-03 08:18:43.800] 0042031614 [app.linknet] TRACE: linknet transaction - cmd = APP_SET_CHARGING_CONFIG (0X21) | addr = 0X00 | pyld_tx_size = 17 | pyld_rx_size = 0 | timeout = 2000 ms
[2023-10-03 08:18:43.942] 0042031761 [app.linknet] TRACE: linknet_rsp_wait returned NONE (0x00) - delay of 144 ms
[2023-10-03 08:18:43.942] 0042031761 [app.boss] INFO: requesting Boss linknet error tracker...
[2023-10-03 08:18:43.948] 0042031762 [app.linknet] TRACE: linknet transaction - cmd = APP_GET_NETWORK_STATS (0X14) | addr = 0X00 | pyld_tx_size = 0 | pyld_rx_size = 48 | timeout = 2000 ms
[2023-10-03 08:18:44.178] 0042032000 [app.linknet] TRACE: linknet_rsp_wait returned NONE (0x00) - delay of 236 ms
[2023-10-03 08:18:44.178] 0042032000 [app.boss] TRACE: pkt_rx_starts = 66768
[2023-10-03 08:18:44.182] 0042032001 [app.boss] TRACE: pkt_headers_received = 66768
[2023-10-03 08:18:44.182] 0042032001 [app.boss] TRACE: pkts_received_total = 66768
[2023-10-03 08:18:44.182] 0042032002 [app.boss] TRACE: pkts_received_this = 66768
[2023-10-03 08:18:44.182] 0042032002 [app.boss] TRACE: pkts_received_other = 0
[2023-10-03 08:18:44.186] 0042032003 [app.boss] TRACE: rx_overflows = 0
[2023-10-03 08:18:44.186] 0042032003 [app.boss] TRACE: rx_timeouts = 0
[2023-10-03 08:18:44.186] 0042032003 [app.boss] TRACE: rx_bytes_missed = 0
[2023-10-03 08:18:44.186] 0042032004 [app.boss] TRACE: bad_crcs = 0
[2023-10-03 08:18:44.186] 0042032004 [app.boss] TRACE: uart_errors = 0
[2023-10-03 08:18:44.186] 0042032004 [app.boss] TRACE: max_linknet_latency_ms = 263
[2023-10-03 08:18:44.186] 0042032005 [app.boss] TRACE: max_subnet_latency_ms = 262
[2023-10-03 08:18:44.186] 0042032005 [app.boss] INFO: ------
[2023-10-03 08:18:44.186] 0042032005 [app.boss] INFO: Failed transactions to this boss: 119
[2023-10-03 08:18:44.186] 0042032006 [app.linknet] TRACE: linknet transaction - cmd = APP_GET_HEARTBEAT (0X13) | addr = 0X00 | pyld_tx_size = 0 | pyld_rx_size = 612 | timeout = 2000 ms
[2023-10-03 08:18:44.448] 0042032271 [app.linknet] TRACE: linknet_rsp_wait returned NONE (0x00) - delay of 263 ms
[2023-10-03 08:18:44.448] ========================================
[2023-10-03 08:18:44.462] =============Boss Heartbeat=============
[2023-10-03 08:18:44.462] ========================================
[2023-10-03 08:18:44.462] tstamp_start = Tuesday, October 3rd, 2023 at 12:37 AM
[2023-10-03 08:18:44.462] 0042032275 [comm.protocol] TRACE: Reply recieved: type=2, code=0
[2023-10-03 08:18:44.462] 0042032275 [comm.papp_flags_sticky = 0X00000000
[2023-10-03 08:18:44.462] page_erase_kb = 0
[2023-10-03 08:18:44.462] reset_count = 0
[2023-10-03 08:18:44.462] por_count = 0
[2023-10-03 08:18:44.462] crash_count = 0
[2023-10-03 08:18:44.462] pack_sessions = 1
[2023-10-03 08:18:44.462] webhooks_generatedrotocol] TRACE: message id 1691 complete with code 0.00
[2023-10-03 08:18:44.462] 0042032277 [comm.protocol] TRACE: rcv'd message = 0
[2023-10-03 08:18:44.462] webhook_bytes_generated = 0
[2023-10-03 08:18:44.462] webhooks_delivered = 0
[2023-10-03 08:18:44.462] self_check_watts = 0
[2023-10-03 08:18:44.462] self_check_loaded_mv = 0
[2023-10-03 08:18:44.488] self_check_unlpack_sessions = 1
[2023-10-03 08:18:44.488] webhooks_generatedrotocol] TRACE: message id 1691 complete with code 0.00
[2023-10-03 08:18:44.488] 0042032277 [comm.protocol] TRACE: rcv'd message = 0
[2023-10-03 08:18:44.488] webhook_bytes_generated = 0
[2023-10-03 08:18:44.488] webhooks_delivered = 0
[2023-10-03 08:18:44.488] self_check_watts = 0
[2023-10-03 08:18:44.488] self_check_loaded_mv = 0
[2023-10-03 08:18:44.488] self_check_unlpack_sessions = 1
[2023-10-03 08:18:44.488] webhooks_generatedrotocol] TRACE: message id 1691 complete with code 0.00
[2023-10-03 08:18:44.488] 0042032277 [comm.protocol] TRACE: rcv'd message = 0
[2023-10-03 08:18:44.488] webhook_bytes_generated = 0
[2023-10-03 08:18:44.488] webhooks_delivered = 0
[2023-10-03 08:18:44.488] self_check_watts = 0
[2023-10-03 08:18:44.488] self_check_loaded_mv = 0
[2023-10-03 08:18:44.488] self_check_unloack_sessions = 1
[2023-10-03 08:18:44.488] webhooks_generatedrotocol] TRACE: message id 1691 complete with code 0.00
[2023-10-03 08:18:44.488] 0042032277 [comm.protocol] TRACE: rcv'd message = 0
[2023-10-03 08:18:44.488] webhook_bytes_generated = 0
[2023-10-03 08:18:44.488] webhooks_delivered = 0
[2023-10-03 08:18:44.488] self_check_watts = 0
[2023-10-03 08:18:44.488] self_check_loaded_mv = 0
[2023-10-03 08:18:44.488] self_check_unloack_sessions = 1
[2023-10-03 08:18:44.488] webhooks_generatedrotocol] TRACE: message id 1691 complete with code 0.00
[2023-10-03 08:18:44.488] 0042032277 [comm.protocol] TRACE: rcv'd message = 0
[2023-10-03 08:18:44.488] webhook_bytes_generated = 0
[2023-10-03 08:18:44.488] webhooks_delivered = 0
[2023-10-03 08:18:44.503] self_check_watts = 0
[2023-10-03 08:18:44.503] self_check_loaded_mv = 0
[2023-10-03 08:18:44.503] self_check_unloack_sessions = 1
[2023-10-03 08:18:44.503] webhooks_generatedrotocol] TRACE: message id 1691 complete with code 0.00
[2023-10-03 08:18:44.503] 0042032277 [comm.protocol] TRACE: rcv'd message = 0
[2023-10-03 08:18:44.503] webhook_bytes_generated = 0
[2023-10-03 08:18:44.503] webhooks_delivered = 0
[2023-10-03 08:18:44.503] self_check_watts = 0
[2023-10-03 08:18:44.503] self_check_loaded_mv = 0
[2023-10-03 08:18:44.503] self_check_unloack_sessions = 1
[2023-10-03 08:18:44.503] webhooks_generatedrotocol] TRACE: message id 1691 complete with code 0.00
[2023-10-03 08:18:44.503] 0042032277 [comm.protocol] TRACE: rcv'd message = 0
[2023-10-03 08:18:44.503] webhook_bytes_generated = 0
[2023-10-03 08:18:44.503] webhooks_delivered = 0
[2023-10-03 08:18:44.503] self_check_watts = 0
[2023-10-03 08:18:44.503] self_check_loaded_mv = 0
[2023-10-03 08:18:44.503] self_check_unloack_sessions = 1
[2023-10-03 08:18:44.503] webhooks_generatedrotocol] TRACE: message id 1691 complete with code 0.00
[2023-10-03 08:18:44.503] 0042032277 [comm.protocol] TRACE: rcv'd message = 0
[2023-10-03 08:18:44.503] webhook_bytes_generated = 0
[2023-10-03 08:18:44.503] webhooks_delivered = 0
[2023-10-03 08:18:44.503] self_check_watts = 0
[2023-10-03 08:18:44.503] self_check_loaded_mv = 0
[2023-10-03 08:18:44.503] self_check_unloack_sessions = 1
[2023-10-03 08:18:44.503] webhooks_generatedrotocol] TRACE: message id 1691 complete with code 0.00
[2023-10-03 08:18:44.503] 0042032277 [comm.protocol] TRACE: rcv'd message = 0
[2023-10-03 08:18:44.503] webhook_bytes_generated = 0
[2023-10-03 08:18:44.520] webhooks_delivered = 0
[2023-10-03 08:18:44.520] self_check_watts = 0
[2023-10-03 08:18:44.520] self_check_loaded_mv = 0
[2023-10-03 08:18:44.520] self_check_unloack_sessions = 1
[2023-10-03 08:18:44.520] webhooks_generatedrotocol] TRACE: message id 1691 complete with code 0.00
[2023-10-03 08:18:44.520] 0042032277 [comm.protocol] TRACE: rcv'd message = 0
[2023-10-03 08:18:44.520] webhook_bytes_generated = 0
[2023-10-03 08:18:44.520] webhooks_delivered = 0
[2023-10-03 08:18:44.520] self_check_watts = 0
[2023-10-03 08:18:44.520] self_check_loaded_mv = 0
[2023-10-03 08:18:44.520] self_check_unloack_sessions = 1
[2023-10-03 08:18:44.520] webhooks_generatedrotocol] TRACE: message id 1691 complete with code 0.00
[2023-10-03 08:18:44.520] 0042032277 [comm.protocol] TRACE: rcv'd message = 0
[2023-10-03 08:18:44.520] webhook_bytes_generated = 0
[2023-10-03 08:18:44.520] webhooks_delivered = 0
[2023-10-03 08:18:44.520] self_check_watts = 0
[2023-10-03 08:18:44.520] self_check_loaded_mv = 0
[2023-10-03 08:18:44.520] self_check_unloack_sessions = 1
[2023-10-03 08:18:44.520] webhooks_generatedrotocol] TRACE: message id 1691 complete with code 0.00
[2023-10-03 08:18:44.520] 0042032277 [comm.protocol] TRACE: rcv'd message = 0
[2023-10-03 08:18:44.520] webhook_bytes_generated = 0
[2023-10-03 08:18:44.520] webhooks_delivered = 0
[2023-10-03 08:18:44.520] self_check_watts = 0
[2023-10-03 08:18:44.520] self_check_loaded_mv = 0
[2023-10-03 08:18:44.520] self_check_unloack_sessions = 1
[2023-10-03 08:18:44.520] webhooks_generatedrotocol] TRACE: message id 1691 complete with code 0.00
[2023-10-03 08:18:44.520] 0042032277 [comm.protocol] TRACE: rcv'd message = 0
[2023-10-03 08:18:44.534] webhook_bytes_generated = 0
[2023-10-03 08:18:44.534] webhooks_delivered = 0
[2023-10-03 08:18:44.534] self_check_watts = 0
[2023-10-03 08:18:44.534] self_check_loaded_mv = 0
[2023-10-03 08:18:44.534] self_check_unloack_sessions = 1
[2023-10-03 08:18:44.534] webhooks_generatedrotocol] TRACE: message id 1691 complete with code 0.00
[2023-10-03 08:18:44.534] 0042032277 [comm.protocol] TRACE: rcv'd message = 0
[2023-10-03 08:18:44.534] webhook_bytes_generated = 0
[2023-10-03 08:18:44.534] webhooks_delivered = 0
[2023-10-03 08:18:44.534] self_check_watts = 0
[2023-10-03 08:18:44.534] self_check_loaded_mv = 0
[2023-10-03 08:18:44.534] self_check_unloack_sessions = 1
[2023-10-03 08:18:44.534] webhooks_generatedrotocol] TRACE: message id 1691 complete with code 0.00
[2023-10-03 08:18:44.534] 0042032277 [comm.protocol] TRACE: rcv'd message = 0
[2023-10-03 08:18:44.534] webhook_bytes_generated = 0
[2023-10-03 08:18:44.534] webhooks_delivered = 0
[2023-10-03 08:18:44.534] self_check_watts = 0
[2023-10-03 08:18:44.534] self_check_loaded_mv = 0
[2023-10-03 08:18:44.534] self_check_unloack_sessions = 1
[2023-10-03 08:18:44.534] webhooks_generatedrotocol] TRACE: message id 1691 complete with code 0.00
[2023-10-03 08:18:44.534] 0042032277 [comm.protocol] TRACE: rcv'd message = 0
[2023-10-03 08:18:44.534] webhook_bytes_generated = 0
[2023-10-03 08:18:44.534] webhooks_delivered = 0
[2023-10-03 08:18:44.534] self_check_watts = 0
[2023-10-03 08:18:44.534] self_check_loaded_mv = 0
[2023-10-03 08:18:44.534] self_check_unloack_sessions = 1
[2023-10-03 08:18:44.534] webhooks_generatedrotocol] TRACE: message id 1691 complete with code 0.00
[2023-10-03 08:18:44.534] 0042032277 [comm.protocol] TRACE: rcv'd message = 0
[2023-10-03 08:18:44.564] webhook_bytes_generated = 0
[2023-10-03 08:18:44.564] webhooks_delivered = 0
[2023-10-03 08:18:44.564] self_check_watts = 0
[2023-10-03 08:18:44.564] self_check_loaded_mv = 0
[2023-10-03 08:18:44.564] self_check_unloack_sessions = 1
[2023-10-03 08:18:44.564] webhooks_generatedrotocol] TRACE: message id 1691 complete with code 0.00
[2023-10-03 08:18:44.564] 0042032277 [comm.protocol] TRACE: rcv'd message = 0
[2023-10-03 08:18:44.564] webhook_bytes_generated = 0
[2023-10-03 08:18:44.564] webhooks_delivered = 0
[2023-10-03 08:18:44.564] self_check_watts = 0
[2023-10-03 08:18:44.564] self_check_loaded_mv = 0
[2023-10-03 08:18:44.564] self_check_unloack_sessions = 1
[2023-10-03 08:18:44.564] webhooks_generatedrotocol] TRACE: message id 1691 complete with code 0.00
[2023-10-03 08:18:44.564] 0042032277 [comm.protocol] TRACE: rcv'd message = 0
[2023-10-03 08:18:44.564] webhook_bytes_generated = 0
[2023-10-03 08:18:44.564] webhooks_delivered = 0
[2023-10-03 08:18:44.564] self_check_watts = 0
[2023-10-03 08:18:44.564] self_check_loaded_mv = 0
[2023-10-03 08:18:44.564] self_check_unloack_sessions = 1
[2023-10-03 08:18:44.564] webhooks_generatedrotocol] TRACE: message id 1691 complete with code 0.00
The relevant spot in source code that matches the debug output in my app is here:
printHeaderBreak("Boss Heartbeat");
Serial.printlnf("tstamp_start = %s", getTimeStr(this->beat.tstamp_start));
Serial.printlnf(
"app_flags_sticky = 0X%08lx\n"
"page_erase_kb = %lu\n"
"reset_count = %lu\n"
"por_count = %lu\n"
"crash_count = %lu\n"
"pack_sessions = %lu\n"
"webhooks_generated = %lu\n"
"webhook_bytes_generated = %lu\n"
"webhooks_delivered = %lu\n"
"self_check_watts = %lu\n"
"self_check_loaded_mv = %lu\n"
"self_check_unloaded_mv = %lu\n"
,this->beat.app_flags_sticky.val
,this->beat.page_erase_kb
,this->beat.reset_count
,this->beat.por_count
,this->beat.crash_count
,this->beat.pack_sessions
,this->beat.webhooks_generated
,this->beat.webhook_bytes_generated
,this->beat.webhooks_delivered
,this->beat.self_check_watts
,this->beat.self_check_loaded_mv
,this->beat.self_check_unloaded_mv
);
Serial.flush();
(and so on... for 300 MB).
Pressing the reset button fixed everything.
I'm guessing that Particle OS is in fact not in factreceiving messages constantly as is implied, and that my application is not in fact repeatedly printing out the Serial.printlnf()
statement either.
Could this behavior be due to mixing of the Particle Logging class and the Serial class on the same USB peripheral? On the Serial.print vs. Log.info webpage it seems to indicate that bad things happen when you mix Serial and Logging together:
Serial is not thread-safe. It's possible that if you log simultaneously with both Serial and Logging calls, the device may crash.
I tried cloning the Particle OS repo on my local machine and doing some digging on the webhooks_generatedrotocol log messages but I couldn't find any matches. Expanding the search, a bit, it seems likely that this message comes from code that gets auto-generated by a python script during the build process....
Should I go through my whole app and replace all of the Serial.print statements with logging statements?