Open konacurrents opened 2 years ago
Please note in the future that this forum is for issues with the code in this repository, not issues with your code. esp32.com is a more open conversation about all manner of esp32 questions.
You say you are having problems with mqtt, but the errors quite directly point at Wire. My guess is that you have your data collection (from some I2C device) and data delivery intermingled. Separate them so that you have the data in hand before you make the network connection. That will reduce the possibility of timeouts and race conditions. It also makes it easier to add new collection and delivery processes. The more asynchronous you can make these steps, the more robust your application will be overall.
You can decode the backtrace you are getting to pin down exactly at what line in the code the error is occurring. I think you will see that it is happening while some device is polling the wire. See if there isn't a better driver for that device out there that is better suited for esp32 (or perhaps more recently updated).
Thanks for the reply and pointer to the backtrace debugging approach. I'll look into that.
I assumed that since the error I'm getting was not my code (like Wire) that this forum was appropriate.
Would you suggest that a data collection (like MQTT) - store that data, and release the interrupt, then in the next loop() process the message? That's what I ended up doing with BLE messages.
thanks.
Well, I separated the MQTT.loop which has an interrupt processor, from the actual processing of the received data after returning from the loop - and I get the same error. So I guess I have to go the backtrace route.
[ 50715][E][Wire.cpp:319] beginTransmission(): could not acquire lock
Did you initialize the wire correctly. I think something is wrong camera.
That M5 camera (on right in pic) is a self contained unit so there is no wiring on my part.
Its wireless... so where is the wire.h in use?
I assume the internals of the esp chip to the camera.
I just need a good approach to debug, which I haven't figured out on any of my esp projects.
Oh. I see now. I don't am exprenced engough with M5 stack. I can only point you in a direction what I think it could be it.
Did you check the freehap of the allocated memorie or maybe somthing is missing in your code that is needed to use the library. How long is the message you are sending to the MQTT? Sending small msg improves the performance.
Are you using this library?
/ PubSubClient.h - A simple client for MQTT. Nick O'Leary http://knolleary.net /
Then check these parameters in the MQTT library if they are valid for you application.
// MQTT_MAX_PACKET_SIZE : Maximum packet size. Override with setBufferSize().
#ifndef MQTT_MAX_PACKET_SIZE
#define MQTT_MAX_PACKET_SIZE 256
#endif
// MQTT_KEEPALIVE : keepAlive interval in Seconds. Override with setKeepAlive()
#ifndef MQTT_KEEPALIVE
#define MQTT_KEEPALIVE 15
#endif
// MQTT_SOCKET_TIMEOUT: socket timeout interval in Seconds. Override with setSocketTimeout()
#ifndef MQTT_SOCKET_TIMEOUT
#define MQTT_SOCKET_TIMEOUT 15
#endif
is this still valid?
Yes sadly I still get this issue.
Intresting. I am using now an other mqqt lib with events and I have the same issue.
assert failed: xQueueGenericSend queue.c:820 (pxQueue)
Here is what's strange, I change the build so it thinks it's an M5 without a camera, and the assert failure still happens. So it seems the internals of the M5Camera
acts slightly differently.
That said, it can send some MQTT messages depending on events.
I'll keep debugging to see if the thread wasn't released enough before the send. What works is receiving an MQTT message to take a picture, which then takes a picture, uploads to a web page, and sends out a URL of the result over MQTT.
After leaning how to get the stack track here it is:
assert failed: xQueueGenericSend queue.c:820 (pxQueue)
Decoding stack results
0x40084269: panic_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_system/panic.c line 402
0x40084269: panic_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_system/panic.c line 402
0x4009572d: esp_system_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_system/esp_system.c line 128
0x4009572d: esp_system_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_system/esp_system.c line 128
0x4009b37d: __assert_func at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/newlib/assert.c line 85
0x4009b37d: __assert_func at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/newlib/assert.c line 85
0x400961ca: xQueueGenericSend at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/queue.c line 820
0x400961ca: xQueueGenericSend at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/queue.c line 820
0x400e79f9: TwoWire::beginTransmission(unsigned short) at /Users/scott/Library/Arduino15/packages/m5stack/hardware/esp32/2.0.4/libraries/Wire/src/Wire.cpp line 315
0x400e7b68: TwoWire::beginTransmission(int) at /Users/scott/Library/Arduino15/packages/m5stack/hardware/esp32/2.0.4/libraries/Wire/src/Wire.cpp line 499
0x400e5f0f: AXP192::ReadBuff(unsigned char, unsigned char, unsigned char*) at /Users/scott/Documents/Arduino/libraries/M5StickCPlus/src/AXP192.cpp line 120
0x400e5f5d: AXP192::Read12Bit(unsigned char) at /Users/scott/Documents/Arduino/libraries/M5StickCPlus/src/AXP192.cpp line 67
0x400e5f5d: AXP192::Read12Bit(unsigned char) at /Users/scott/Documents/Arduino/libraries/M5StickCPlus/src/AXP192.cpp line 67
0x400e5f78: AXP192::GetBatVoltage() at /Users/scott/Documents/Arduino/libraries/M5StickCPlus/src/AXP192.cpp line 342
0x400e5f78: AXP192::GetBatVoltage() at /Users/scott/Documents/Arduino/libraries/M5StickCPlus/src/AXP192.cpp line 342
0x400dd9d5: getBatPercentage_mainModule() at /Users/scott/Documents/GitHub/ESP_IOT_BLE_AP_Testing/ESP_IOT/src/MainModule/MainModule.cpp line 1722
0x400dd9d5: getBatPercentage_mainModule() at /Users/scott/Documents/GitHub/ESP_IOT_BLE_AP_Testing/ESP_IOT/src/MainModule/MainModule.cpp line 1722
0x400ddb61: main_currentStatusURL(bool) at /Users/scott/Documents/GitHub/ESP_IOT_BLE_AP_Testing/ESP_IOT/src/MainModule/MainModule.cpp line 1986
0x400ddb61: main_currentStatusURL(bool) at /Users/scott/Documents/GitHub/ESP_IOT_BLE_AP_Testing/ESP_IOT/src/MainModule/MainModule.cpp line 1986
0x400de59a: invokeAsyncCommands() at /Users/scott/Documents/GitHub/ESP_IOT_BLE_AP_Testing/ESP_IOT/src/MainModule/MainModule.cpp line 1368
0x400d342b: loop() at /Users/scott/Documents/GitHub/ESP_IOT_BLE_AP_Testing/ESP_IOT/ESP_IOT.ino line 361
0x40104f85: loopTask(void*) at /User line 499
0x400e5f0f: AXP192::ReadBuff(unsigned char, unsigned char, unsigned char*) at /Users/scott/Documents/Arduino/libraries/M5StickCPlus/src/AXP192.cpp line 120
0x400e5f5d: AXP192::Read12Bit(unsigned char) at /Users/scott/Documents/Arduino/libraries/M5StickCPlus/src/AXP192.cpp line 67
0x400e5f5d: AXP192::Read12Bit(unsigned char) at /Users/scott/Documents/Arduino/libraries/M5StickCPlus/src/AXP192.cpp line 67
0x400e5f78: AXP192::GetBatVoltage() at /Users/scott/Documents/Arduino/libraries/M5StickCPlus/src/AXP192.cpp line 342
0x400e5f78: AXP192::GetBatVoltage() at /Users/scott/Documents/Arduino/libraries/M5StickCPlus/src/AXP192.cpp line 342
0x400dd9d5: getBatPercentage_mainModule() at /Users/scott/Documents/GitHub/ESP_IOT_BLE_AP_Testing/ESP_IOT/src/MainModule/MainModule.cpp line 1722
0x400dd9d5: getBatPercentage_mainModule() at /Users/scott/Documents/GitHub/ESP_IOT_BLE_AP_Testing/ESP_IOT/src/MainModule/MainModule.cpp line 1722
0x400ddb61: main_currentStatusURL(bool) at /Users/scott/Documents/GitHub/ESP_IOT_BLE_AP_Testing/ESP_IOT/src/MainModule/MainModule.cpp line 1986
0x400ddb61: main_currentStatusURL(bool) at /Users/scott/Documents/GitHub/ESP_IOT_BLE_AP_Testing/ESP_IOT/src/MainModule/MainModule.cpp line 1986
0x400de59a: invokeAsyncCommands() at /Users/scott/Documents/GitHub/ESP_IOT_BLE_AP_Testing/ESP_IOT/src/MainModule/MainModule.cpp line 1368
0x400d342b: loop() at /Users/scott/Documents/GitHub/ESP_IOT_BLE_AP_Testing/ESP_IOT/ESP_IOT.ino line 361
0x40104f85: loopTask(void*) at /Users/scott/Library/Arduino15/packages/m5stack/hardware/esp32/2.0.4/cores/esp32/main.cpp line 50
s/scott/Library/Arduino15/packages/m5stack/hardware/esp32/2.0.4/cores/esp32/main.cpp line 50
Decoding stack results
0x40084269: panic_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_system/panic.c line 402
0x40084269: panic_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_system/panic.c line 402
0x4009572d: esp_system_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_system/esp_system.c line 128
0x4009572d: esp_system_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_system/esp_system.c line 128
0x4009b37d: __assert_func at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/newlib/assert.c line 85
0x4009b37d: __assert_func at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/newlib/assert.c line 85
0x400961ca: xQueueGenericSend at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/queue.c line 820
0x400961ca: xQueueGenericSend at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/queue.c line 820
0x400e79f9: TwoWire::beginTransmission(unsigned short) at /Users/scott/Library/Arduino15/packages/m5stack/hardware/esp32/2.0.4/libraries/Wire/src/Wire.cpp line 315
0x400e7b68: TwoWire::beginTransmission(int) at /Users/scott/Library/Arduino15/packages/m5stack/hardware/esp32/2.0.4/libraries/Wire/src/Wire.cpp
Hello @konacurrents as Arduino Team, we are not really able to help here. Is your issue still relevant?
Board
M5Stack-Tiny-CAM
Device Description
Just the M5 Timer X.
Hardware Configuration
Nothing attached
(I don't know how to find the Arduino ESP32 version), but I assume it's the latest.
Version
v2.0.4
IDE Name
Arduino IDE 1.8.19
Operating System
maxOSx 12.4
Flash frequency
240mhz
PSRAM enabled
yes
Upload speed
115200
Description
Basically I have ESP code that works with ESP32 and the M5 chip nicely. It has BLE Server/Client, MQTT, WIFI, AP mode etc.
So I was successful compiling for the M5Stack-Tiny-CAM, and it receives MQTT messages from my network.
But for a couple of my messages, I get the
then it processes my MQTT message, then:
Previously ran in other threads
In some cases, my MQTT code was trying to use BLE messaging, and the thread /task had to be released, so that the BLEClient code could run (versus just calling that code).
In this case I don't see that issue.
Not happening on my other 2 builds. The errors above don't even show up.
Also the code doesn't even have to do anything, but the error still occurs:
Sketch
Debug Message
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide