rwmingis / InterruptButton

This is an interrupt based button event library for the ESP32. It enables binding user defined actions to button events including 'Key Down', Key Up' , 'Key Press', 'Long Key Press' 'AutoRepeat Press' and 'Double-Click'. The actions associated it these events may be executed Asynchronously, Synchronously, or a Hybrid between the two.
MIT License
30 stars 8 forks source link

Program crashes #15

Closed davidzhu210 closed 1 year ago

davidzhu210 commented 1 year ago

Hi I often encounter this issue and my ESp32 will reboot:

assert failed: xQueueGenericSend queue.c:832 (pxQueue->pcHead != ((void )0) || pxQueue->u.xSemaphore.xMutexHolder == ((void )0) || pxQueue->u.xSemaphore.xMutexHolder == xTaskGetCurrentTaskHandle())

Why?

rwmingis commented 1 year ago

Hi,

I have not seen this before, but haven't seen your code either so can't be sure. But 2 things come to mind.

  1. If your routine that you bind to the button is too big, i may be too much for the RTOS handler with the amount of stack reserved for this library. If you want to change it then modify this line in your instance of the library to set aside more memory:

https://github.com/rwmingis/InterruptButton/blob/2331071e14f82f9937dca66f1268496cb62a0a1a/InterruptButton.cpp#L39

I had it on my list to make this value user configurable when creating the object, just looks like I haven't quite gotten there yet.

  1. Potentially you could get crashes when deleting dynamically created instances of the interrupt button object, but I have put in some code to prevent this from happening if deleted mid-press say.

Let me know if either fixes your issue..

davidzhu210 commented 1 year ago

Thanks for the response. I will try again.

On Thu, Mar 2, 2023 at 6:19 AM rwmingis @.***> wrote:

Hi,

I have not seen this before, but haven't seen your code either so can't be sure. But 2 things come to mind.

  1. If your routine that you bind to the button is too big, i may be too much for the RTOS handler with the amount of stack reserved for this library. If you want to change it then modify this line in your instance of the library to set aside more memory:

https://github.com/rwmingis/InterruptButton/blob/2331071e14f82f9937dca66f1268496cb62a0a1a/InterruptButton.cpp#L39

I had it on my list to make this value user configurable when creating the object, just looks like I haven't quite gotten there yet.

  1. Potentially you could get crashes when deleting dynamically created instances of the interrupt button object, but I have put in some code to prevent this from happening if deleted mid-press say.

Let me know if either fixes your issue..

— Reply to this email directly, view it on GitHub https://github.com/rwmingis/InterruptButton/issues/15#issuecomment-1450931026, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALMASQ3MZC6QLNUDIG2S6VLWZ7DOFANCNFSM6AAAAAAVKLUPGI . You are receiving this because you authored the thread.Message ID: @.***>

-- Thanks, David