I am currently trying to log all communication from and to /dev/ttyUSB0 and simultaneously be able to connect minicom/screen to the same device for interaction.

I tried a couple of tools and tutorials but they all seem to occupy the device, so I can not connect to it with a terminal program.

Then I came across socat. It sounds promising, though it is able to redirect the /dev/ttyUSB0 to a PTS and log the transfered data to a file.

The idea is:

HW - /dev/ttyUSB0 <---> socat/logging <---> /dev/ptyX <---> minicom

Has anyone done this before?

Any help is appreciated. Chris

  • minicom and screen already have some logging options. what extra do you want from your log? do you want to merge rx and tx or keep them in separate files, add timestamps, ... ?
    – meuh
    Jul 14, 2017 at 8:06
  • I want a seperate process for logging because it is a remote machine where I can not leave my terminal progam open.
    – Chris
    Jul 14, 2017 at 8:09

1 Answer 1


You can certainly put an intervening socat in the way, and use its logging facilities. For example,

socat -v /dev/ttyUSB0,b19200,raw  PTY,link=$HOME/myserial,raw,echo=0 2>logfile &
minicom -p $(readlink $HOME/myserial)

This will log the data read in each direction, shown by ">" or "<":

< 2017/07/14 14:33:58.210584  length=3 from=0 to=2
> 2017/07/14 14:33:58.214745  length=3 from=0 to=2
  • 1
    This answer pointed me towards the right direction when I noticed that the exact command (except for /dev/ttyS0 and b9600) worked whereas my earlier attempts failed (input to the terminal was sent to the box connected by physical serial port, but output from the box never showed up in socat logging output nor the terminal application). The problem was that I had specified the option rawer instead of raw, and that doesn't work for whatever reason. Details at github.com/dosemu2/dosemu2/discussions/1738
    – ecm
    Jul 20, 2022 at 19:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .