Search code examples
linuxembeddedusbusbserial

g_serial gadget with handshake


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


Solution

  • 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.