Hello,
I have a requirement to use my own defined structure in the .api file. Somehow I am successfully doing this like below:
File: abc.api
REFERENCE Params;
FUNCTION Info(Params params OUT);
File: abcd.h
typedef struct {
//Common parameters
int32_t signal_strength;
int32_t temperature;
uint32_t level;
}abc_Params;
File: abcde.c
void abc_Info(abc_ParamsRef_t* params) {
//Here I can’t access the struct members
}
Could anyone please help
flu
July 11, 2018, 9:12am
2
Hello sowviroy
*.api files do not support structures
Solution #1:
Use different functions to pass the difference structure fields
Solution #2:
abc_Params myStruc;
Use le_event_Report ( myEvtId, & myStruc, sizeof ( myStruc ) );
KR.
Madan
October 25, 2018, 4:16am
3
I do need to use a structure in an API call.
Legato documentation shows there is a provision for STRUCT. But it is not recognised by compiler.
Wasnt it supposed to work?
davidc
October 25, 2018, 7:06am
4
Hiya,
API doesn’t support a struct as a ‘datatype’.
The struct
you see mentioned in the docs are just how the IPC library deals with references
- they’re actually an opaque data type that you treat as a void pointer.
This has caused me grief for a couple of years…
ciao, Dave
Kalai
September 16, 2021, 6:10am
5
hi any samples available how to use struct in user defined api.thanks in advance
Kalai
September 16, 2021, 10:35am
7
StructApi.tar.gz (3.0 KB)
am getting the following error, can u guide me how to pass input to the struct and my sample is attached for your refernce
Jan 6 10:27:00 swi-mdm9x28-wp user.info Legato: INFO | ClientCompExe[4274]/ClientComp T=main | ClientComp.c _ClientComp_COMPONENT_INIT() 17 | LOG_CLIENT> start
Jan 6 10:27:00 swi-mdm9x28-wp user.info Legato: INFO | ClientCompExe[4274]/ClientComp T=main | ClientComp.c _ClientComp_COMPONENT_INIT() 24 | LOG_CLIENT> make the request no 1 to server
Jan 6 10:27:00 swi-mdm9x28-wp user.info Legato: INFO | StructApiComponentExe[4273]/StructApiComponent T=main | StructApiComponent.c Sample_logMessage() 26 | LOG_SERVER> received the message “log from client : request no 1” from a client.
Jan 6 10:27:10 swi-mdm9x28-wp user.emerg Legato: EMR | ClientCompExe[4274]/framework T=main | Sample_client.c Sample_arraySend() 667 | Assert Failed: ‘Sample_PackARRAY123( &_msgBufPtr, &_msgBufSize, asdPtr )’
Jan 6 10:27:10 swi-mdm9x28-wp user.info Legato: INFO | supervisor[4058]/supervisor T=main | proc.c proc_SigChildHandler() 2051 | Process ‘ClientCompExe’ (PID: 4274) has exited with exit code 1.
Jan 6 10:27:10 swi-mdm9x28-wp user.warn Legato: -WRN- | supervisor[4058]/supervisor T=main | app.c app_SigChildHandler() 4031 | Process ‘ClientCompExe’ in app ‘StructApi’ faulted: Ignored.
jyijyi
September 16, 2021, 11:02am
8
Can yoy use the sample code in the link which is proven to be working fine
Kalai
September 16, 2021, 11:04am
9
i exactly use the same program but getting error , the only change made is instead of two app i used two component
jyijyi
September 16, 2021, 11:06am
10
How about just running my app with two app
Kalai
September 16, 2021, 11:28am
11
getting same error, dont know what am missing
jyijyi
September 16, 2021, 11:30am
12
Are you using swi-wp76_4.7.0