erpc
erpc copied to clipboard
Structures definition on server side
Hello erpc team, as far as i understand, there is no need to declare struct on server side or client. Moreover if i define struct on server side i receive errors:
error: redefinition of ‘struct nested_t’
error: redefinition of ‘struct elements_t’
My structs defined on server side as follows:
`typedef struct elements_t elements_t;
struct elements_t
{
int8_t elem;
int8_t elem2;
int8_t *word;
};
typedef struct nested_t nested_t;
struct nested_t { elements_t struct1; elements_t struct2; };`
and in erpc file: `struct elements_t { int8 elem int8 elem2 byref int8 word }
struct nested_t { elements_t struct1 elements_t struct2 }` Is there any way to keep declaration of structure on server side? Thank you
Hello, if you don't want erpc to generate declarations, use @external annotation ;)
Thanks, it works. And i have another question. I have structure defined on server (not generated by erpc) an i want to call it on client using callback.
This is server code
void myFun2(const callback2_t pCallback2_in) { //cb2 = NULL; printf("Function for callback registry is done, starting to call the callback\n"); pCallback2_in(&nest); }
where nest
is object of defined on server struct, and this is client code
`void callback2(const nested_t *nest) {
printf("Hello callback\n");
printf("Hello from the callback - %d, %d, %s, %s\n", nest->struct1.elem, nest->struct2.elem, nest->struct1.word, nest->struct2.word);
}
TEST(test_arbitrator, FirstSendReceiveInt) { //int8_t result; //int8_t r = getNesterStruct(&result);
myFun2(callback2);
EXPECT_TRUE(1 == 1);
//EXPECT_TRUE((*result) == 2);
}` It works if i use generated struct by erpc, but when i try to make it work using struct defined on server i receive client code compilation errors like nested_t was not declared. Is there way to make it work? Thanks in advance
Hi @anakorenko , if you don't want use that structure on client side, then maybe include file in erpc IDL file where for client the file will contain structure definition with some body (not important implementation). In server the include file will contain include with structure definition.