Unterstanding ser2net buffering

Anonymous
2012-06-09
2013-04-01

  • Anonymous
    2012-06-09

    I'm successfully running ser2net on OpenWRT, but I can only send/receive 16 bytes over TCP.

    For example, when I run

    echo "ABCDEFGHIJKLMNOPQRSTUVWXYZ"|nc 192.168.11.85 3001
    

    I will only receive "ABCDEFGHIJKLMNOP" at the serial device connected to 192.168.11.85.

    Shouldn't TCP flow control handle this problem? (fast network, slow serial connection)
    I would be very happy, if someone could explain this to me.

    My ser2net config:

    3001:raw:0:/dev/ttyS0:9600
    

    Running

    echo "ABCDEFGHIJKLMNOPQRSTUVWXYZ" > /dev/ttyS0
    

    directly works perfectly fine.

    Cheers
    Thomas

     
  • Corey Minyard
    Corey Minyard
    2012-06-10

    I don't really think the problem is on the TCP side.  ser2net itself has an internal 64-byte buffer, so 16 bytes shouldn't be an issue anyway.

    I would guess that the problem is lack of flow-control on the serial port.  You don't have any flow-control enabled on the device, so it's going to transmit characters continuously even if the other end is not ready for it.  Do a "man stty" to see all the serial port configuration, and you can do a "stty </dev/ttyS0" to see what the configuration of the port is.

    When you use ser2net, it's going to set it to whatever you have in the configuration.  Which, in this case, is none.  I'd guess you need to add RTSCTS as an option.  Also, if you have the start/stop bits, parity, number of bits, etc set wrong it can do strange things, too.