-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support for waiting for the serial port and reconnecting after the device is closed #122
base: master
Are you sure you want to change the base?
Conversation
If configured with inotify support, picocom will wait for the serial port to appear rather than immediately exiting.
- When tty device is lost, the application will now notice and try to reconnect.
Add support for reconnecting to lost tty device.
wait similar to what was suggested here: npat-efault/picocom#122
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 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... |
just found your example at #!/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.