Skip to content

Fix PDO mapping with OD_ARRAY entries #64

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

Merged
merged 1 commit into from
Feb 9, 2024
Merged
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
6 changes: 4 additions & 2 deletions src/co_pdo.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,12 @@ void co_pdo_pack (co_net_t * net, co_pdo_t * pdo)
const co_entry_t * entry = pdo->entries[ix];
const co_obj_t * obj = pdo->objs[ix];
size_t bitlength = pdo->mappings[ix] & 0xFF;
uint8_t subindex = (pdo->mappings[ix] >> 8) & 0xFF;
uint64_t value = 0;

if (entry != NULL)
{
co_od_get_value (net, obj, entry, entry->subindex, &value);
co_od_get_value (net, obj, entry, subindex, &value);
}

bitslice_set (&pdo->frame, offset, bitlength, value);
Expand All @@ -106,12 +107,13 @@ void co_pdo_unpack (co_net_t * net, co_pdo_t * pdo)
const co_entry_t * entry = pdo->entries[ix];
const co_obj_t * obj = pdo->objs[ix];
size_t bitlength = pdo->mappings[ix] & 0xFF;
uint8_t subindex = (pdo->mappings[ix] >> 8) & 0xFF;
uint64_t value;

if (entry != NULL)
{
value = bitslice_get (&pdo->frame, offset, bitlength);
co_od_set_value (net, obj, entry, entry->subindex, value);
co_od_set_value (net, obj, entry, subindex, value);
}

offset += bitlength;
Expand Down