2

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 '17 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 '17 at 8:09
3

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
hi
> 2017/07/14 14:33:58.214745  length=3 from=0 to=2
hi

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.