最終更新:2025-01-21 (火) 13:54:25 (17d)
grabserial
Top / grabserial
help
Usage: grabserial -d <device> [options] Grabserial reads data from a serial port, processes it, and outputs it. It is much more flexible than a simple 'cat' command. It keeps track of timing data, and can record when a pattern is seen in the data. It can show timing data for every line received. It can save the data to a file and can quit or restart based on a timeout or when a pattern is seen. It can split the data into multiple files based on timeout or a pattern. It supports interactive writing to the serial port during data collection. It is useful for things like: 1. capturing and annotating data from a serial port 2. logging data to multiple files 3. timing events in a stream of data (such as how long it takes a Linux kernel to boot) 4. executing commands to a serial console. Options: -h, --help Print this message -d, --device=<devpath> Set the device to read (default '/dev/ttyS0') -b, --baudrate=<val> Set the baudrate (default 115200) -B <val> Force the baudrate to the indicated value (grabserial won't check if the baudrate is legal) -w, --width=<val> Set the data bit width (default 8) -p, --parity=<val> Set the parity (default N) -s, --stopbits=<val> Set the stopbits (default 1) -x, --xonxoff Enable software flow control (default off) -r, --rtscts Enable RTS/CTS flow control (default off) -f, --force-reset Force pyserial to reset device parameters -e, --endtime=<secs> End the program after the specified seconds have elapsed. -c, --command=<cmd> Send a command to the port before reading -t, --time Print time for each line received. The time is when the first character of each line is received by grabserial. -a, --again Restart application after -e expires, -q is triggered, or the serial device is disconnected. -R, --rotate=<time> Rotate logs every <time> period. Time is in seconds. -T, --systime Print system time for each line received. The time is the absolute local time when the first character of each line is received by grabserial. -F, --timeformat=<val> Specifies system time format for each received line e.g. -F "%%Y-%%m-%%d %%H:%%M:%%S.%%f" (default "%%H:%%M:%%S.%%f") -m, --match=<pat> Specify a regular expression pattern to match to set a base time. Time values for lines after the line matching the pattern will be relative to this base time. -i, --inlinepat=<pat> Specify a regular expression pattern to have its time reported at end of run. It works mid-line. -q, --quitpat=<pat> Specify a regular expression pattern to end the program. It works mid-line. -l, --launchtime Set base time from launch of program. -o, --output=<name> Output data to the named file. Uses: %%Y-%%m-%%dT%%H:%%M:%%S on "%%". -A, --append Append (rather than overwrite) output data to the file specifed with -o option -Q, --quiet Silent on stdout, serial port data is only written to file, if specified. -v, --verbose Show verbose runtime messages -V, --version Show version number and exit -S, --skip Skip sanity checking of the serial device. May be needed for some devices. This option is required if you want grabserial to continue running and attemp re-connections after the serial device has been disconnected. -n, --nodelta Skip printing delta between read lines. --crtonewline Promote a carriage return to be treated as a newline -C, --command-mode Perform a single command on the serial port, and omit command echo and shell prompt from output. Must be used with -c and -q options, with the argument to -q being interpreted as the prompt returned after the command completes. Ex: grabserial -e 30 -t -m "^Linux version.*" This will grab serial input for 30 seconds, displaying the time for each line, and re-setting the base time when the line starting with "Linux version" is seen.