Skip to content

Scanner Scripts

dcyoung edited this page May 11, 2017 · 14 revisions

Work in Progress...

Scanner Scripts

The scanner/ directory contains various python scripts for scanning and testing. Normally the webapp will call these scripts using node's child process module. However, to make development easy, each script has a simple demo or main method that is callable directly from python like so:

# from inside the scanner/ directory
python script_name.py

For the sake of simplicity, inter-process communication (between the node webapp, and the python scripts) is accomplished by piping the printed output from the python process into the input of the node process. To make parsing the messages simple, anything that is printed from a python script is printed in JSON format. This keeps everything human readable in the terminal, and also makes it incredibly easy to parse the messages in the webapp. Sometimes these JSON messages can even be passed along to the client (browser) side front-end javascript, without requiring any processing.

Currently there are a few bugs in libsweep and sweeppy. Therefore the scripts are rather verbose in attempting to catch errors and shutdown. As the underlying sdk becomes more robust, so too will the scanner code. There is a lot of room to clean things up.

See the scanner/ README for more details about the individual scripts.

The code from the scanner/ directory requires:

  • python + numpy module
  • physical hardware (sweep sensor + raspberry pi + motor HAT + motors + limitswitch)
  • installation of libsweep or sweeppy

Dummy Version

The dummy_scanner/ directory contains dummy scripts that simulate the behavior of the normal scripts found in the scanner/ directory. These dummy scripts are used in place of the normal scanner code when the main node web application is run with the dummy flag.

node app.js -d

Just as with the normal scanner scripts, the dummy versions can also be tested directly:

# from inside the dummy_scanner/ directory
python script_name.py

Again, all scripts print in formatted JSON so the node webapp can easily parse the output.

The code from the dummy_scanner/ directory only requires:

  • python + numpy module

The following are NOT required:

  • any physical hardware (sweep sensor + raspberry pi + motor HAT + motors + limitswitch)
  • installation of libsweep or sweeppy