Commit 14b372fb authored by Jeroen Vreeken's avatar Jeroen Vreeken
Browse files

First canopen fix

parent d1365c48
......@@ -558,11 +558,13 @@ ssize_t esc_mailbox_write(struct esc_mailbox *mailbox, int type,
/* wait till mailbox is empty */
while (1) {
/* write mailbox contents */
ret = ec_datagram_write(&mailbox->data_wr, mailbox->buffer_wr,
mailbox->len_wr);
if (ret > 0) {
break;
}
/* wait while mailbox full */
do {
ret = ec_datagram_read(&mailbox->status_wr, &val8,
sizeof(val8));
......@@ -598,18 +600,20 @@ ssize_t esc_mailbox_read(struct esc_mailbox *mailbox, int *type,
/* wait till mailbox is full */
while (1/*todo add timeout*/) {
ret = ec_datagram_read(&mailbox->data_rd, mailbox->buffer_rd,
mailbox->len_rd);
if (ret > 0) {
break;
}
/* wait while mailbox full */
do {
ret = ec_datagram_read(&mailbox->status_rd, &val8, sizeof(val8));
if (ret != sizeof(val8)) {
printf("Could not read mailbox status\n");
return -1;
}
} while (!(val8 & 0x08));
} while (val8 & 0x08);
/* read mailbox contents */
ret = ec_datagram_read(&mailbox->data_rd, mailbox->buffer_rd,
mailbox->len_rd);
if (ret > 0) {
break;
}
}
clen = le16toh(hdr->length);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment