Frage

I have application on Windows-host that connects to board-device via RS232 with full handshake (RTS, CTS, DTR). I want to replace the RS232 with USB now. I use board with embedded linux and USB device (g_serial) module. I get all the data on terminal both sides, but application can't handle it (lack of handshake signals). How is it possible to handle it ? (Host or device side) Maybe there are some handshake "emulators" that cares about handshake on PC-host side ?

BR Bartlomiej Grzeskowiak

War es hilfreich?

Lösung

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.

Andere Tipps

If the underlying driver implements the CDC ACM class then the control line states are set using the SET_CONTROL_LINE_STATE (0x22) request. Windows certainly issues this request when the control line states are set, and responds to the request also from a device.

However these signals have no effect on the USB transfer since the underlying USB protocol has its own flow control mechanism. Your application at both ends needs to handle the signals. In Windows for example you must enable hardware flow control explicitly for the port.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top