Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/hal/drivers/mesa-hostmot2/abs_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ int hm2_absenc_setup_ssi(hostmot2_t *hm2, hm2_sserial_remote_t *chan,
if ( hm2_sserial_create_pins(hm2, chan)) return -EINVAL;

chan->params = hal_malloc(sizeof(*chan->params));
if (chan->params == NULL) {
HM2_ERR("out of HAL memory allocating absenc params on %s\n", chan->name);
return -ENOMEM;
}
hm2->absenc.clock_frequency = md->clock_freq;
hm2->absenc.ssi_version = md->version;

Expand Down Expand Up @@ -170,6 +174,10 @@ int hm2_absenc_setup_biss(hostmot2_t *hm2, hm2_sserial_remote_t *chan,
if ( hm2_sserial_create_pins(hm2, chan)) return -EINVAL;

chan->params = hal_malloc(sizeof(*chan->params));
if (chan->params == NULL) {
HM2_ERR("out of HAL memory allocating absenc params on %s\n", chan->name);
return -ENOMEM;
}
hm2->absenc.clock_frequency = md->clock_freq;
hm2->absenc.biss_version = md->version;

Expand Down Expand Up @@ -201,6 +209,10 @@ int hm2_absenc_setup_fabs(hostmot2_t *hm2, hm2_sserial_remote_t *chan,
if ( hm2_sserial_create_pins(hm2, chan)) return -EINVAL;

chan->params = hal_malloc(sizeof(*chan->params));
if (chan->params == NULL) {
HM2_ERR("out of HAL memory allocating absenc params on %s\n", chan->name);
return -ENOMEM;
}
hm2->absenc.clock_frequency = md->clock_freq;
hm2->absenc.fanuc_version = md->version;

Expand Down
21 changes: 21 additions & 0 deletions src/hal/drivers/mesa-hostmot2/sserial.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,11 @@ int hm2_sserial_create_params(hostmot2_t *hm2, hm2_sserial_remote_t *chan){
int hal_dir;

chan->params = hal_malloc(chan->num_globals * sizeof(*chan->params));
if (chan->params == NULL && chan->num_globals > 0) {
HM2_ERR("out of HAL memory allocating %i sserial params on %s\n",
chan->num_globals, chan->name);
return -ENOMEM;
}
for (i = 0 ; i < chan->num_globals ; i++){
global = chan->globals[i];

Expand Down Expand Up @@ -1099,6 +1104,11 @@ int hm2_sserial_create_pins(hostmot2_t *hm2, hm2_sserial_remote_t *chan){
int r = 0;
int data_dir;
chan->pins = hal_malloc(chan->num_confs * sizeof(*chan->pins));
if (chan->pins == NULL && chan->num_confs > 0) {
HM2_ERR("out of HAL memory allocating %i sserial pin sets on %s\n",
chan->num_confs, chan->name);
return -ENOMEM;
}

chan->num_read_bits = 0 ; chan->num_write_bits = 0;

Expand Down Expand Up @@ -1153,6 +1163,12 @@ int hm2_sserial_create_pins(hostmot2_t *hm2, hm2_sserial_remote_t *chan){
chan->pins[i].bit_pins = hal_malloc(chan->confs[i].DataLength * sizeof(*chan->pins[i].bit_pins));
chan->pins[i].bit_pins_not = hal_malloc(chan->confs[i].DataLength * sizeof(*chan->pins[i].bit_pins_not));
chan->pins[i].invert = hal_malloc(chan->confs[i].DataLength * sizeof(*chan->pins[i].invert));
if ((chan->pins[i].bit_pins == NULL || chan->pins[i].bit_pins_not == NULL
|| chan->pins[i].invert == NULL) && chan->confs[i].DataLength > 0) {
HM2_ERR("out of HAL memory allocating %i bit pins on %s.%s\n",
chan->confs[i].DataLength, chan->name, chan->confs[i].NameString);
return -ENOMEM;
}
for (j = 0; j < chan->confs[i].DataLength ; j++){

r = hal_pin_new_bool(hm2->llio->comp_id, data_dir, &(chan->pins[i].bit_pins[j]),
Expand Down Expand Up @@ -1238,6 +1254,11 @@ int hm2_sserial_create_pins(hostmot2_t *hm2, hm2_sserial_remote_t *chan){
}
if (data_dir == HAL_IN) {
chan->pins[i].invert = hal_malloc(sizeof(*chan->pins[i].invert));
if (chan->pins[i].invert == NULL) {
HM2_ERR("out of HAL memory allocating invert param on %s.%s\n",
chan->name, chan->confs[i].NameString);
return -ENOMEM;
}
r = hal_param_new_bool(hm2->llio->comp_id, HAL_RW, chan->pins[i].invert,
0, "%s.%s-invert", chan->name, chan->confs[i].NameString);
if (r < 0) {
Expand Down
Loading