4

I would like picocom to log serial data on a remote computer, without having to keep my ssh session to the remote computer alive.

I have tried:


picocom <my options>

This dies when I logout.


picocom <my options> & 

No output on terminal, and exiting picocom with C-a C-x leaves the job as stopped, it doesn't kill it (I need to kill -9, a simple kill on the job does not work. I then have to manually clean the tty lock in /var/lock/).


picocom <my options> > tmp/data.log&

then in another ssh session:

tail -f tmp/data.log

No data cames out in the file data.log.


bash -c "picocom --baud 115200 /dev/ttyACM1 > /home/pi/tmp/data.log" &

No output to the file either. The job becomes "Stopped" right away.


nohup sh -c "picocom --baud 115200 /dev/ttyACM1 > /home/pi/tmp/data.log" &

I get the start output of picocom in the tailed file, but then the job is exited.


Good to know as well: picocom does not react to C-z.

My questions are:

  • is it at all possible to run picocom in the background?
  • what alternatives are there to log serial terminal without an open session?

3 Answers 3

3

An alternative is to setup the device with stty, then read it with cat:

stty <my options>
nohup sh -c "cat /dev/ttyACM0 > data.log" &
1

I suggest using dtach. dtach allows you to run programs in the background. I have been successfully using it with picocom to do serial logging without an open session (on a remote Raspberry Pi).

I also recommend using picocom's built-in logging -g to save serial data to a file.

Once you have dtach installed, you can run it with picocom like;

dtach -A /tmp/dtach picocom --baud 115200 /dev/ttyACM1 -g /home/pi/tmp/data.log

then once picocom is running, you can put it in the background with C-\

to rejoin the "dtached" process use;

dtach -a /tmp/dtach

I have found that picocom does write to the log file in the background, so I can cat /home/pi/tmp/data.log with picocom still running but "dtached"

0

Assuming the user session is meant, you might be able to use screen with the -X option to send commands to a running screen session and the stuff command to send keystrokes to the current window.

screen -dmS newScreen bash
screen -S newScreen -X stuff "picocom <options>\n"
screen -ls
screen -r <pid>

Please take note to put the quotes around and the next line in order for the commands to be executed. *

... haven't checked if bash -c or tmux would be possible too.

You must log in to answer this question.

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