I wanted to try to control the GPIO from Gambas. I know that this can be done using file system reads and writes but I wanted to get control at a bit lower level.
The wiringPi C library written by Gordon looked like a good place to start. This takes the form of a /usr/local/lib/libwiringPi.a library and a /usr/local/include/wiringPi.h C include file.
Unfortunately Gambas3's external function definition won't work with a .a library. It needs a shared object .so library instead.
Not expecting it to work I ran the command ' gcc -shared -o libwiringPi.so *.o ' in the wiringPi source directory. To my surprise it produced a .so file with no errors displayed.
The file produced is here:- http://www.filedropper.com/libwiringpi
When this was used in a this Gambas test project http://www.filedropper.com/gpiotest
it worked as expected.
I am sure this is not a true .so file but for now it seems to work. Maybe someone with some more knowledge can produce a better one.
The test project drives 10 LEDs and monitors 5 switches. Everything seems to work just like the C version.
The only problem I had was that the wiringPi library can be configured to work with several pin numbering conventions. This is achieved by calling different setup functions. These in turn modify function pointers to point the published functions to the correct internal functions.
For example one of the published functions is digitalWrite() this is pointed at digitalWriteGpio() by the function wiringPiSetupGpio().
Gambas doesn't seem to be able to handle function pointers so it produced an error when I tried to use digitalWrite(). However using digitalWriteGpio() worked OK.
So far the following functions have been tested as working.
wiringPiSetupGpio() , pinModeGpio() , pullUpDnControlGpio(), digitalWriteGpio() , digitalReadGpio() all appear to work as they do in C.
Like most programs that talk directly to the hardware Gambas3 must be run from a root login to get this to work.
More later when I have had time to experiment some more...