epsilonrt / piduino

Arduino API on Pi boards, the best of both worlds !
https://epsilonrt.fr/2019/01/piduino/
GNU Lesser General Public License v3.0
29 stars 7 forks source link

Using Console in a GPIO interrupt service routine #3

Closed epsilonrt closed 5 years ago

epsilonrt commented 5 years ago

Using the Console object in an interrupt routine causes an exception when the program stops : ^C everything was closed. Have a nice day ! pure virtual method called terminate called without an active exception Abandon

epsilonrt commented 5 years ago

Problem related to stopping the terminal and GPIO threads. to do as soon as possible.

epsilonrt commented 5 years ago

As we can see below, the thread of the GPIO pin ends after the closing of the GPIO which is not normal: 11315: 1 150: 0 150: 1 151: 0 150: 1 150: 0 150: 1 150: 0 150: 1 150: 0 150: 1 150: 0 150: 1 150: 0 151: 1 150: 0 158: 1 142: 0 150: 1 150: 0 150: 1 150: 0 151: 1 ^C everything was closed. Have a nice day ! 200: 0

irqThread terminated

epsilonrt commented 5 years ago

The root of the problem is that closing a GPIO pin does not stop the polling thread. You must terminate the thread at the time of closing and not at the time of deletion.