Socat to UDP Server Truncating Last Character

192 Views Asked by At

So I am working on a Serial to UDP gateway to link a point of sale printer to a NVR that can overlay the transactions on the Camera video (When the POS unit prints on the serial printer, this unit taps into the serial data to the printer, then on the NVR screen you will see the text of what the serial printer.

Here is my code so far :

/usr/bin/socat -d -d -d -u file:/dev/ttyUSB0,b19200,nonblock exec:/usr/bin/strings |/usr/bin/socat -d -d -d -u - udp:10.0.1.3:37777,reuseaddr,sourceport=51470,reuseaddr

The first Socat instance reads the data going to the printer. Passes it to strings to strip the non ascii data, then the 2nd socat instance passes it onto the NVR.

This is working fine, however on the NVR, for some reason it is missing the last letter in each line. It might be reading the newline, and somehow ignoring the last character. What I need to do is figure out why it is doing this, or possibly easier, just add a dummy character before the newline character.

This is what the first socat and Strings produces

    Thank you please call again
    Gratuity........................
    Total...........................
    Please Do Not Accept Any
    Hand Written Changes
    To This Bill !!!

This is what the NVR is printing out

    Thank you please call agai
    Gratuity.......................
    Total..........................
    Please Do Not Accept An
    Hand Written Change
    To This Bill !!

A hexdump of what the first socat and strings produces is (the 0A i believe is the newline code)

00005030: 323a 3139 2054 6f74 616c 2044 7565 2020  2:19 Total Due
00005040: 2020 2020 2020 1b21 2032 3033 332e 3030        .! 2033.00
00005050: 1b21 000a 1b76 1b45 000a 1b45 0020 201b  .!...v.E...E.  .
00005060: 4500 2020 2020 5641 5420 2020 2020 2020  E.    VAT
00005070: 2020 2020 2020 2020 2020 2020 2020 2020
00005080: 2032 3635 2e31 370a 1b76 1b45 000a 1b45   265.17..v.E...E
00005090: 0020 201b 4500 2020 2020 5468 616e 6b20  .  .E.    Thank
000050a0: 796f 7520 706c 6561 7365 2063 616c 6c20  you please call
000050b0: 6167 6169 6e0a 1b76 1b45 0020 201b 4500  again..v.E.  .E.
000050c0: 2020 0a1b 761b 4500 2020 1b45 0020 2020    ..v.E.  .E.
000050d0: 2047 7261 7475 6974 792e 2e2e 2e2e 2e2e   Gratuity.......
000050e0: 2e2e 2e2e 2e2e 2e2e 2e2e 2e2e 2e2e 2e2e  ................
000050f0: 2e0a 1b76 1b45 0020 201b 4500 2020 0a1b  ...v.E.  .E.  ..
00005100: 761b 4500 2020 1b45 0020 2020 2054 6f74  v.E.  .E.    Tot
00005110: 616c 2e2e 2e2e 2e2e 2e2e 2e2e 2e2e 2e2e  al..............
00005120: 2e2e 2e2e 2e2e 2e2e 2e2e 2e2e 2e0a 1b76  ...............v
00005130: 1b45 0020 201b 4500 2020 0a1b 761b 4500  .E.  .E.  ..v.E.
00005140: 2020 1b45 0020 2020 2050 6c65 6173 6520    .E.    Please
00005150: 446f 204e 6f74 2041 6363 6570 7420 416e  Do Not Accept An
00005160: 790a 1b76 1b45 0020 201b 4500 2020 2020  y..v.E.  .E.
00005170: 4861 6e64 2057 7269 7474 656e 2043 6861  Hand Written Cha
00005180: 6e67 6573 0a1b 761b 4500 2020 1b45 0020  nges..v.E.  .E.
00005190: 2020 2054 6f20 5468 6973 2042 696c 6c20     To This Bill
000051a0: 2121 210a 1b76 1b45 000a                 !!!..v.E..

Thanks for any help

0

There are 0 best solutions below