Cdc_Acm: Failed to Set Dtr/Rts - Can Not Communicate with Usb Cdc Device

How to set RTS/DTR using libusb?

libusb can't do that itself - you should send 'control state' for CDC-device or FTDI-specific commands for FTDI-device.

For CDC:
http://cscott.net/usb_dev/data/devclass/usbcdc11.pdf

`6.2.14 SetControlLineState
This request generates RS-232/V.24 style control signals.
...

D1 Carrier control for half duplex modems. This signal corresponds to
V.24 signal
105 and RS-232 signal RTS.
0 - Deactivate carrier
1 - Activate carrier
The device ignores the value of this bit when operating in full duplex mode

D0 Indicates to DCE if DTE is present or not. This signal corresponds to V.24
signal 108/2 and RS-232 signal DTR.
0 - Not Present
1 - Present`

PS. Thanks to Xiaofan from libusb-devel mailing list.

g_serial gadget with handshake

I looked through the kernel (originally 3.8, later 4.11) source code for the g_serial driver in the Linux kernel, to see if it implements the API to control the hardware handshaking lines on the Linux-side API (/dev/ttyGS0). E.g.:

#include <unistd.h>
#include <termios.h>

int fd;
int status;

...
ioctl(fd, TIOCMGET, &status);
status |= TIOCM_DTR;
ioctl(fd, TIOCMSET, &status);

It looks as though the driver has no support for it. In drivers/usb/gadget/function/u_serial.c, see struct tty_operations gs_tty_ops which doesn't define the .tiocmset or .tiocmget members which would normally be needed to support the above code.

So I think the driver would need to be improved to add this support.



Related Topics



Leave a reply



Submit