Skip to content

Commit 845798b

Browse files
authored
Merge pull request #28 from nattgris/pdo-rtr
Fix PDOs sending remote frames instead of actual data
2 parents fbf6ecf + 21e8d71 commit 845798b

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

Diff for: src/co_main.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ extern "C" {
3535

3636
#define CO_BYTELENGTH(bitlength) (((bitlength) + 7) / 8)
3737

38-
#define CO_RTR_MASK BIT (30)
39-
#define CO_EXT_MASK BIT (29)
40-
#define CO_ID_MASK 0x1FFFFFFF
38+
#define CO_RTR_MASK BIT (30)
39+
#define CO_EXT_MASK BIT (29)
40+
#define CO_ID_MASK 0x1FFFFFFF
41+
#define CO_EXTID_MASK (CO_EXT_MASK | CO_ID_MASK)
4142

4243
#define CO_COBID_INVALID BIT (31)
4344
#define CO_NODE_GET(id) ((id)&0x7F)

Diff for: src/co_pdo.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ static void co_pdo_transmit (co_net_t * net, co_pdo_t * pdo)
538538
/* Transmit PDO */
539539
co_pdo_pack (net, pdo);
540540
dlc = CO_BYTELENGTH (pdo->bitlength);
541-
os_channel_send (net->channel, pdo->cobid, &pdo->frame, dlc);
541+
os_channel_send (net->channel, pdo->cobid & CO_EXTID_MASK, &pdo->frame, dlc);
542542
pdo->timestamp = now;
543543
pdo->queued = false;
544544
}
@@ -685,7 +685,7 @@ void co_pdo_rx (co_net_t * net, uint32_t id, void * msg, size_t dlc)
685685

686686
if (id & CO_RTR_MASK)
687687
{
688-
id &= ~CO_RTR_MASK;
688+
id &= CO_EXTID_MASK;
689689
for (ix = 0; ix < MAX_TX_PDO; ix++)
690690
{
691691
co_pdo_t * pdo = &net->pdo_tx[ix];

Diff for: src/co_sync.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ int co_sync_timer (co_net_t * net, uint32_t now)
157157
co_put_uint8 (msg, sync->counter);
158158
os_channel_send (
159159
net->channel,
160-
sync->cobid & 0x1FFFFFF,
160+
sync->cobid & CO_EXTID_MASK,
161161
msg,
162162
sizeof (msg));
163163

@@ -166,7 +166,7 @@ int co_sync_timer (co_net_t * net, uint32_t now)
166166
}
167167
else
168168
{
169-
os_channel_send (net->channel, sync->cobid & 0x1FFFFFFF, NULL, 0);
169+
os_channel_send (net->channel, sync->cobid & CO_EXTID_MASK, NULL, 0);
170170
}
171171

172172
/* Call user callback */

0 commit comments

Comments
 (0)