I have been having problems making swig work for the following:
In C i have:
typedef struct
{
uint8_t a[16];
uint8_t b;
uint8_t c;
uint8_t d;
uint8_t e;
uint8_t f;
}t_type2;
typedef struct
{
uint8_t a[16];
uint8_t b;
uint8_t c;
uint8_t d;
t_type2 ch[10];
uint8_t e;
}t_type1;
And i have a function that has prototype:
t_dtbt_uint8 test_func(t_type1 **types);
It return an array to an internal data buffer containing an array of "t_type1".
I can make a typedef that returns the services correctly so in python i can do:
err, types = test_wrap.test_func()
But i simply cannot get "types" to contain anything valid.
Anyone know how to do this?
I have looked at tons of other examples, but no matter what i do i end up in errors and crashes.
I have tried this without success:
%typemap(in, numinputs=0) t_type1 **types_result(t_type1 *temp) {$1= &temp;}
%typemap(argout) t_type1 **types
{
$result = SWIG_Python_AppendOutput ($result, SWIG_NewPointerObj(*$1, WIGTYPE_p_p_t_type1, 0 | 0 ));
}
and wrapper function:
uint8_t test_func_wrapper(t_type1 **types_result)
{
int err = test_func(types_result);
return err;
}
It compiles fine, but I simply cannot find the right combination to make it work. I use similar constructions for simpler types, but for this I cannot make it work.
As soon as i access the array in Python i get a sigfault, or a iteration error. I am sure there is a way to do this...
Thanks,
/pedro
Tried all examples i could find, but none seemed to work for my purpose.