0

I am trying to communicate with a serial device via a ch341 based usb-serial adapter (wemos.cc / ch340). Since the target device has limited buffer size it uses a signal line to indicate if it is safe to send bytes.

I have confirmed that the level of the CTS# pin is connected correctly: the state of the pin is visible with the "statserial" utility and is propagated to the "Clear To Send" flag (logically inverted, which matches the "datasheet" of the ch341).

I am enabling RTS/CTS flow control via the CRTSCTS flag in tcsetattr(), also the CLOCAL flag is set to avoid waiting for the DCD signal.

However, this does not seem to have an effect on the behaviour of the ch341. When connecting the CTS# pin to either VCC or GND the ch341 happily accepts all the data sent to the chip via the /dev/ttyUSB0 device. I'd expect it to block when the chip-internal buffers are filled up until CTS# gets low, allowing it to send the data to the TX pin...

Is there something I am missing? Or is CTS not implemented on the ch341?

Thanks,
        Simon.

nomis
  • 1
  • 1
  • *"a ch341 based usb-serial adapter"* -- That's not specific enough. Is the adapter for TTL levels or RS-232 levels? *"When connecting the CTS# pin to either VCC or GND..."* -- That would only test TTL levels, and not test RS-232 levels. *"the ch341 happily accepts all the data sent to the chip via the /dev/ttyUSB0 device"* -- How do you know this? Do you have a USB analyzer? *"Is there something I am missing?"* -- Apparently you don't know (or choose to ignore) the difference between TTL and RS-232 levels. You may be overlooking terminal transmit buffering. – sawdust May 30 '18 at 00:20
  • *"Or is CTS not implemented on the ch341?"* -- This [patch](https://www.spinics.net/lists/linux-serial/msg21945.html) doesn't seem to be in mainline. – sawdust May 30 '18 at 00:55
  • Sorry, I was under the assumption that the text on the pcb ("wemos.cc / ch340") was enough to identify the model, but that doesn't seem to be the case. – nomis May 31 '18 at 07:00
  • It is a arduino style adapter using this chip, and it currently is configured for 5V TTL levels, testing against VCC/GND should be fine. I basically wrote lots of data to the ch341 and I expect it to block when the buffers on the ch341 are filled. That doesn't seem to happen. – nomis May 31 '18 at 07:07
  • Thanks for the hint regarding the patch, I am using the kernel "4.16.5-1 (2018-04-29)" as of debian unstable. I'll investigate that. – nomis May 31 '18 at 07:07

0 Answers0