Hello everyone
new week new problem

I modified the siggen.c program to make it do other things and if I put it in the .hal file where I activate it
loadrt IOdecoder input=16 output=16
the program runs and does its job
but if I put different input output numbers, for example
input=16 output=32
when I open LINUXCNC it gives me the error
rtapi_app: caught signal 11-dumping core
and it turns off my threads
with equal numbers it always works
I'll put the parts where the component is created where I think the error is
Code:
static int input;
static int output;
RTAPI_MP_INT(input, "number input channels");
RTAPI_MP_INT(output, "number output channels");
#define MAX_INPUT 32
#define MAX_OUTPUT 32
typedef struct {
hal_bit_t *clock; /* pin: clock */
hal_bit_t *data; /* pin: data */
hal_bit_t *l_input; /* pin: latch input */
hal_bit_t *l_output; /* pin: latch output */
hal_bit_t *in_com; /* pin: input common */
hal_float_t *frequency; /* pin: frequency */
hal_float_t *debug; /* pin: debug */
hal_bit_t *in_bit[MAX_INPUT];
hal_bit_t *out_bit[MAX_OUTPUT];
double index; /* position within output cycle */
} hal_IOdecoder_t;
/* pointer to array of IOdecoder_t structs in shared memory, 1 per gen */
static hal_IOdecoder_t *IOdecoder_array;
/* other globals */
static int comp_id; /* component ID */
static int export_IOdecoder(int num, hal_IOdecoder_t * addr,char* prefix);
static void calc_IOdecoder(void *arg, long period);
int rtapi_app_main(void) {
int n, retval, i;
int howmany;
n=0;
/* have good config info, connect to the HAL */
comp_id = hal_init("IOdecoder");
if (comp_id < 0) {
rtapi_print_msg(RTAPI_MSG_ERR, "IOdecoder: ERROR: hal_init() failed\n");
return -1;
}
/* allocate shared memory for IOdecoder data */
howmany = 1;
IOdecoder_array = hal_malloc(howmany * sizeof(hal_IOdecoder_t));
if (IOdecoder_array == 0) {
rtapi_print_msg(RTAPI_MSG_ERR, "IOdecoder: ERROR: hal_malloc() failed\n");
hal_exit(comp_id);
return -1;
}
/* export variables and functions for each IOdecoder */
char buf[HAL_NAME_LEN + 1];
rtapi_snprintf(buf, sizeof(buf), "IOdecoder");
retval = export_IOdecoder(n, &;(IOdecoder_array[n]),buf);
rtapi_print_msg(RTAPI_MSG_INFO,
"IOdecoder: installed %d input and %d output\n", input, output);
hal_ready(comp_id);
return 0;
}
static int export_IOdecoder(int num, hal_IOdecoder_t * addr,char* prefix)
{
int retval; int i=0; /* export pins */
for (i = 0; i < input; i++) {
retval = hal_pin_bit_newf(HAL_OUT, &;(addr->in_bit[i]), comp_id, "%s.input.%02i", prefix, i);
if (retval != 0) {
return retval;
}
*(addr->in_bit[i]) = 0;
}
for (i = 0; i < output; i++) {
retval = hal_pin_bit_newf(HAL_IN, &;(addr->out_bit[i]), comp_id, "%s.output.%02i", prefix, i);
if (retval != 0) {
return retval;
}
*(addr->out_bit[i]) = 0;
}
/* export function for this loop */
char support[HAL_NAME_LEN + 1];
rtapi_snprintf(support, sizeof(support), "%s.update", prefix); retval = hal_export_funct(support, calc_IOdecoder, &;(IOdecoder_array[num]), 0, 0, comp_id);
if (retval != 0) {
rtapi_print_msg(RTAPI_MSG_ERR, "IOdecoder: ERROR: update funct export failed\n");
hal_exit(comp_id);
return -1;
}
return 0;
}
naturally there are other lines in the program... I only wrote these so as not to clog up the post too much... if you want I'll share the whole program[/i][/i][/i][/i]