Closed Risineo closed 4 years ago
I'm getting a similar thing when attempting to connect to a bluetooth classic OBD2 dongle.
Using platform IO: espressif32; board: esp32dev; framework: arduino. Have tried three different ESP32 boards. A Espressif Devkit C V4, a Tinypico and a DOIT Devkit v1. All show the same behaviour. Powering the boards from a Mac laptop over USB, also tried different USB cables and also tried from a USB power supply with no luck.
I get a guru meditation unhandled exception SW_CPU_RESET when the execution reaches
bool connected = SerialBT.connect(address);
. The complete code is here https://pastebin.com/S0em3wnD, the crash occurs at line 61.
Part of the code is executing as the LEDs on the OBD2 dongle flash (the host and the OBD LED).
Here's a screen grab of the crash
@patfelst decode the backtrace to narrow the cause further
Do you mean with this https://github.com/me-no-dev/EspExceptionDecoder ?
thanks I will try that on the weekend, I saw reference to that too, but will have to figure out how to use it.
@patfelst yes, if you add that plugin (or use one of the other command line versions) you can paste the Backtrace: XXXX line into the decoder and it should return the decoded details which should point to the specific lines in the code that are causing the LoadProhibited (which usually means a null dereference or out-of-memory condition)
Thanks @atanisoft that enabled me to solve the problem. Nothing to do with bluetooth, it was a sprintf %s being passed a char instead of a string. Enough to crash the micro!!
[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.
[STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions.
Hardware:
Board: lolin32 Core Installation 1.0.4 (PlatformIO calls it 1.12.0 , I assume it is 1.0.4) IDE name: PlatformIO inside VSCode, running the arduino-esp32 core Flash Frequency: 40Mhz PSRAM enabled: no Upload Speed: 115200 Computer OS: Windows 10
Description:
If the receiving module loses connection in the exact moment that the tranmitting module is trying to send data to it, the transmitting module will become unresponsive. The reason for the loss of connection seems to be of no importance (loss of power, reset, brown-out, etc.) In all instances the module has to be reset for it to reassume operation.
Sketch:
Both the master and slave side are basically copies of the SerialtoSerialBT examples. https://github.com/espressif/arduino-esp32/tree/idf-release/v4.0/libraries/BluetoothSerial/examples Only the master side is modified so it sends the 6 byte array in rapid succession.
Debug Messages:
debug_level=5 reveals:
and a couple of seconds later:
After that I have not been able to execute any further code.
I have also tried to implement checks on whether there is actually an active connection to the other side just before a message is transmitted, however all the functions the library offers, seem to be too unresponsive to allow for rapid data tranmission. I plan to set up one board to receive IR data in possibly rapid succession and to have it transmit that data to a second esp32 so it can execute commands and possibly send commands back to the first board that is equipped with the IR receivers.
If someone can offer advice on how I can successfully set up watchdogs to prevent the code from sending data when there is no connection, I would be most grateful aswell. Loss of some packages would be a minor problem, but having the entire mcu freeze up is of no use of course.