-
Notifications
You must be signed in to change notification settings - Fork 3k
USBCDC support ZLP #15473
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
USBCDC support ZLP #15473
Conversation
This does not work if there is no ongoing data stream but just some request/response interaction. --- drivers/usb/source/USBCDC.cpp 2023-02-23 15:00:40 +0000
+++ drivers/usb/source/USBCDC.cpp 2023-12-01 20:39:54 +0000
@@ -186,6 +186,7 @@
_rx_in_progress = false;
_rx_buf = _rx_buffer;
_rx_size = 0;
+ _trans_zlp = false;
}
void USBCDC::callback_reset()
@@ -402,6 +403,9 @@
if (!_tx_in_progress && _tx_size) {
if (USBDevice::write_start(_bulk_in, _tx_buffer, _tx_size)) {
_tx_in_progress = true;
+ if (_tx_size == CDC_MAX_PACKET_SIZE) {
+ _trans_zlp = true;
+ }
}
}
}
@@ -414,6 +418,11 @@
{
assert_locked();
+ if (_trans_zlp && USBDevice::write_start(_bulk_in, _tx_buffer, 0)) {
+ _trans_zlp = false;
+ return;
+ }
+
write_finish(_bulk_in);
_tx_buf = _tx_buffer;
_tx_size = 0;
Note that something similar needs to be done for USBCDC_ECM and maybe other devices. |
@daniel-starke , |
I believe that the condition for |
@daniel-starke, |
@cyliangtw |
Hi @daniel-starke, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verified on NUMAKER_IOT_M467/NUMAKER_IOT_M487 targets
drivers/usb/source/USBCDC.cpp
Outdated
@@ -641,4 +663,4 @@ const uint8_t *USBCDC::configuration_desc(uint8_t index) | |||
} else { | |||
return NULL; | |||
} | |||
} | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add an empty line as it was
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks of your reminder.
I rollback the empty line.
@cyliangtw --- drivers/usb/source/USBCDC.cpp 2023-12-10 15:37:58.259849800 +0100
+++ drivers/usb/source/USBCDC.cpp 2023-12-10 15:58:26.240938600 +0100
@@ -391,7 +391,7 @@
uint32_t free = sizeof(_tx_buffer) - _tx_size;
uint32_t write_size = free > size ? size : free;
if (size > 0) {
- memcpy(_tx_buf, buffer, write_size);
+ memcpy(_tx_buf + _tx_size, buffer, write_size);
}
_tx_size += write_size;
*actual = write_size;
|
@daniel-starke, About send_nb() memcpy possible break the continuation use case, I agree with your point and it's no matter with ZLP, you could add another PR to contribute your good viewpoint. |
@cyliangtw |
CI started |
Jenkins CI Test : ❌ FAILEDBuild Number: 1 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
@0xc0170 , After review the update of USBCDC, seems unrelated with this PR. |
Jenkins CI Test : ❌ FAILEDBuild Number: 4 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
@0xc0170 , |
Mergify sometimes find 2 conditions that are met and goes back and forth.. we might revisit the rules. |
This PR is to support ZLP handling in USBCDC.
It could resolve #15451.
Pull request type
Test results
Reviewers