Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(generic): Preliminary support for 64-bit floats #116

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/devices/lcec_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ int lcec_generic_init(int comp_id, struct lcec_slave *slave, ec_pdo_entry_reg_t

case HAL_FLOAT:
// check data size
if (hal_data->bitLength > 32) {
if ((hal_data->bitLength > 32) && (hal_data->subType != lcecPdoEntTypeFloatDoubleIeee)) {
rtapi_print_msg(RTAPI_MSG_WARN, LCEC_MSG_PFX "unable to export pin %s.%s.%s.%s: invalid process data bitlen!\n", LCEC_MODULE_NAME, master->name, slave->name, hal_data->name);
continue;
}
Expand Down Expand Up @@ -133,6 +133,8 @@ void lcec_generic_read(struct lcec_slave *slave, long period) {
fval = lcec_generic_read_u32(pd, hal_data);
} else if(hal_data->subType == lcecPdoEntTypeFloatIeee){
fval = EC_READ_REAL(&pd[hal_data->pdo_os]);
} else if(hal_data->subType == lcecPdoEntTypeFloatDoubleIeee){
fval = EC_READ_LREAL(&pd[hal_data->pdo_os]);
} else {
fval = lcec_generic_read_s32(pd, hal_data);
}
Expand Down Expand Up @@ -187,6 +189,8 @@ void lcec_generic_write(struct lcec_slave *slave, long period) {
lcec_generic_write_u32(pd, hal_data, (hal_u32_t) fval);
} else if(hal_data->subType == lcecPdoEntTypeFloatIeee){
EC_WRITE_REAL(&pd[hal_data->pdo_os], fval);
} else if(hal_data->subType == lcecPdoEntTypeFloatDoubleIeee){
EC_WRITE_LREAL(&pd[hal_data->pdo_os], fval);
} else {
lcec_generic_write_s32(pd, hal_data, (hal_s32_t) fval);
}
Expand Down
12 changes: 11 additions & 1 deletion src/lcec_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ static void parsePdoEntryAttrs(LCEC_CONF_XML_INST_T *inst, int next, const char
p->subType = lcecPdoEntTypeSimple;
p->halType = HAL_U32;
continue;
}
}
if (strcasecmp(val, "float") == 0) {
p->subType = lcecPdoEntTypeFloatSigned;
p->halType = HAL_FLOAT;
Expand All @@ -960,6 +960,11 @@ static void parsePdoEntryAttrs(LCEC_CONF_XML_INST_T *inst, int next, const char
p->halType = HAL_FLOAT;
continue;
}
if (strcasecmp(val, "float-double-ieee") == 0) {
p->subType = lcecPdoEntTypeFloatDoubleIeee;
p->halType = HAL_FLOAT;
continue;
}
fprintf(stderr, "%s: ERROR: Invalid pdoEntry halType %s\n", modname, val);
XML_StopParser(inst->parser, 0);
return;
Expand Down Expand Up @@ -1103,6 +1108,11 @@ static void parseComplexEntryAttrs(LCEC_CONF_XML_INST_T *inst, int next, const c
p->halType = HAL_FLOAT;
continue;
}
if (strcasecmp(val, "float-double-ieee") == 0) {
p->subType = lcecPdoEntTypeFloatDoubleIeee;
p->halType = HAL_FLOAT;
continue;
}
fprintf(stderr, "%s: ERROR: Invalid complexEntry halType %s\n", modname, val);
XML_StopParser(inst->parser, 0);
return;
Expand Down
3 changes: 2 additions & 1 deletion src/lcec_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ typedef enum {
lcecPdoEntTypeFloatSigned,
lcecPdoEntTypeFloatUnsigned,
lcecPdoEntTypeComplex,
lcecPdoEntTypeFloatIeee
lcecPdoEntTypeFloatIeee,
lcecPdoEntTypeFloatDoubleIeee,
} LCEC_PDOENT_TYPE_T;

typedef struct {
Expand Down