Skip to content

TP (not really) creates example pins/params (but could) #4248

Description

@BsAtHome

There is code in tp.c that is guarded by the MAKE_TP_HAL_PINS define. However, the code is clearly a copy/paste job from the kinematics example and is not used and completely irrelevant.

The define of MAKE_TP_HAL_PINS in line 50 of emc/tp/tp.c is undefined in line 51. Very effective :-)

This code should be removed IMO. Anybody against retiring this code?

There are some kinematics instances that suffer from the same infliction and should be cleaned as well. There is no need to have "example pins and params" exposed in production code.

This is the code in tp.c:

linuxcnc/src/emc/tp/tp.c

Lines 50 to 58 in 8bc2801

#define MAKE_TP_HAL_PINS
#undef MAKE_TP_HAL_PINS
// api for tpCreate() inherits a component id provision to include hal pins:
// (not used by the this default tp implementation but may
// be used in alternate user-built implementations)
#ifdef MAKE_TP_HAL_PINS // {
#include <hal.h>
#endif // }

linuxcnc/src/emc/tp/tp.c

Lines 384 to 417 in 8bc2801

#ifdef MAKE_TP_HAL_PINS // {
static struct tp_haldata {
// Example pin pointers
hal_u32_t *in;
hal_u32_t *out;
// Example parameters
hal_float_t param_rw;
hal_float_t param_ro;
} *tp_haldata;
static int makepins(int id) {
#define HAL_PREFIX "tp"
int res=0;
if (id < 0) goto error;
tp_haldata = hal_malloc(sizeof(struct tp_haldata));
if (!tp_haldata) goto error;
// hal pin examples:
res += hal_pin_u32_newf(HAL_IN ,&(tp_haldata->in) ,id,"%s.in" ,HAL_PREFIX);
res += hal_pin_u32_newf(HAL_OUT,&(tp_haldata->out),id,"%s.out",HAL_PREFIX);
// hal parameter examples:
res += hal_param_float_newf(HAL_RW, &tp_haldata->param_rw,id,"%s.param-rw",HAL_PREFIX);
res += hal_param_float_newf(HAL_RO, &tp_haldata->param_ro,id,"%s.param-ro",HAL_PREFIX);
if (res) goto error;
rtapi_print("@@@ %s:%s: ok\n",__FILE__,__FUNCTION__);
return 0; // caller issues hal_ready()
error:
rtapi_print("\n!!! %s:%s: failed res=%d\n\n",__FILE__,__FUNCTION__,res);
return -1;
#undef HAL_PREFIX
}
#endif // }

linuxcnc/src/emc/tp/tp.c

Lines 438 to 442 in 8bc2801

#ifdef MAKE_TP_HAL_PINS // {
if (-1 == makepins(id)) {
return TP_ERR_FAIL;
}
#endif // }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions