Author Topic: Help Using socat  (Read 677 times)

0 Members and 1 Guest are viewing this topic.

Offline GaryC50

  • Jr. Member
  • **
  • Posts: 1
  • Karma: 0
  • I've just joined!
    • View Profile
    • Awards
Help Using socat
« on: January 18, 2013, 01:38:14 pm »
Hi

I have a data stream being fed into a serial port that I wish to push out to the network (via UDP, either to a specific host, broadcast or multicast). The data is made up of a series of sentences of variable length but each terminated with a CR and LF.

So far I have been using socat with varying degrees of success.

If I use the following command:

socat /dev/ttyUSB0,echo=0,raw UDP4-DATAGRAM:192.168.0.8:8888

I end up with a packet being sent for every character in the input stream

If I then use stty to set the serial port to echo=0 and raw and try:

awk '{ print $0 }' /dev/ttyUSB0 | socat - UDP4-DATAGRAM:192.168.0.8:8888

I end up with each packet containing multiple sentences (I guess as many that can fit in the space defined by the MTU) and the last one in the packet is not always complete.

Does anyone know if there is a way of telling socat when to consider a packet as being complete, i.e. send the packet when you see the CR/LF combination?

Thanks

Gary


Online Mark Greaves (PCNetSpec)

  • Administrator
  • Hero Member
  • *****
  • Posts: 13192
  • Karma: 321
  • Gender: Male
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
    • Awards
Re: Help Using socat
« Reply #1 on: January 18, 2013, 02:44:27 pm »
OK, I have no idea how to use socat .. but reading through the man page seems to suggest the use of the "crnl" option.

So maybe:
Code: [Select]
socat /dev/ttyUSB0,raw,echo=0,crnl UDP4-DATAGRAM:192.168.0.8:8888
?

For future reference:
http://www.dest-unreach.org/socat/doc/socat.html
« Last Edit: January 18, 2013, 02:46:05 pm by Mark Greaves (PCNetSpec) »
WARNING: You are logged into reality as 'root'

logging in as 'insane' is the only safe option.

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal