Skip to content

Commit

Permalink
usbd_gs_can: USBD_GS_CAN_SendFrame(): disable pad_pkts_to_max_pkt_siz…
Browse files Browse the repository at this point in the history
…e feature for CAN-FD frames
  • Loading branch information
marckleinebudde committed Dec 15, 2022
1 parent 23c8fae commit c2ddbb5
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/usbd_gs_can.c
Original file line number Diff line number Diff line change
Expand Up @@ -791,11 +791,18 @@ static uint8_t USBD_GS_CAN_SendFrame(USBD_HandleTypeDef *pdev, struct gs_host_fr

send_addr = (uint8_t *)frame;

if (hcan->pad_pkts_to_max_pkt_size) {
// When talking to WinUSB it seems to help a lot if the
// size of packet you send equals the max packet size.
// In this mode, fill packets out to max packet size and
// then send.
/*
* When talking to WinUSB it seems to help a lot if the size of
* packet you send equals the max packet size. In this mode, fill
* packets out to max packet size and then send.
*
* Don't know if the above observation is still true for CAN-FD
* (CAN-FD frames don't fit into a single the full speed USB
* packet of 64 byte), so don't do any padding for CAN-FD frames
* for now.
*/
if (hcan->pad_pkts_to_max_pkt_size &&
!(IS_ENABLED(CONFIG_CANFD) && frame->flags & GS_CAN_FLAG_FD)) {
memcpy(buf, frame, len);

// zero rest of buffer
Expand Down

0 comments on commit c2ddbb5

Please sign in to comment.