Hi, all. I need to code something very much like the gpioCf3Demo, but it needs to be a ‘legacy app’ to fit within the constraints of our current project’s build system. A colleague of mine wrote a CMake function that is supposed to handle this, but I’m having trouble seeing how it all fits together.
Reverse-engineering the CMake bits via some message()
calls, I see that his function is running the following command:
/opt/legato/bin/ifgen \
--gen-client \
--gen-interface \
--gen-local \
--gen-messages \
--gen-common-interface \
--gen-common-client \
/opt/legato/interfaces/le_gpio.api
This generates the following files:
$ ls -1 le_*.*
le_gpio_client.c
le_gpio_common.h
le_gpio_commonclient.c
le_gpio_interface.h
le_gpio_messages.h
le_gpio_service.h
The .c
files are compiled into the binary as described in Port Legacy C App. The CMake function also creates an .adef
file for the app that contains the following config blocks:
...
bindings:
{
*.le_gpioPin2 -> <root>.le_gpioPin2
*.le_gpioPin42 -> <root>.le_gpioPin42
}
...
extern:
{
requires:
{
le_gpioPin2 = /opt/legato/interfaces/le_gpio.api
le_gpioPin42 = /opt/legato/interfaces/le_gpio.api
}
}
...
(This is a partial listing, since the file is 92 lines long; I can provide the entire content if needed.)
My expectation from the .adef
file—and from studying the gpioCf3Demo
sample app—is that I should be able to call functions such as le_gpioPin2_Read()
, le_gpioPin42_IsActive()
, etc, to control the two desired GPIO pins. But these symbols are undefined:
Scanning dependencies of target systemmanagerservice
[ 66%] Building CXX object systemmanagerservice/CMakeFiles/systemmanagerservice.dir/src/gpiofuncs.cpp.o
/build/ivs_car/src/systemmanagerservice/src/gpiofuncs.cpp: In function 'int ivs::systemmanagerservice::gpio_read(int)':
/build/ivs_car/src/systemmanagerservice/src/gpiofuncs.cpp:39:12: error: 'le_gpioPin2_Read' was not declared in this scope
return le_gpioPin2_Read();
^~~~~~~~~~~~~~~~
/build/ivs_car/src/systemmanagerservice/src/gpiofuncs.cpp:39:12: note: suggested alternative: 'le_gpio_Read'
return le_gpioPin2_Read();
^~~~~~~~~~~~~~~~
le_gpio_Read
Erm… there’s a single le_gpio_Read()
function?? Which pin does it read—all of them? It doesn’t accept any arguments, so… I’m confused. Can anybody shed some light on what’s going wrong here? I’m very new to Legato, so I can’t tell whether:
- My expectations are simply incorrect
- The
ifgen
command run by my coleague’s CMake function is incorrect/incomplete - The
.adef
is incorrect/incomplete - Something else is wrong?
Any insights much appreciated—thank you!