Using the include CLI tool

In order to use the CLI tool, you must first create a null modem.

to execute the cli command simply invoke

python -m serial_mock.cli COMMAND`

the available commands are detailed below

CLI commands

to view help on a given command simply invoke the command with the -h or --help switch

you can optionally specify a verbosity level for screen output with -v <LOGLEVEL> BEFORE you invoke the {echo,bridge,build} command, this can be helpful for debugging

echo directive

the echo cli directive will bind a simple echo device to the specified bind port

python -m serial_mock.cli echo COMPORT

where COMPORT is one half of a pair of ports specified when you created a null modem.

bridge directive

the bridge cli directive will create a bridge between two points, optionally capturing the traffic to a log file for use with the build directive

_images/bridge_diagram.png
python -m serial_mock.cli bridge COMPORT1 COMPORT2 <options>

where COMPORT1 and COMPORT2 are the two ports you wish to bridge, typically one port will be an actual connected device and the 2nd port will be one end of a null modem that you created.

build directive

the build directive can convert a logfile created with the bridge directive, and convert it into a “playback” device, that will play back the responses from the bridged session

python -m serial_mock.cli build serial_output.txt --out=MySerialDevice.py

you can then serve your mocked serial port with

python MySerialDevice.py COM100

this will bind your mocked device to COM100, which will expose it at the other end of the null modem (COM99)