Added support for waiting for the serial port and reconnecting after the device is closed#122
Open
IsaacJT wants to merge 4 commits intonpat-efault:masterfrom
Open
Added support for waiting for the serial port and reconnecting after the device is closed#122IsaacJT wants to merge 4 commits intonpat-efault:masterfrom
IsaacJT wants to merge 4 commits intonpat-efault:masterfrom
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.
5frank
added a commit
to 5frank/spcom
that referenced
this pull request
Feb 10, 2021
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;
doneand 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.