[Gambas-user] Shared WiringPi library for RasPi

Benoît Minisini gambas at ...1...
Tue Apr 2 19:18:49 CEST 2013


Le 02/04/2013 16:53, Christer Johansson a écrit :
> Finally got some free time to get back into Gambas and I've been trying to
> get I/O interrupt to work on the Raspberry Pi.
>
> I made a simple CLI test program with the following code...
>
> MMain.Module
> ------------
>
> ' Gambas module file
>
> ' Setting up shared library wiringPi with bcm2835 pin naming
> Public Extern wiringPiSetupGpio() As Integer In "libwiringPi:1"
> Public Extern wiringPiISR(iPin As Integer, iEdgeType As Integer, pFunction
> As Pointer) As Integer In "libwiringPi:1"
>
> Public Sub Main()
>
>    ' Init library
>    If wiringPiSetupGpio() = 0 Then
>      Print "wiringPi Init OK..."
>    Else
>      Print "wiringPi Init Failed!"
>      Quit
>    Endif
>
>    ' Set up falling edge interrupt (1) on GPIO18 pin. Pin is connected to
> 3.3V via 10k pullup
>    wiringPiISR(18, 1, Class1.InterruptHandler)
>
>    ' Loop forever
>    Do
>      Wait 1
>      Print "Waiting...."
>    Loop
>
> End
>
> Class1.class
> ------------
>
> ' Gambas class file
>
> Export
>
> Static Public Function InterruptHandler() As Integer
>    Print "IRQ handler activated"
> End
>
> Code compiles OK but when I pull GPIO18 pin low (i.e generating the
> interrupt) it
> crashes with a "Stack overflow" error message. Without doubt it's me doing
> something wrong
> but after 2 days trying I wonder if anyone see what I'm missing??
>
> Attached is also a C example that uses the same library. Also if anyone is
> interested in the
> latest (130207) libwiringPi.so file just let me know and I will send it to
> the list...
>

Can you run your program through gdb to get the stack backtrace when you 
get the error?

That way:

$ cd /path/to/my/project
$ gdb gbx3
...
(gdb) break THROW
(gdb) run
...

And when the program breaks in the THROW function, it should be because 
of the stack overflow. Then you type:

(gdb) bt

Send me the result of that last command.

Regards,

-- 
Benoît Minisini




More information about the User mailing list