-
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
CDC doesn't respect no flow control setting (DTR control needed to receive data) #1548
Comments
This has been done intentionally. They use the DTR signal to detect when the PC/host has actually opened or closed the com port. I agree, it causes problems it some cases. Most of the arduino CDC implementations do this as well; it is fairly common. I have a pull request submitted that adds a CH341 emulation class driver which would solve your problem. You can get this from my fork here: https://github.com/TravisRo/tinyusb/tree/master The api is nearly 100% compatible with the cdc driver except you have to change all of your "tud_cdc" prefixes to "tud_ch341" |
Thank you for responding my inquiry. Yes I checked the code. And Thank you for the PR #1507 When people use MCU which support USB, and if serial port is needed using CDC is common to use instead of using USB serial converters. When it happens, you expect using CDC to be the same as using a USB serial converter. Using DTR to detect connection shouldn't be implemented. We can't expect all applications to raise DTR when open the serial port. That's why I raised this issue. |
@MrGreensWorkshop |
I saw in #482 too. its closed with another #506 patch, which is still using DTR control. I think author of this repo only tested in VT100 terminals like PuTTY or Teraterm. PuTTY or Teraterm terminals are made for VT100 etc., not exactly plain text transmission. You can use if you want. But those are uses other pins too. DTR -> DSR and DSR <- DTR. But the main problem is not those terminals. Because we use them just for test. The real problem is, asking host application for DSR on is reduce the compatibility with other apps if user is explicitly select no flow control. We should came with better option. |
I think you should ask pico SDK to remove tud_cdc_n_connected() test, just like #506 remove this test from examples. |
I know I know. I'm trying to make a point. I know the solution. |
Removing |
I see your point. |
CDC should still send & receive data even if DTTR/RTS aren't set. Could you try the stock example from this repo
If yes, then the issue is pico-sdk making use of the connect() API which return the state of DTR. In that case you should ask rpi team to remove that check. |
@hathach
the example suggested examples/device/cdc_msc is waiting for chars if they are available, then it sends backs.
this works because this example waits for chars first. This comment is misleading. OK, lets say if This is how raspberry pi pico sdk implemented. they are using Kind of you are right it's their problem. I think there must be better implementation for I think tud_cdc_connected name is misleading. tud_dtr_check, tud_dtr_is_on would be better choice. But that's out of content. |
Let me know if you figure out the better way to determine there is a connected client, I am happy to make the changes. Note: there is a difference in cdc behavior when dtr is not set, the tx buffer will become overwritable, i.e if tx fifo is full, it will be overwritten. more details of this behavior is discussed in previous issue/pr mentioned above. |
Are you referring to #482 ? |
I made some changes and test it's behavior. first changed this
and renamed When port is opened all data in tx buffer(255 bytes?) output to terminal. Is there any other concerns? |
as mentioned above, the only difference in behavior is tx fifo can be overwritten when dtr is not set. When dtr is set, tinyusb will blocking wait for tx fifo to be sent since it is certain there is waiting client. In other words, If you send too many data in short period, there maybe some missing. connected() is optional, going to support dtr or not is up to stdio integration i.e rpi team. For the changes you propose is within pico-sdk, you should ask them to see if it is acceptable or not. |
@hathach Things are more clear now. Thank you for your explanation. |
no problem, I am glad that help. The current state of control signals (dtr,rts, cts etc...) in cdc acm are not standardized among terminal clients, though more and more terminal use dtr as connected nowsaday. I will try to revise/improve this later on when having time. I guess we could now close this issue here ? |
I open the this PR on pico-SDK. Clearly
About that. It is also mentioned in #482.
PSTN Devices are mostly modems. Most of time we need flow control to control data flow. Let's not confuse with modems. The reason that I raise the issue is not about the terminals default settings. It's about the application side. Most people use terminals for test purpose. As you know more mcu have usb support nowadays, so serial port replace with CDC. People like me want to use cdc without any change in host application. Host serial app could be run on PC, mobile device or host mcu. Thank you again for this great project. |
Operating System
Windows 10, Mac OS, I think in all OS es.
Board
Raspberry pi pico
Firmware
just simple app to test cdc behavior.
RasPiPicoSDK_cdc_test-main.zip
What happened ?
When handshake is set to none, to receive data we need to enable DTR. We shouldn't be force to enable DTR to receive data. (other flow control status shouldn't be changed in cdc side if it is the case.)
I believe this is related with #872 maybe with #746 too.
please watch the gif file.
How to reproduce ?
RasPiPicoSDK_cdc_test-main.zip
Expected behavior
This the demonstration that 2 FDTI USB serial converter connected each other with 3 pins.
It shouldn't be forced to enable DTR to receive data either sides. Please watch the gif file.
Cause
This happens when raspberry pi usb cdc is used.
This is other issue talks about same thing.
#932
Please check this file.
https://github.com/hathach/tinyusb/blob/master/src/class/cdc/cdc_device.c
it is checking DTR if it's on or not regardless checking flow control.
The text was updated successfully, but these errors were encountered: