Error generating Java IPC code (le_gpio.api)


#1

I’m trying to use GPIO API.

cdef fragment:

requires:
{
	api:
	{
		NReset = le_gpio.api
	}
}

adef fragment:

bindings:
{
    fx30.App.NReset -> gpioService.le_gpioPin6
}

Compilation output:

mkapp -t wp85 -s /home/tm/dev/sv/legato-16.10.1//components fx30.adef
[2/7] Generating IPC interface code
FAILED: ifgen --output-dir _build_fx30/wp85/component/1a31e9fb59f731d0ec637c01634d85d0/src --lang Java --gen-client --name-prefix NReset --import-dir /home/tm/dev/sv/legato-16.10.1/interfaces --import-dir /home/tm/dev/sv/legato-16.10.1/framework/c/inc --import-dir /home/tm/dev/sv/fx30 /home/tm/dev/sv/legato-16.10.1/interfaces/le_gpio.api
Traceback (most recent call last):
  File "/home/tm/dev/sv/legato-16.10.1/bin/ifgen", line 287, in 
    Main()
  File "/home/tm/dev/sv/legato-16.10.1/bin/ifgen", line 279, in Main
    commandLib.RunCommand(args, data, importList, hashValue)
  File "/home/tm/dev/sv/legato-16.10.1/framework/tools/ifgen/langJava/commandLib.py", line 104, in RunCommand
    codeGen.WriteAllCode(args, importedCodeList, importedNameList, parsedCode, hashValue)
  File "/home/tm/dev/sv/legato-16.10.1/framework/tools/ifgen/langJava/codeGen.py", line 1433, in WriteAllCode
    WriteClientItem(clientFile, commandArgs.serviceName, codeItem)
  File "/home/tm/dev/sv/legato-16.10.1/framework/tools/ifgen/langJava/codeGen.py", line 1336, in WriteClientItem
    WriteClientEventFuncs(clientFile, apiName, codeItem)
  File "/home/tm/dev/sv/legato-16.10.1/framework/tools/ifgen/langJava/codeGen.py", line 1315, in WriteClientEventFuncs
    WriteClientAddEventFunction(clientFile, apiName, addFunc)
  File "/home/tm/dev/sv/legato-16.10.1/framework/tools/ifgen/langJava/codeGen.py", line 1222, in WriteClientAddEventFunction
    handlerName = "handle" + Types[handlerParam.pType].funcName
KeyError: 'int'
ninja: build stopped: subcommand failed.

After some research the problem is related to:

EVENT ChangeEvent
(
    Edge trigger IN,        ///< Change(s) that should trigger the callback to be called.
    ChangeCallback handler, ///< The callback function.
    int32 sampleMs          ///< If not interrupt capable, sample the input this often (ms).
);

in le_gpio.api.

Script codeGen.py assumes last param of EVENT is handler.

# --------------------------------------------------------------------------------------------------
# This will generate the code to request the server to register a client's event handler.
# --------------------------------------------------------------------------------------------------
def WriteClientAddEventFunction(clientFile, apiName, addFunc):

    WriteClientFunctionPreamble(clientFile, addFunc)

    # First off, pack up the normal parameters for this function.  We separate out the last one
    # because we deal with the event handler object specially.
    basicParams = addFunc.parmList[: -1]
    handlerParam = addFunc.parmList[-1]

Not sure where the mistake is. Error in codeGen.py or le_gpio.api? Anyway, I replaced order of parameters in le_gpio.api and it compiles, but I guess I won’t be able to register event handler due to mismatch.


#2

This is a bug in ifgen. Due to this and similar issues it is currently recommended to use JNI if you want to access Legato services from Java.