
Let SOcket CAT Be Thy Glue over Serial - todsacerdoti
https://bloggerbust.ca/post/let-socket-cat-be-thy-glue-over-serial/
======
oarsinsync
Also, try `screen`

    
    
      screen /dev/ttyS0 
      screen /dev/ttyUSB0 115200
    

You can specify baud rate (defaults to 9600), and a number of other
parameters. Some of these are nicely documented at
[https://www.cyberciti.biz/faq/unix-linux-apple-osx-bsd-
scree...](https://www.cyberciti.biz/faq/unix-linux-apple-osx-bsd-screen-set-
baud-rate/) if you dislike reading the entire man page for screen(1).

~~~
tyingq
I imagine many will go see if tmux does it as well. Tmux appears to not want
that feature:
[https://github.com/tmux/tmux/issues/1862](https://github.com/tmux/tmux/issues/1862)

~~~
throwaway2048
whats the advantage over just using something like cu inside a tmux window?

[https://man.openbsd.org/cu.1](https://man.openbsd.org/cu.1)

------
erinaceousjones
socat + "everything as a file" lets you network up stuff only designed to be
used over a serial link too, which I've found super useful. Wireless
calibration of a drone using software that only supports USB serial? Hook it
up to a raspberry pi in AP mode, stick some socats with udp on one side and
/dev/ttyUSB0 on the other, boom, now you can talk to the flight controller
untethered with 10 minutes reading the man page for socat and some trial and
error.

~~~
rubatuga
I'm using socat to emulate a PTY that I then run a PPP link over. socat gets
its byte stream from an RTL-SDR and send out data using a tiny FM transmitter.
After setting up these on both computers, I was able to SSH and ping google
over FM radio.

~~~
dbolgheroni
Do you have any page describing it?

~~~
rubatuga
I'll be uploading a video to my youtube channel in the coming weeks! Part 1
will be describing the link layer. Part 2 will be full duplex communication.

[0]:
[https://www.youtube.com/channel/UCsRWsHhvzSoMgVfiNhy0NoA](https://www.youtube.com/channel/UCsRWsHhvzSoMgVfiNhy0NoA)

------
cellularmitosis
Slightly off topic, but socat and lzop are my favorite utilities for shuttling
data around a local network at high speed.

Backing up a disk:

    
    
        alice$ pv /dev/sda | lzop | socat - tcp:bob:1234
        bob$ socat tcp-listen:1234 - > alice.sda.lzo
    

Copying a bunch of files:

    
    
        alice$ tar c dir | lzop | socat - tcp:bob:1234
        bob$ socat tcp-listen:1234 - | lzop -d | pv | tar x

~~~
rubatuga
Wouldn't netcat be easier?

~~~
cellularmitosis
Some versions of netcat have no way of closing the connection when the file is
finished transferring. You just have to wait long enough and then hit
control+c.

------
novamostra
In case anybody is interesting, over the last month I used socat as a simple
way to transfer serial over IP. Here you can see the "sending" part
[https://novamostra.com/2020/05/15/rasperry-pi-as-a-usb-
gadge...](https://novamostra.com/2020/05/15/rasperry-pi-as-a-usb-gadget/) and
here [https://novamostra.com/2020/05/15/rasperry-pi-as-a-usb-
gadge...](https://novamostra.com/2020/05/15/rasperry-pi-as-a-usb-gadget/) you
can see how you can redirect input from a remote serial device or the local
UART port of a Raspberry PI to the Gadget port using socat.

------
exabrial
AGH omg I've needed this. I'm connecting a few Digimesh nodes to Arduinos,
Macs, and RPIs. Sometimes I just need to reproduce a problem by sending the
raw transmission again a few times. I've used minicom, but it's a "little too
much" tool for the job.

On OSX I haven't been able to get screen to work properly, not sure why; I've
just used minicom.

------
emilfihlman
//Opinion

The issue with socat (and some other tools) is the esoteric argument syntax.
Arguments should always be passed as "-s arg" for short option names, or more
preferably "\--long-name argument" as long names, and multiple different
things should be passed as multiple different arguments instead of some
crammed way.

~~~
tyingq
Since you can specify several devices on one command line, that might make the
number of options too high.

The "cramming" allows the 2nd, 3rd, etc, argument to contextually tie to the
first. Like: _" /dev/ttyUSB0,b115200,rawer"_

~~~
Hello71
ffmpeg (and some other programs) has a different solution to this: options
apply to the succeeding non-option argument: ffmpeg -f wav infile -f mp4
outfile means to convert the wav infile to an mp4 outfile. of course, nobody
ever reads the manual, so they use it wrong.

------
carapace
What's the difference between netcat and socat?

------
wefwef4
I thought this was about the old google ctf challenge...

