-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable empty transfers for tud_vendor_n_write() #911
Enable empty transfers for tud_vendor_n_write() #911
Conversation
I have a second thought though, I think ZLP should only be sent when there is no data and the last packet is multiple of endpoint size) much like cdc https://github.com/hathach/tinyusb/blob/master/src/class/cdc/cdc_device.c#L469 . |
51580a1
to
f607a99
Compare
Something like this? (Compiles, but not tested). It does not exactly what you wrote in that it doesn't check for a multiple, but the equivalent of the endpoint size, because the actual transfer can't really be bigger than the EP size? Or were you referring to the last Even so I don't fully get the rationale behind that requirement. On the protocol level, the device can still send packages that are smaller than the EP size and in that case there would still be no way to send a ZLP? (I don't think change would help for the problem that lead me to open this thread). |
src/class/vendor/vendor_device.c
Outdated
{ | ||
TU_ASSERT( usbd_edpt_xfer(TUD_OPT_RHPORT, p_itf->ep_in, p_itf->epin_buf, count) ); | ||
} | ||
last_in_transfer_was_epsize = count && (count == CFG_TUD_VENDOR_EPSIZE); |
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.
condition seems to be overkill (only right side of && makes a difference) or wrong (&& where || should be)
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.
&&
ist correct, but you're right, it's redundant.
Sorry for the extra long delay, I've merged latest ZLP handling from CDC class. |
Extend
tud_vendor_n_write()
to make a zero length transfer whenbuffer==NULL && bufsize==0
, as discussed in #903.I consider implementing this via a flag to
maybe_transmit()
the best solution:tud_vendor_n_write()
doesn't have access to neitherbuffer
norbufsize
, so it can't make the decision.tud_vendor_n_write()
would mean duplicating some functionality ofmaybe_transmit()
(but judging by your latest comment maybe that's what you prefer?).