From 8e9bfb813eef0398ed699ea4205a9f386cf27506 Mon Sep 17 00:00:00 2001 From: Bertho Stultiens Date: Mon, 23 Nov 2026 14:55:44 +0100 Subject: [PATCH] hal: Update VFD drivers to be 64-bit clean. --- src/hal/user_comps/gs2_vfd.c | 34 ++++++++++---------- src/hal/user_comps/huanyang-vfd/hy_vfd.c | 32 +++++++++---------- src/hal/user_comps/hy_gt_vfd.c | 24 +++++++------- src/hal/user_comps/svd-ps_vfd.c | 10 +++--- src/hal/user_comps/vfdb_vfd/vfdb_vfd.c | 28 ++++++++--------- src/hal/user_comps/vfs11_vfd/vfs11_vfd.c | 40 ++++++++++++------------ 6 files changed, 84 insertions(+), 84 deletions(-) diff --git a/src/hal/user_comps/gs2_vfd.c b/src/hal/user_comps/gs2_vfd.c index e1c489a3447..c9ec322f643 100644 --- a/src/hal/user_comps/gs2_vfd.c +++ b/src/hal/user_comps/gs2_vfd.c @@ -167,7 +167,7 @@ static void quit(int sig) { done = 1; } -static int comm_delay = 0; // JET delay counter for at-speed +static rtapi_sint comm_delay = 0; // JET delay counter for at-speed int match_string(char *string, char **matches) { size_t len; @@ -394,17 +394,17 @@ int write_data(modbus_t *mb_ctx, slavedata_t *slavedata, haldata_t *haldata) { modbus_write_register(mb_ctx, slavedata->write_reg_start+4, 0); haldata->old_err_reset = err_reset; } - if (comm_delay < hal_get_si32(haldata->ack_delay)){ // JET allow time for communications between drive and EMC + if (comm_delay < hal_get_sint(haldata->ack_delay)){ // JET allow time for communications between drive and EMC comm_delay++; } - if (spindle_on && comm_delay == hal_get_si32(haldata->ack_delay)){ // JET test for up to speed + if (spindle_on && comm_delay == hal_get_sint(haldata->ack_delay)){ // JET test for up to speed if (hal_get_real(haldata->freq_cmd) == hal_get_real(haldata->freq_out)) hal_set_bool(haldata->at_speed, 1); } if (!spindle_on){ // JET reset at-speed hal_set_bool(haldata->at_speed, 0); } - hal_set_si32(haldata->retval, retval); + hal_set_sint(haldata->retval, retval); return retval; } @@ -464,16 +464,16 @@ int read_data(modbus_t *mb_ctx, slavedata_t *slavedata, haldata_t *hal_data_bloc return -1; /* but we can signal an error if the other params are null */ if ((mb_ctx==NULL) || (slavedata == NULL)) { - hal_set_si32(hal_data_block->errorcount, hal_get_si32(hal_data_block->errorcount) + 1); + hal_set_sint(hal_data_block->errorcount, hal_get_sint(hal_data_block->errorcount) + 1); return -1; } retval = modbus_read_registers(mb_ctx, slavedata->read_reg_start, slavedata->read_reg_count, receive_data); if (retval==slavedata->read_reg_count) { retval = 0; - hal_set_si32(hal_data_block->retval, retval); - hal_set_si32(hal_data_block->stat1, receive_data[0]); - hal_set_si32(hal_data_block->stat2, receive_data[1]); + hal_set_sint(hal_data_block->retval, retval); + hal_set_sint(hal_data_block->stat1, receive_data[0]); + hal_set_sint(hal_data_block->stat2, receive_data[1]); hal_set_real(hal_data_block->freq_cmd, receive_data[2] * 0.1); hal_set_real(hal_data_block->freq_out, receive_data[3] * 0.1); if (receive_data[3]==0) { // JET if freq out is 0 then the drive is stopped @@ -488,10 +488,10 @@ int read_data(modbus_t *mb_ctx, slavedata_t *slavedata, haldata_t *hal_data_bloc hal_set_real(hal_data_block->scale_freq, (receive_data[8] | (receive_data[9] << 16)) * 0.1); hal_set_real(hal_data_block->power_factor, receive_data[10]); hal_set_real(hal_data_block->load_pct, receive_data[11] * 0.1); - hal_set_si32(hal_data_block->FW_Rev, receive_data[12]); + hal_set_sint(hal_data_block->FW_Rev, receive_data[12]); } else { - hal_set_si32(hal_data_block->retval, retval); - hal_set_si32(hal_data_block->errorcount, hal_get_si32(hal_data_block->errorcount) + 1); + hal_set_sint(hal_data_block->retval, retval); + hal_set_sint(hal_data_block->errorcount, hal_get_sint(hal_data_block->errorcount) + 1); retval = -1; } return retval; @@ -686,9 +686,9 @@ int main(int argc, char **argv) goto out_close; } - retval = hal_pin_new_si32(hal_comp_id, HAL_OUT, &(haldata->stat1), 0, "%s.status-1", modname); + retval = hal_pin_new_sint(hal_comp_id, HAL_OUT, &(haldata->stat1), 0, "%s.status-1", modname); if (retval!=0) goto out_closeHAL; - retval = hal_pin_new_si32(hal_comp_id, HAL_OUT, &(haldata->stat2), 0, "%s.status-2", modname); + retval = hal_pin_new_sint(hal_comp_id, HAL_OUT, &(haldata->stat2), 0, "%s.status-2", modname); if (retval!=0) goto out_closeHAL; retval = hal_pin_new_real(hal_comp_id, HAL_OUT, &(haldata->freq_cmd), 0.0, "%s.frequency-command", modname); if (retval!=0) goto out_closeHAL; @@ -708,13 +708,13 @@ int main(int argc, char **argv) if (retval!=0) goto out_closeHAL; retval = hal_pin_new_real(hal_comp_id, HAL_OUT, &(haldata->load_pct), 0.0, "%s.load-percentage", modname); if (retval!=0) goto out_closeHAL; - retval = hal_pin_new_si32(hal_comp_id, HAL_OUT, &(haldata->FW_Rev), 0, "%s.firmware-revision", modname); + retval = hal_pin_new_sint(hal_comp_id, HAL_OUT, &(haldata->FW_Rev), 0, "%s.firmware-revision", modname); if (retval!=0) goto out_closeHAL; - retval = hal_param_new_si32(hal_comp_id, HAL_RW, &(haldata->errorcount), 0, "%s.error-count", modname); + retval = hal_param_new_sint(hal_comp_id, HAL_RW, &(haldata->errorcount), 0, "%s.error-count", modname); if (retval!=0) goto out_closeHAL; retval = hal_param_new_real(hal_comp_id, HAL_RW, &(haldata->looptime), 0.1, "%s.loop-time", modname); if (retval!=0) goto out_closeHAL; - retval = hal_param_new_si32(hal_comp_id, HAL_RW, &(haldata->retval), 0, "%s.retval", modname); + retval = hal_param_new_sint(hal_comp_id, HAL_RW, &(haldata->retval), 0, "%s.retval", modname); if (retval!=0) goto out_closeHAL; retval = hal_pin_new_bool(hal_comp_id, HAL_OUT, &(haldata->at_speed), 0, "%s.at-speed", modname); if (retval!=0) goto out_closeHAL; @@ -736,7 +736,7 @@ int main(int argc, char **argv) if (retval!=0) goto out_closeHAL; retval = hal_param_new_real(hal_comp_id, HAL_RW, &(haldata->motor_RPM), 1730, "%s.nameplate-RPM", modname); if (retval!=0) goto out_closeHAL; - retval = hal_param_new_si32(hal_comp_id, HAL_RW, &(haldata->ack_delay), 2, "%s.ack-delay", modname); + retval = hal_param_new_sint(hal_comp_id, HAL_RW, &(haldata->ack_delay), 2, "%s.ack-delay", modname); if (retval!=0) goto out_closeHAL; /* define run (enable) pin and isInitialized */ retval = hal_pin_new_bool(hal_comp_id, HAL_IN, &(haldata->ena_gs2comp), enabled, "%s.enable", modname); diff --git a/src/hal/user_comps/huanyang-vfd/hy_vfd.c b/src/hal/user_comps/huanyang-vfd/hy_vfd.c index 2831d6c60fd..b1c8623addd 100644 --- a/src/hal/user_comps/huanyang-vfd/hy_vfd.c +++ b/src/hal/user_comps/huanyang-vfd/hy_vfd.c @@ -320,15 +320,15 @@ int write_data(hycomm_param_t *hc_param, hycomm_data_t *hc_data, haldata_t *hald hal_set_bool(haldata->CNST_Track_Start, (CNST & CONTROL_Track_Start) != 0); retval = 0; - hal_set_ui32(haldata->retval, retval); + hal_set_uint(haldata->retval, retval); return retval; failed: if (hc_param->debug) { printf("write_data: FAILED\n"); } - hal_set_ui32(haldata->retval, retval); - hal_set_si32(haldata->errorcount, hal_get_si32(haldata->errorcount) + 1); + hal_set_uint(haldata->retval, retval); + hal_set_sint(haldata->errorcount, hal_get_sint(haldata->errorcount) + 1); retval = -1; return retval; @@ -344,7 +344,7 @@ int read_setup(hycomm_param_t *hc_param, hycomm_data_t *hc_data, haldata_t *hald return -1; /* but we can signal an error if the other params are null */ if (hc_param==NULL) { - hal_set_si32(haldata->errorcount, hal_get_si32(haldata->errorcount) + 1); + hal_set_sint(haldata->errorcount, hal_get_sint(haldata->errorcount) + 1); return -1; } @@ -441,10 +441,10 @@ int read_setup(hycomm_param_t *hc_param, hycomm_data_t *hc_data, haldata_t *hald hal_set_real(haldata->rated_motor_current, hc_data->ret_data * 0.1); hc_data->parameter = 143; // PD143 Number of Motor Poles - if (hal_get_ui32(haldata->motor_poles) != 0) { + if (hal_get_uint(haldata->motor_poles) != 0) { // user passed in motor poles, send to VFD hc_data->function = FUNCTION_WRITE; - hc_data->data = (uint16_t)hal_get_ui32(haldata->motor_poles); + hc_data->data = (uint16_t)hal_get_uint(haldata->motor_poles); if ((retval = hy_comm(hc_param, hc_data)) != 0) { goto failed; } @@ -452,7 +452,7 @@ int read_setup(hycomm_param_t *hc_param, hycomm_data_t *hc_data, haldata_t *hald } if ((retval = hy_comm(hc_param, hc_data)) != 0) goto failed; - hal_set_ui32(haldata->motor_poles, hc_data->ret_data); + hal_set_uint(haldata->motor_poles, hc_data->ret_data); hc_data->parameter = 144; // PD144 Rated Motor Rev (at 50 Hz) if (hal_get_real(haldata->rated_motor_rev) != 0) { @@ -495,15 +495,15 @@ int read_setup(hycomm_param_t *hc_param, hycomm_data_t *hc_data, haldata_t *hald fflush(NULL); retval = 0; - hal_set_ui32(haldata->retval, retval); + hal_set_uint(haldata->retval, retval); return retval; failed: if (hc_param->debug) { printf("read_setup: FAILED\n"); } - hal_set_ui32(haldata->retval, retval); - hal_set_si32(haldata->errorcount, hal_get_si32(haldata->errorcount) + 1); + hal_set_uint(haldata->retval, retval); + hal_set_sint(haldata->errorcount, hal_get_sint(haldata->errorcount) + 1); retval = -1; return retval; @@ -610,15 +610,15 @@ int read_data(hycomm_param_t *hc_param, hycomm_data_t *hc_data, haldata_t *halda retval = 0; - hal_set_ui32(haldata->retval, retval); + hal_set_uint(haldata->retval, retval); return retval; failed: if (hc_param->debug) { printf("read_data: FAILED\n"); } - hal_set_ui32(haldata->retval, retval); - hal_set_si32(haldata->errorcount, hal_get_si32(haldata->errorcount) + 1); + hal_set_uint(haldata->retval, retval); + hal_set_sint(haldata->errorcount, hal_get_sint(haldata->errorcount) + 1); retval = -1; return retval; @@ -915,16 +915,16 @@ int main(int argc, char **argv) if (retval!=0) goto out_closeHAL; retval = hal_pin_new_real(hal_comp_id, HAL_OUT, &(haldata->rated_motor_rev), motor_speed, "%s.rated-motor-rev", modname); if (retval!=0) goto out_closeHAL; - retval = hal_pin_new_ui32(hal_comp_id, HAL_OUT, &(haldata->motor_poles), motor_poles, "%s.motor-poles", modname); + retval = hal_pin_new_uint(hal_comp_id, HAL_OUT, &(haldata->motor_poles), motor_poles, "%s.motor-poles", modname); if (retval!=0) goto out_closeHAL; retval = hal_pin_new_bool(hal_comp_id, HAL_OUT, &(haldata->hycomm_ok), 0, "%s.hycomm-ok", modname); if (retval!=0) goto out_closeHAL; - retval = hal_pin_new_si32(hal_comp_id, HAL_OUT, &(haldata->errorcount), 0, "%s.error-count", modname); + retval = hal_pin_new_sint(hal_comp_id, HAL_OUT, &(haldata->errorcount), 0, "%s.error-count", modname); if (retval!=0) goto out_closeHAL; - retval = hal_pin_new_ui32(hal_comp_id, HAL_OUT, &(haldata->retval), 0, "%s.retval", modname); + retval = hal_pin_new_uint(hal_comp_id, HAL_OUT, &(haldata->retval), 0, "%s.retval", modname); if (retval!=0) goto out_closeHAL; retval = hal_pin_new_real(hal_comp_id, HAL_OUT, &(haldata->spindle_speed_fb), 0.0, "%s.spindle-speed-fb", modname); diff --git a/src/hal/user_comps/hy_gt_vfd.c b/src/hal/user_comps/hy_gt_vfd.c index 09214f8058e..ef876d4e4a1 100644 --- a/src/hal/user_comps/hy_gt_vfd.c +++ b/src/hal/user_comps/hy_gt_vfd.c @@ -66,8 +66,8 @@ typedef struct { float multiplier; int type; union { - hal_real_t hal_pin_float; - hal_uint_t hal_pin_u32; + hal_real_t hal_pin_real; + hal_uint_t hal_pin_uint; }; } modbus_register_t; @@ -207,7 +207,7 @@ int set_motor_on_forward(modbus_t *mb) { return 0; } fprintf(stderr, "%s: error writing %u to register 0x%04x: %s\n", __func__, val, addr, modbus_strerror(errno)); - hal_set_ui32(haldata->modbus_errors, hal_get_ui32(haldata->modbus_errors) + 1); + hal_set_uint(haldata->modbus_errors, hal_get_uint(haldata->modbus_errors) + 1); } return -1; } @@ -225,7 +225,7 @@ int set_motor_off(modbus_t *mb) { return 0; } fprintf(stderr, "%s: error writing %u to register 0x%04x: %s\n", __func__, val, addr, modbus_strerror(errno)); - hal_set_ui32(haldata->modbus_errors, hal_get_ui32(haldata->modbus_errors) + 1); + hal_set_uint(haldata->modbus_errors, hal_get_uint(haldata->modbus_errors) + 1); } return -1; } @@ -244,7 +244,7 @@ int set_motor_frequency(modbus_t *mb, float freq) { return 0; } fprintf(stderr, "%s: error writing %u to register 0x%04x: %s\n", __func__, val, addr, modbus_strerror(errno)); - hal_set_ui32(haldata->modbus_errors, hal_get_ui32(haldata->modbus_errors) + 1); + hal_set_uint(haldata->modbus_errors, hal_get_uint(haldata->modbus_errors) + 1); } return -1; } @@ -260,16 +260,16 @@ int read_modbus_register(modbus_t *mb, modbus_register_t *reg) { if (r == 1) { switch (reg->type) { case REGISTER_FLOAT: - hal_set_real(reg->hal_pin_float, data * reg->multiplier); + hal_set_real(reg->hal_pin_real, data * reg->multiplier); break; case REGISTER_U32: - hal_set_ui32(reg->hal_pin_u32, data); + hal_set_uint(reg->hal_pin_uint, data); break; } return 0; } fprintf(stderr, "%s: error reading %s (register 0x%04x): %s\n", __func__, reg->name, reg->address, modbus_strerror(errno)); - hal_set_ui32(haldata->modbus_errors, hal_get_ui32(haldata->modbus_errors) + 1); + hal_set_uint(haldata->modbus_errors, hal_get_uint(haldata->modbus_errors) + 1); } return -1; } @@ -289,7 +289,7 @@ modbus_register_t *add_modbus_register_float(modbus_t *mb, int address, const ch reg = &modbus_register[num_modbus_registers]; reg->type = REGISTER_FLOAT; - r = hal_pin_new_real(hal_comp_id, HAL_OUT, ®->hal_pin_float, 0.0, "%s.%s", modname, pin_name); + r = hal_pin_new_real(hal_comp_id, HAL_OUT, ®->hal_pin_real, 0.0, "%s.%s", modname, pin_name); if (r != 0) { return NULL; } @@ -314,7 +314,7 @@ modbus_register_t *add_modbus_register_u32(modbus_t *mb, int address, const char reg = &modbus_register[num_modbus_registers]; reg->type = REGISTER_U32; - r = hal_pin_new_ui32(hal_comp_id, HAL_OUT, ®->hal_pin_u32, 0, "%s.%s", modname, pin_name); + r = hal_pin_new_uint(hal_comp_id, HAL_OUT, ®->hal_pin_uint, 0, "%s.%s", modname, pin_name); if (r != 0) { return NULL; } @@ -586,7 +586,7 @@ int main(int argc, char **argv) { retval = hal_pin_new_bool(hal_comp_id, HAL_IN, &(haldata->spindle_on), 0, "%s.spindle-on", modname); if (retval != 0) goto out_closeHAL; - retval = hal_pin_new_ui32(hal_comp_id, HAL_OUT, &(haldata->modbus_errors), 0, "%s.modbus-errors", modname); + retval = hal_pin_new_uint(hal_comp_id, HAL_OUT, &(haldata->modbus_errors), 0, "%s.modbus-errors", modname); if (retval != 0) goto out_closeHAL; modbus_register = (modbus_register_t *)hal_malloc(20 * sizeof(*modbus_register)); @@ -672,7 +672,7 @@ int main(int argc, char **argv) { hal_set_real(haldata->freq_cmd, (speed_cmd / motor_max_speed) * max_freq); set_motor_frequency(mb, hal_get_real(haldata->freq_cmd)); - hal_set_bool(haldata->at_speed, (fabs(speed_cmd - hal_get_real(speed_fb_reg->hal_pin_float)) / speed_cmd) < 0.02); + hal_set_bool(haldata->at_speed, (fabs(speed_cmd - hal_get_real(speed_fb_reg->hal_pin_real)) / speed_cmd) < 0.02); } else { set_motor_off(mb); hal_set_bool(haldata->at_speed, 0); diff --git a/src/hal/user_comps/svd-ps_vfd.c b/src/hal/user_comps/svd-ps_vfd.c index 43beebcf856..3a455526978 100644 --- a/src/hal/user_comps/svd-ps_vfd.c +++ b/src/hal/user_comps/svd-ps_vfd.c @@ -190,7 +190,7 @@ int set_motor_on_forward(modbus_t *mb) { return 0; } fprintf(stderr, "%s: error writing %u to register 0x%04x: %s\n", __func__, val, addr, modbus_strerror(errno)); - hal_set_ui32(haldata->modbus_errors, hal_get_ui32(haldata->modbus_errors) + 1); + hal_set_uint(haldata->modbus_errors, hal_get_uint(haldata->modbus_errors) + 1); } return -1; } @@ -207,7 +207,7 @@ int set_motor_off(modbus_t *mb) { return 0; } fprintf(stderr, "%s: error writing %u to register 0x%04x: %s\n", __func__, val, addr, modbus_strerror(errno)); - hal_set_ui32(haldata->modbus_errors, hal_get_ui32(haldata->modbus_errors) + 1); + hal_set_uint(haldata->modbus_errors, hal_get_uint(haldata->modbus_errors) + 1); } return -1; } @@ -226,7 +226,7 @@ int set_motor_frequency(modbus_t *mb, float freq) { return 0; } fprintf(stderr, "%s: error writing %u to register 0x%04x: %s\n", __func__, val, addr, modbus_strerror(errno)); - hal_set_ui32(haldata->modbus_errors, hal_get_ui32(haldata->modbus_errors) + 1); + hal_set_uint(haldata->modbus_errors, hal_get_uint(haldata->modbus_errors) + 1); } return -1; } @@ -244,7 +244,7 @@ int read_modbus_register(modbus_t *mb, modbus_register_t *reg) { return 0; } fprintf(stderr, "%s: error reading %s (register 0x%04x): %s\n", __func__, reg->name, reg->address, modbus_strerror(errno)); - hal_set_ui32(haldata->modbus_errors, hal_get_ui32(haldata->modbus_errors) + 1); + hal_set_uint(haldata->modbus_errors, hal_get_uint(haldata->modbus_errors) + 1); } return -1; } @@ -535,7 +535,7 @@ int main(int argc, char **argv) { retval = hal_pin_new_bool(hal_comp_id, HAL_IN, &(haldata->spindle_on), 0, "%s.spindle-on", modname); if (retval != 0) goto out_closeHAL; - retval = hal_pin_new_ui32(hal_comp_id, HAL_OUT, &(haldata->modbus_errors), 0, "%s.modbus-errors", modname); + retval = hal_pin_new_uint(hal_comp_id, HAL_OUT, &(haldata->modbus_errors), 0, "%s.modbus-errors", modname); if (retval != 0) goto out_closeHAL; modbus_register = (modbus_register_t *)hal_malloc(20 * sizeof(modbus_register_t)); diff --git a/src/hal/user_comps/vfdb_vfd/vfdb_vfd.c b/src/hal/user_comps/vfdb_vfd/vfdb_vfd.c index 962a753a399..e9a8c3f4cc3 100644 --- a/src/hal/user_comps/vfdb_vfd/vfdb_vfd.c +++ b/src/hal/user_comps/vfdb_vfd/vfdb_vfd.c @@ -225,8 +225,8 @@ static struct option long_options[] = { void windup(param_pointer p) { - if (p->haldata && hal_get_si32(p->haldata->errorcount)) { - fprintf(stderr,"%s: %d modbus errors\n",p->progname, hal_get_si32(p->haldata->errorcount)); + if (p->haldata && hal_get_sint(p->haldata->errorcount)) { + fprintf(stderr,"%s: %ld modbus errors\n",p->progname, (long)hal_get_sint(p->haldata->errorcount)); fprintf(stderr,"%s: last command register: 0x%.4x\n",p->progname, p->failed_reg); fprintf(stderr,"%s: last error: %s\n",p->progname, modbus_strerror(p->last_errno)); } @@ -368,7 +368,7 @@ int write_data(modbus_t *ctx, haldata_t *haldata, param_pointer p) // send 0 to 0x2000 register - no bus control if (modbus_write_register(ctx, REG_COMMAND1, 0) < 0) { p->failed_reg = REG_COMMAND1; - hal_set_si32(haldata->errorcount, hal_get_si32(haldata->errorcount) + 1); + hal_set_sint(haldata->errorcount, hal_get_sint(haldata->errorcount) + 1); p->last_errno = errno; return errno; } @@ -425,7 +425,7 @@ int write_data(modbus_t *ctx, haldata_t *haldata, param_pointer p) goto retry; } p->failed_reg = REG_COMMAND1; - hal_set_si32(haldata->errorcount, hal_get_si32(haldata->errorcount) + 1); + hal_set_sint(haldata->errorcount, hal_get_sint(haldata->errorcount) + 1); p->last_errno = errno; return errno; } @@ -436,7 +436,7 @@ int write_data(modbus_t *ctx, haldata_t *haldata, param_pointer p) if ((modbus_write_register(ctx, REG_FREQUENCY, freq_reg)) < 0) { p->failed_reg = REG_FREQUENCY; - hal_set_si32(haldata->errorcount, hal_get_si32(haldata->errorcount) + 1); + hal_set_sint(haldata->errorcount, hal_get_sint(haldata->errorcount) + 1); p->last_errno = errno; return errno; } @@ -480,7 +480,7 @@ int read_initial(modbus_t *ctx, haldata_t *haldata, param_pointer p) failed: p->failed_reg = curr_reg; p->last_errno = errno; - hal_set_si32(haldata->errorcount, hal_get_si32(haldata->errorcount) + 1); + hal_set_sint(haldata->errorcount, hal_get_sint(haldata->errorcount) + 1); if (p->debug) fprintf(stderr, "%s: read_initial: modbus_read_registers(0x%4.4x): %s\n", p->progname, curr_reg, modbus_strerror(errno)); @@ -501,12 +501,12 @@ int read_data(modbus_t *ctx, haldata_t *haldata, param_pointer p) } GETREG(SR_ERROR_CODE, &curr_reg); - hal_set_si32(haldata->error_code, curr_reg); + hal_set_sint(haldata->error_code, curr_reg); // we always at least read the main status register SR_INV_OPSTATUS // and current operating frequency SR_OP_FREQUENCY GETREG(SR_INV_OPSTATUS, &status_reg); - hal_set_si32(haldata->status, status_reg); + hal_set_sint(haldata->status, status_reg); GETREG(SR_OUTPUT_FREQ, &freq_reg); hal_set_real(haldata->freq_out, freq_reg * 0.01); @@ -550,7 +550,7 @@ int read_data(modbus_t *ctx, haldata_t *haldata, param_pointer p) failed: p->failed_reg = curr_reg; p->last_errno = errno; - hal_set_si32(haldata->errorcount, hal_get_si32(haldata->errorcount) + 1); + hal_set_sint(haldata->errorcount, hal_get_sint(haldata->errorcount) + 1); if (p->debug) fprintf(stderr, "%s: read_data: modbus_read_registers(0x%4.4x): %s\n", p->progname, curr_reg, modbus_strerror(errno)); @@ -586,10 +586,10 @@ int hal_setup(int id, haldata_t *h, const char *name) PIN(hal_pin_new_real(id, HAL_OUT, &(h->output_volt), 0.0, "%s.output-voltage", name)); PIN(hal_pin_new_real(id, HAL_IN, &(h->speed_command), 0.0, "%s.speed-command", name)); PIN(hal_pin_new_bool(id, HAL_IN, &(h->spindle_on), 0, "%s.spindle-on", name)); - PIN(hal_pin_new_si32(id, HAL_OUT, &(h->error_code), 0, "%s.error-code", name)); - PIN(hal_pin_new_si32(id, HAL_OUT, &(h->status), 0, "%s.status", name)); + PIN(hal_pin_new_sint(id, HAL_OUT, &(h->error_code), 0, "%s.error-code", name)); + PIN(hal_pin_new_sint(id, HAL_OUT, &(h->status), 0, "%s.status", name)); PIN(hal_pin_new_bool(id, HAL_IN, &(h->max_speed), 0, "%s.max-speed", name)); - PIN(hal_pin_new_si32(id, HAL_OUT, &(h->errorcount), 0, "%s.error-count", name)); + PIN(hal_pin_new_sint(id, HAL_OUT, &(h->errorcount), 0, "%s.error-count", name)); PIN(hal_pin_new_real(id, HAL_OUT, &(h->upper_limit_hz), 0.0, "%s.frequency-limit", name)); PIN(hal_param_new_real(id, HAL_RW, &(h->looptime), 0.1, "%s.loop-time", name)); @@ -606,7 +606,7 @@ int set_defaults(param_pointer p) { haldata_t *h = p->haldata; - hal_set_si32(h->status, 0); + hal_set_sint(h->status, 0); hal_set_real(h->freq_cmd, 0); hal_set_real(h->freq_out, 0); hal_set_real(h->output_volt, 0); @@ -624,7 +624,7 @@ int set_defaults(param_pointer p) // hal_set_bool(h->err_reset, 0); hal_set_bool(h->jog_mode, 0); hal_set_bool(h->enabled, 0); - hal_set_si32(h->errorcount, 0); + hal_set_sint(h->errorcount, 0); hal_set_bool(h->max_speed, 0); hal_set_real(h->looptime, 0.1); diff --git a/src/hal/user_comps/vfs11_vfd/vfs11_vfd.c b/src/hal/user_comps/vfs11_vfd/vfs11_vfd.c index 8626218e28b..658b6f6f5f1 100644 --- a/src/hal/user_comps/vfs11_vfd/vfs11_vfd.c +++ b/src/hal/user_comps/vfs11_vfd/vfs11_vfd.c @@ -345,8 +345,8 @@ static struct option long_options[] = { void windup(param_pointer p) { - if (p->haldata && hal_get_si32(p->haldata->errorcount)) { - fprintf(stderr,"%s: %d modbus errors\n",p->progname, hal_get_si32(p->haldata->errorcount)); + if (p->haldata && hal_get_sint(p->haldata->errorcount)) { + fprintf(stderr,"%s: %ld modbus errors\n",p->progname, (long)hal_get_sint(p->haldata->errorcount)); fprintf(stderr,"%s: last command register: 0x%.4x\n",p->progname, p->failed_reg); fprintf(stderr,"%s: last error: %s\n",p->progname, modbus_strerror(p->last_errno)); } @@ -529,7 +529,7 @@ int write_data(modbus_t *ctx, haldata_t *haldata, param_pointer p) // send 0 to FA00 register - no bus control if (modbus_write_register(ctx, REG_COMMAND1, 0) < 0) { p->failed_reg = REG_COMMAND1; - hal_set_si32(haldata->errorcount, hal_get_si32(haldata->errorcount) + 1); + hal_set_sint(haldata->errorcount, hal_get_sint(haldata->errorcount) + 1); p->last_errno = errno; return errno; } @@ -618,7 +618,7 @@ int write_data(modbus_t *ctx, haldata_t *haldata, param_pointer p) goto retry; } p->failed_reg = REG_COMMAND1; - hal_set_si32(haldata->errorcount, hal_get_si32(haldata->errorcount) + 1); + hal_set_sint(haldata->errorcount, hal_get_sint(haldata->errorcount) + 1); p->last_errno = errno; return errno; } @@ -629,7 +629,7 @@ int write_data(modbus_t *ctx, haldata_t *haldata, param_pointer p) if ((modbus_write_register(ctx, REG_FREQUENCY, freq_reg)) < 0) { p->failed_reg = REG_FREQUENCY; - hal_set_si32(haldata->errorcount, hal_get_si32(haldata->errorcount) + 1); + hal_set_sint(haldata->errorcount, hal_get_sint(haldata->errorcount) + 1); p->last_errno = errno; return errno; } @@ -685,7 +685,7 @@ int read_initial(modbus_t *ctx, haldata_t *haldata, param_pointer p) failed: p->failed_reg = curr_reg; p->last_errno = errno; - hal_set_si32(haldata->errorcount, hal_get_si32(haldata->errorcount) + 1); + hal_set_sint(haldata->errorcount, hal_get_sint(haldata->errorcount) + 1); if (p->debug) fprintf(stderr, "%s: read_initial: modbus_read_registers(0x%4.4x): %s\n", p->progname, curr_reg, modbus_strerror(errno)); @@ -708,7 +708,7 @@ int read_data(modbus_t *ctx, haldata_t *haldata, param_pointer p) // we always at least read the main status register SR_INV_OPSTATUS // and current operating frequency SR_OP_FREQUENCY GETREG(SR_INV_OPSTATUS, &status_reg); - hal_set_si32(haldata->status, status_reg); + hal_set_sint(haldata->status, status_reg); GETREG(SR_OP_FREQUENCY, &freq_reg); hal_set_real(haldata->freq_out, freq_reg * 0.01); @@ -721,17 +721,17 @@ int read_data(modbus_t *ctx, haldata_t *haldata, param_pointer p) // determine what to do next. if (status_reg & ST_TRIPPED) { // read and set trip code. GETREG(SR_TRIPCODE, &val); - hal_set_si32(haldata->trip_code, val); + hal_set_sint(haldata->trip_code, val); // a sensible addition would be to read and convey SR_INV_OPSTATUS_T, the status just before the trip } else { - hal_set_si32(haldata->trip_code, 0); + hal_set_sint(haldata->trip_code, 0); } if (status_reg & ST_ALARMED) { // read and set alarm bit map. GETREG(SR_ALARM_MONITOR, &val); - hal_set_si32(haldata->alarm_code, val); + hal_set_sint(haldata->alarm_code, val); } else { - hal_set_si32(haldata->alarm_code, 0); + hal_set_sint(haldata->alarm_code, 0); } if (status_reg & ST_EMERGENCY_STOPPED) { // set e-stop status. @@ -766,7 +766,7 @@ int read_data(modbus_t *ctx, haldata_t *haldata, param_pointer p) failed: p->failed_reg = curr_reg; p->last_errno = errno; - hal_set_si32(haldata->errorcount, hal_get_si32(haldata->errorcount) + 1); + hal_set_sint(haldata->errorcount, hal_get_sint(haldata->errorcount) + 1); if (p->debug) fprintf(stderr, "%s: read_data: modbus_read_registers(0x%4.4x): %s\n", p->progname, curr_reg, modbus_strerror(errno)); @@ -786,7 +786,7 @@ int hal_setup(int id, haldata_t *h, const char *name) { int status; PIN(hal_pin_new_bool(id, HAL_IN, &(h->acc_dec_pattern), 0, "%s.acceleration-pattern", name)); - PIN(hal_pin_new_si32(id, HAL_OUT, &(h->alarm_code), 0, "%s.alarm-code", name)); + PIN(hal_pin_new_sint(id, HAL_OUT, &(h->alarm_code), 0, "%s.alarm-code", name)); PIN(hal_pin_new_bool(id, HAL_OUT, &(h->at_speed), 0, "%s.at-speed", name)); PIN(hal_pin_new_real(id, HAL_OUT, &(h->load_current_pct), 0.0, "%s.current-load-percentage", name)); PIN(hal_pin_new_bool(id, HAL_IN, &(h->DC_brake), 0, "%s.dc-brake", name)); @@ -808,10 +808,10 @@ int hal_setup(int id, haldata_t *h, const char *name) PIN(hal_pin_new_bool(id, HAL_IN, &(h->spindle_fwd), 1, "%s.spindle-fwd", name)); PIN(hal_pin_new_bool(id, HAL_IN, &(h->spindle_on), 0, "%s.spindle-on", name)); PIN(hal_pin_new_bool(id, HAL_IN, &(h->spindle_rev), 0, "%s.spindle-rev", name)); //JET - PIN(hal_pin_new_si32(id, HAL_OUT, &(h->status), 0, "%s.status", name)); - PIN(hal_pin_new_si32(id, HAL_OUT, &(h->trip_code), 0, "%s.trip-code", name)); + PIN(hal_pin_new_sint(id, HAL_OUT, &(h->status), 0, "%s.status", name)); + PIN(hal_pin_new_sint(id, HAL_OUT, &(h->trip_code), 0, "%s.trip-code", name)); PIN(hal_pin_new_bool(id, HAL_IN, &(h->max_speed), 0, "%s.max-speed", name)); - PIN(hal_pin_new_si32(id, HAL_OUT, &(h->errorcount), 0, "%s.error-count", name)); + PIN(hal_pin_new_sint(id, HAL_OUT, &(h->errorcount), 0, "%s.error-count", name)); PIN(hal_pin_new_real(id, HAL_OUT, &(h->upper_limit_hz), 0.0, "%s.frequency-limit", name)); // the following limit must be set manually from the panel since its in EEPROM @@ -829,7 +829,7 @@ int set_defaults(param_pointer p) { haldata_t *h = p->haldata; - hal_set_si32(h->status, 0); + hal_set_sint(h->status, 0); hal_set_real(h->freq_cmd, 0); hal_set_real(h->freq_out, 0); hal_set_real(h->curr_out_pct, 0); @@ -838,8 +838,8 @@ int set_defaults(param_pointer p) hal_set_real(h->inv_load_pct, 0); hal_set_real(h->load_current_pct, 0); hal_set_real(h->upper_limit_hz, 0); - hal_set_si32(h->trip_code, 0); - hal_set_si32(h->alarm_code, 0); + hal_set_sint(h->trip_code, 0); + hal_set_sint(h->alarm_code, 0); hal_set_bool(h->at_speed, 0); hal_set_bool(h->is_stopped, 0); hal_set_bool(h->estop, 0); @@ -855,7 +855,7 @@ int set_defaults(param_pointer p) hal_set_bool(h->jog_mode, 0); hal_set_bool(h->enabled, 0); hal_set_bool(h->acc_dec_pattern, 0); - hal_set_si32(h->errorcount, 0); + hal_set_sint(h->errorcount, 0); hal_set_bool(h->max_speed, 0); hal_set_real(h->looptime, 0.1);