6 ms·
Let SOcket CAT Be Thy Glue over Serial
- oarsinsync 7y agoAlso, 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-screen-set-baud-rate/ https://www.cyberciti.biz/faq/unix-linux-apple-osx-bsd-scree... if you dislike reading the entire man page for screen(1).
- fla 7y agoThere's a very nice write up about the socat command line interface here [1] in case anyone is interested. [1] https://medium.com/@copyconstruct/socat-29453e9fc8a6 https://medium.com/@copyconstruct/socat-29453e9fc8a6
- astrobe_ 7y agoIf you want neither Minicom nor Screen, and Socat is a bit too minimal, there is dterm[1] [1] http://www.knossos.net.nz/resources/free-software/dterm http://www.knossos.net.nz/resources/free-software/dterm
- tyingq 7y agoOn the other end of the scale, if minicom doesn't have enough features, there's Kermit. Especially handy if you need to script "expect" style functionality over serial. http://www.kermitproject.org/ http://www.kermitproject.org/
- tyingq 7y agoI 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
- Aloha 7y agoI agree with the assertion by the tmux maintainers that screen probably shouldn't do it either.
- throwaway2048 7y agowhats the advantage over just using something like cu inside a tmux window? https://man.openbsd.org/cu.1 https://man.openbsd.org/cu.1
- durkie 7y agoOne issue with using screen for these purposes is that it will silently drop \xFF bytes. In my case I was trying to pull an image off of an Arduino or RPI connected camera, and my images would arrive like 99% accurate (mostly correct headers etc) but would not open in any image viewing program. Took a long time before I realized that transferring the data via screen was causing the corruption.
- tyingq 7y agoThat's somewhat curious. Do you know why screen does anything special with 11111111?
- prussian 7y agoThe problem with this, and likely why the post was made in the first place, is screen and many other solutions are basically just a terminal emulator on your existing terminal emulator and may cause problems. screen for instance seems to make snippets I use to resize serial terminals nonfunctional, likely because it does not implement things the same as xterm-like terminals.
- gh02t 7y agoFor a standard serial terminal I also really like the `miniterm.py` script that is included with the PySerial Python package. miniterm.py /dev/ttyUSB0 115200 It's just a basic serial terminal but it covers all of my use cases (mostly interfacing with embedded devices).
- erinaceousjones 7y agosocat + "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 7y agoI'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 7y agoDo you have any page describing it?
- rubatuga 7y agoI'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
- ac29 7y agoIs it actually a FM transmitter, or is it FSK? Or something like AFSK?
- rubatuga 7y agoRight, it is AFSK. The FM transmitter is something off the shelf, for car radios and such, meaning it has a low pass filter installed, along with spitting out a 19khz stereo carrier.
- wefwef4 7y agoI thought this was about the old google ctf challenge...
- emilfihlman 7y ago//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 7y agoSince 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 7y agoffmpeg (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.
- rubatuga 7y agoI agree with you, it has some bad parsing bugs if you actually want characters like commas and colons as arguments.
- cellularmitosis 7y agoSlightly 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
- dbolgheroni 7y agoDo you consider you're on a secure network?
- rubatuga 7y agoWouldn't netcat be easier?
- cellularmitosis 7y agoSome 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.
- carapace 7y agoWhat's the difference between netcat and socat?
- exabrial 7y agoAGH 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.
- novamostra 7y agoIn 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-gadget/ https://novamostra.com/2020/05/15/rasperry-pi-as-a-usb-gadge... and here https://novamostra.com/2020/05/15/rasperry-pi-as-a-usb-gadget/ https://novamostra.com/2020/05/15/rasperry-pi-as-a-usb-gadge... 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.