rtlabs-com / c-open

CANopen stack for embedded devices
http://www.rt-labs.com
Other
79 stars 40 forks source link

Standard RPDO padding not possible #11

Closed nattgris closed 4 years ago

nattgris commented 4 years ago

It seems standard RPDO padding between mappings as per CiA 301 §7.4.7.1 is not implemented.

For static mappings I guess you could work around it by defining objects like

    {0x0005, OTYPE_DEFTYPE,0,               OD0005, NULL},

with

static uint8_t dummy;

/* Entry descriptor for UNSIGNED8 (0005h) */
static const co_entry_t OD0005[] = {
    {0x00, OD_WO | OD_TRANSIENT | OD_RPDO, DTYPE_UNSIGNED8, 8, 0, &dummy},
};

However to support dynamic mappings you'd basically have to do this for all integer types for all slaves, because you don't know what mapping the master may set up. Seems better if that was built into the stack.

hefloryd commented 4 years ago

Agreed, padding using the static data types should be possible.

hefloryd commented 4 years ago

This PR adds support for padding. The CiA spec mentions padding for RPDO:s only, this PR would make it possible add padding into TPDO:s as well. It also doesn't validate the bitlength against the datatypes, as it seems useful to be able to e.g. pad 7 bits using a BOOLEAN datatype.