4

Occasionally I'm trying to debug a (usually serial) device that starts very quickly.

If I get the device running, I can connect to it using:

minicom -D /dev/ttyUSB0

Then, if the device disconnects, minicom stays open until it reconnects.

Is there a switch to tell minicom to open in this "waiting" state, even if the device has not yet been created?

I've tried -o (Do not initialize.)

1 Answers1

5

If all you want to do initially is capture all the output from the device you can use:

tail -F /dev/ttyUSB0

as this will wait until the device exists then read from it. If the device disappears and reappears, it will valiantly re-open it.


You can try creating a fifo and using minicom on this as the device. Then, in a loop, wait for the real device to appear, and open and connect it the fifo when it does, for example with socat. minicom will not see the re-opens.

mkfifo ~/myfifo
while sleep 1; do socat /dev/ttyUSB0,b19200,echo=0,raw ~/myfifo; done &
minicom -o -D ~/myfifo

b19200 is an example of setting the speed, which you can remove if it doesn't need to be set.

Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
meuh
  • 49,672
  • 2
  • 52
  • 114
  • Unfortunately, this doesn't allow me to interact with the device, merely to read it. :-( – tudor -Reinstate Monica- Jul 08 '15 at 00:36
  • @tudor I added a socat/fifo example for bidirectional use. – meuh Jul 08 '15 at 07:00
  • Ah! That's a smart way to think about it. :-) – tudor -Reinstate Monica- Jul 08 '15 at 23:53
  • This looked like a good idea, but didn't work in Ubuntu 22.04 unfortunately. I got three messages in this sequence: **1.** "tail: cannot open '/dev/ttyACM0' for reading: No such file or directory **2.** "tail: '/dev/ttyACM0' has appeared; following new file" **3.** tail: /dev/ttyACM0: cannot seek to offset 0: Illegal seek" – Seamus Nov 14 '22 at 07:45