2

For the serial terminal program choices, we have hyperterminal and putty on Windows; minicom and screen on Linux/Mac. But as far as I know, none of these has the message filtering functionality as described below:

What I need is some message filtering capability. The black box device I have is outputting lots of verbose messages, only a tiny of which are interested to me. I would like filter out those noises, but still keep the terminal interactive so I can input commands.

Any suggestions?

2 Answers 2

1

There is miniterm in Python that has filters, but you'll have to code Python classes as filters; see the source code of pyserial for examples:

https://github.com/pyserial/pyserial/blob/3a6ae5a630589a29af8d8bd45616d7aadb2fb3db/serial/tools/miniterm.py#L179

For instance, it has:

class CRLF(Transform):
    """ENTER sends CR+LF"""

    def tx(self, text):
        return text.replace('\n', '\r\n')

You could call miniterm with usage of this filter with:

python3 -m serial.tools.miniterm  --parity N --xonxoff --echo --eol CRLF /dev/ttyUSB1 9600

... and as these are "end of line" specific filters - note that there are additional filters via the --filter option ( see https://pyserial.readthedocs.io/en/latest/tools.html )

1
  • I haven't tested this but it seems reasonable. I will accept your answer. Thanks! Feb 14, 2020 at 20:20
1

If you don't need to push any output over the serial line, AFAIK you can just read from the serial device and use tools like grep for the filtering. I haven't tried that, though. Also you could look at the documentation of the tools you are using to see whether they're capable of logging all input to a file. You could then theoretically grep the file but in practice you would use a named pipe so that you can grep the output in real time.

1
  • 1
    You will need to configure the serial parameters first, since grep won't do it.
    – BatchyX
    Mar 29, 2014 at 10:41

Not the answer you're looking for? Browse other questions tagged .