-
-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Fix CDC write() when DTR is not set #3839
base: master
Are you sure you want to change the base?
Conversation
@matthijskooijman build this please |
@ArduinoBot build this please |
The PR like this does not work for me I've noticed. If the host is not listening my RawHID dev sketch will block for a long time. I tried to check for baud() but this also didnt help (set the value default to zero of course). But adding I will add this to the patch. The only thing we could also add would be baud() but that was not needed in this case. Tested under linux 64 bit elementary os. |
I think testing for availableForWrite() inside write() is not correct. It looses the automatic flow control USB provides: if the process on the host temporarily does not catch up with the data you send it, the write method should block till data is sent. If this is not acceptable for an application, it should call availableForWrite() by itself.
Just consulted the datasheet. The VBUSTI irq fires upon connect/disconnect. The VBUS status bit in USBSTA tells you the current state. Did not try this though. |
Without the writeavailable my device locked up. Have to check this again. Feel free to also test it, I will not have time to debug this in the next days. |
|
Fix #1182
This should not give any disadvantage. You still can check via
while(!Serial);
if the Serial port is opened. If you write to a not opened port this should not cause any problems. This is how other firmwares like lufa handle it. Also you dont need to set a DTR state to co0mmunicate with the device. This enables more options.https://github.com/abcminiuser/lufa/blob/master/Projects/USBtoSerial/USBtoSerial.c#L197
https://github.com/abcminiuser/lufa/blob/master/LUFA/Drivers/USB/Class/Device/CDCClassDevice.c#L193
We could also check the baud info, but since it is set to 57600 by default this doesnt make sense. Maybe we should change this as well?
https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/CDC.cpp#L34
TODO (from peter)