aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/generic/canserial.c7
-rw-r--r--src/generic/canserial.h2
-rw-r--r--src/generic/usb_canbus.c12
3 files changed, 8 insertions, 13 deletions
diff --git a/src/generic/canserial.c b/src/generic/canserial.c
index 0607e489..d56235f5 100644
--- a/src/generic/canserial.c
+++ b/src/generic/canserial.c
@@ -224,7 +224,7 @@ canserial_notify_rx(void)
DECL_CONSTANT("RECEIVE_WINDOW", ARRAY_SIZE(CanData.receive_buf));
// Handle incoming data (called from IRQ handler)
-int
+void
canserial_process_data(struct canbus_msg *msg)
{
uint32_t id = msg->id;
@@ -233,7 +233,7 @@ canserial_process_data(struct canbus_msg *msg)
int rpos = CanData.receive_pos;
uint32_t len = CANMSG_DATA_LEN(msg);
if (len > sizeof(CanData.receive_buf) - rpos)
- return -1;
+ return;
memcpy(&CanData.receive_buf[rpos], msg->data, len);
CanData.receive_pos = rpos + len;
canserial_notify_rx();
@@ -243,13 +243,12 @@ canserial_process_data(struct canbus_msg *msg)
uint32_t pushp = CanData.admin_push_pos;
if (pushp >= CanData.admin_pull_pos + ARRAY_SIZE(CanData.admin_queue))
// No space - drop message
- return -1;
+ return;
uint32_t pos = pushp % ARRAY_SIZE(CanData.admin_queue);
memcpy(&CanData.admin_queue[pos], msg, sizeof(*msg));
CanData.admin_push_pos = pushp + 1;
canserial_notify_rx();
}
- return 0;
}
// Remove from the receive buffer the given number of bytes
diff --git a/src/generic/canserial.h b/src/generic/canserial.h
index e8f3767f..3dd5cd9d 100644
--- a/src/generic/canserial.h
+++ b/src/generic/canserial.h
@@ -9,7 +9,7 @@
// canserial.c
void canserial_notify_tx(void);
struct canbus_msg;
-int canserial_process_data(struct canbus_msg *msg);
+void canserial_process_data(struct canbus_msg *msg);
void canserial_set_uuid(uint8_t *raw_uuid, uint32_t raw_uuid_len);
#endif // canserial.h
diff --git a/src/generic/usb_canbus.c b/src/generic/usb_canbus.c
index 602acc70..9b0bebe6 100644
--- a/src/generic/usb_canbus.c
+++ b/src/generic/usb_canbus.c
@@ -204,20 +204,16 @@ usbcan_task(void)
msg.dlc = gs->can_dlc;
msg.data32[0] = gs->data32[0];
msg.data32[1] = gs->data32[1];
+ if (host_status & HS_TX_LOCAL) {
+ canserial_process_data(&msg);
+ UsbCan.host_status = host_status = host_status & ~HS_TX_LOCAL;
+ }
if (host_status & HS_TX_HW) {
ret = canhw_send(&msg);
if (ret < 0)
return;
UsbCan.host_status = host_status = host_status & ~HS_TX_HW;
}
- if (host_status & HS_TX_LOCAL) {
- ret = canserial_process_data(&msg);
- if (ret < 0) {
- usb_notify_bulk_out();
- return;
- }
- UsbCan.host_status = host_status & ~HS_TX_LOCAL;
- }
continue;
}