SLSNIF(1)

πŸ“¦ version 0.4.4, in nixos 26.05, nixpkgs unstable

πŸ¦‹ slsnif(1) β€” the serial line sniffer πŸ¦‹

Manual name: slsnif(1). Category: Debug. Okay bestie, buckle up πŸ’–


🌸 NAME 🌸

slsnif β€” serial line sniffer, aka your little wiretap for serial traffic ✨


🌈 SYNOPSIS 🌈

slsnif [-b]  [-l logfile]  [-i file]  [-o file]  [-s speed]  [-t]  [-x]
       [-p port2] [--color color] [--timecolor color] [--bytescolor color] [-n]
       [-u] port1

πŸ’… DESCRIPTION πŸ’…

Okay so slsnif is serial line sniffer software, fr fr. It listens to the serial port you specify and writes all data coming through it into either stdout β€” that's the default β€” or a log file if you specify one with option -l.

It operates either by creating a pseudo tty (pty) and linking it to the serial port, or by linking two serial ports together. To set up a debug session, you either start slsnif on a given port first, note the pty it opened β€” also available from file /tmp/slsnif_pty while slsnif is running β€” then configure the controlling software for the device being debugged to use this pty instead of the actual port. Or, if you're using two ports, just start slsnif on two ports (see option -p) and watch the show :)

Note 1: slsnif will try to match port settings on pty and port (or on 1st and 2nd ports) as soon as it detects the first chunk of data coming from the "host side" (which is either pty or 2nd port). If it fails β€” in case of a braindead controlling software that doesn't set the baudrate correctly β€” one has an ability to set baudrate by hand via option -s. Controlling software and slsnif should be set up to use the same baudrate, which in turn should match the baudrate used by the device connected to the port.

Note 2: If controlling software is running under vmware (www.vmware.com) and pty is used, the port in question should be disconnected from vmware before invoking slsnif, and connected to the opened pty after slsnif has been started. πŸ’€

πŸŽ€ PARAMETERS πŸŽ€

slsnif accepts the following parameters:

  • <port1> (required) β€” first serial port to listen to (and the only one in case of pty being used). Examples: /dev/ttyS0, /dev/ttyS1, etc. 🫢

✨ OPTIONS ✨

  • -l logfile, --log logfile β€” file to direct output to. Output is sent to stdout by default.
  • -i in-file, --in-tee in-file β€” file to dump raw data from device to. Multiple -i / --in-tee arguments result in multiple copies of data in corresponding files.
  • -o out-file, --out-tee out-file β€” file to dump raw data from host to. Multiple -o / --out-tee arguments result in multiple copies of data in corresponding files.
  • -s speed, --speed speed β€” baudrate to use. Valid options are: 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200. Defaults to 9600 baud.
  • -b, --bytes β€” print number of bytes transmitted on every read.
  • -p port2, --port2 port2 β€” use real serial port instead of pty. Useful when one needs to log data going between two ports.
  • -n, --nolock β€” disable locking of the port. Normally not a good idea, but can be very useful if one doesn't have permissions to write to the lock directory (usually /var/lock/).
  • -t, --timestamp β€” print timestamp for every transmission.
  • -x, --hex β€” display hexadecimal ascii values.
  • -u, --unix98 β€” use SYSV (Unix98) ptys instead of BSD ptys.
  • --color color β€” color to use for normal output.
  • --timecolor color β€” color to use for timestamp.
  • --bytescolor color β€” color to use for number of bytes transmitted. Valid <color> values are: black, red, green, yellow, blue, magenta, cyan, white, brightblack, brightred, brightgreen, brightyellow, brightblue, brightmagenta, brightcyan, and brightwhite.
  • -h, --help β€” display help.

🧚 RC FILE 🧚

The following options can be specified via rc-file .slsnifrc, which should be located in the user's home directory:

  • TOTALBYTES ON/OFF β€” corresponds to -b (--bytes).
  • TIMESTAMP ON/OFF β€” corresponds to -t (--timestamp).
  • DISPLAYHEX ON/OFF β€” corresponds to -x (--hex).
  • NOLOCK ON/OFF β€” corresponds to -n (--nolock).
  • SYSVPTY ON/OFF β€” corresponds to -u (--unix98).
  • COLOR <color> β€” corresponds to --color <color>.
  • TIMECOLOR <color> β€” corresponds to --timecolor <color>.
  • BYTESCOLOR <color> β€” corresponds to --bytescolor <color>.

Options specified via command line always override the ones specified via rc-file. Periodt πŸ’…


πŸ”₯ EXAMPLE πŸ”₯

slsnif -n -l log.txt -s 2400 /dev/ttyS1

        Started logging data into file 'log.txt'.
        Opened pty: /dev/ttyp0
        Saved name of the pty opened into file '/tmp/slsnif_pty'.
        Opened port: /dev/ttyS1
        Baudrate is set to 2400 baud.
Note: pty slsnif has opened is /dev/ttyp0.

πŸ’œ SIGNALS πŸ’œ

SIGHUP signal causes slsnif to move file pointer in all log files back to the beginning. This is useful for example when logfiles are rotated by logrotate. SIGUSR1 signal causes slsnif to re-synchronize settings between ttys at any time. Useful for debugging software that changes port settings in the middle of transmission. πŸ¦‹


🌟 SEE ALSO 🌟

setserial(8), stty(1).


πŸ‘‘ AUTHOR πŸ‘‘

Yan Gurtovoy <ymg@dakotacom.net>.


Cute footer sign-off, bestie: Yan Gurtovoy, version 0.4.4, manual SLSNIF(1) β€” no date printed, just iconic legacy energy πŸ’–βœ¨

πŸ“¦ where this page comes from