Open IsaacJT opened 3 years ago
Hmm, can't this be achieved outside picocom with 'inotifywait'? The added code is not small and not portable, so I'd like to keep the solution to this problem in the scripts calling picocom.
@wsakernel can you give me a hint how to do something like this with inotifywait
?
i have no idea - the examples i found all seem very complex..
i tested with
#!/bin/bash
inotifywait -m /dev --include 'ttyACM0' |
while read dir action file; do
echo "The file '$file' appeared in directory '$dir' via '$action'"
# do something with the file
# picocom /dev/ttyACM0 --baud 115200;
done
and for my device get
$ pico_.sh
Setting up watches.
Watches established.
The file 'ttyACM0' appeared in directory '/dev/' via 'ATTRIB'
The file 'ttyACM0' appeared in directory '/dev/' via 'DELETE'
The file 'ttyACM0' appeared in directory '/dev/' via 'CREATE'
The file 'ttyACM0' appeared in directory '/dev/' via 'ATTRIB'
The file 'ttyACM0' appeared in directory '/dev/' via 'ATTRIB'
The file 'ttyACM0' appeared in directory '/dev/' via 'CLOSE_NOWRITE,CLOSE'
The file 'ttyACM0' appeared in directory '/dev/' via 'ATTRIB'
The file 'ttyACM0' appeared in directory '/dev/' via 'DELETE'
The file 'ttyACM0' appeared in directory '/dev/' via 'CREATE'
The file 'ttyACM0' appeared in directory '/dev/' via 'ATTRIB'
The file 'ttyACM0' appeared in directory '/dev/' via 'ATTRIB'
The file 'ttyACM0' appeared in directory '/dev/' via 'CLOSE_NOWRITE,CLOSE'
so i would have no idea what event i should use...
maybe the CLOSE_NOWRITE,CLOSE
...
just found your example at https://gitlab.com/wsakernel/picocom/-/issues/2
#!/bin/sh
port="${1:-/dev/ttyUSB0}"
while :; do
picocom "$@"
inotifywait -qq -e attrib --include="$(basename $port)" "$(dirname $port)"
done
If configured with inotify support in the Makefile, picocom will wait for the serial port to appear rather than immediately exiting.
As inotify is only available on Linux, this functionality will only be activated when running under Linux.