Skip to content

Commit

Permalink
usb_canbus: Prioritize local response sending over new host messages
Browse files Browse the repository at this point in the history
Prioritize sending responses back to the host over transmitting new
messages from the host.  Otherwise, the gs_usb host usb
acknowledgments could saturate the usb bandwidth for extended periods.

Signed-off-by: Kevin O'Connor <[email protected]>
  • Loading branch information
KevinOConnor committed Oct 1, 2023
1 parent 7629e52 commit c2cc494
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/generic/usb_canbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,9 @@ usbcan_task(void)

// Send any previous echo frames
if (host_status) {
if (UsbCan.usb_send_busy)
if (UsbCan.notify_local || UsbCan.usb_send_busy)
// Don't send echo frame until other traffic is sent
return;
break;
int ret = usb_send_bulk_in(gs, sizeof(*gs));
if (ret < 0)
return;
Expand Down Expand Up @@ -281,6 +281,8 @@ canbus_send(struct canbus_msg *msg)
int ret = send_frame(msg);
if (ret < 0)
goto retry_later;
if (UsbCan.notify_local && UsbCan.host_status)
canbus_notify_tx();
UsbCan.notify_local = 0;
return msg->dlc;
retry_later:
Expand Down

0 comments on commit c2cc494

Please sign in to comment.