[Gambas-user] Shared WiringPi library for RasPi
Benoît Minisini
gambas at ...1...
Sat May 25 21:35:17 CEST 2013
Le 25/05/2013 20:54, CJ a écrit :
>
>> What happens if there is no code at all inside the interrupt handler?
>
> The same thing.
>
>> Do you know in which context the interrupt handler is run? (signal
>> handler context? Something else?)
>
> Here is the response from wiringPi's author Gordon Henderson...
>
> The interrupt handler is a standard pthread process. The wiringPiISR code
> creates the thread and that thread then waits for the interrupt, then
> calls the ISR function - so the function called has to be "thread safe" -
> something I possibly ought to better document...
The interpreter cannot be run in another thread. This is the reason why
you get a crash.
Two possible solutions :
1) A pure Gambas solution. But that needs writing a component in C/C++
to implement an interrupt handler that would write to a pipe that would
be read by the main thread (the one that runs the Gambas interpreter).
2) Ask to the wiringPi's author to add a new function to handle the
interrupt (or modify the current one) that proceeds that way:
- Create an internal pipe.
- Create the thread.
- When an interrupt occurs, the thread writes a byte to the pipe.
- The function returns the file descriptor of the other side of the pipe.
That way, Gambas would just have to watch the file descriptor returned
by the new wiringPiISR function to know if an interrupt has occured.
Note that many other interpreters will be happy with that solution!
Regards,
--
Benoît Minisini
More information about the User
mailing list