Configuration Overview

What is a Command Reader?

Command Readers are the objects that handle the processing of individual serial commands. Each serial command that comes in is processed by each Command Reader, and once a Command Reader returns a valid response, the next Command Readers will skip processing the command. This allows you to change the behavior of individual commands by defining new Command Readers.

Canned Queries

The most basic Command Reader is the CannedQueries Command Reader. This Command Reader has you define a series of commands and a responses, and then when a command comes in, it will return the next matching response for that command. It will iterate through the subset of matching commands (ex: all “get sn\r”), until it reaches the end. There are ways with Hooks to define the behavior of what happens when it reaches the end.

You can see a more in-depth tutorial on CannedQueries here.

Getters And Setters

Another useful Command Reader is the GettersAndSetters Command Reader. This Command Reader manages the state of a number of attributes which you can access with getters and set with setters. It initializes some default values and stores those values in the attribute. These attributes can then be modified with setters, and then grabbed from the getters. Both getters and setters allow configuration with using Jinja2 formatting.

You can see a more in-depth tutorial on GettersAndSetters here.

What is a Hook?

Hook is a class that is associated with a Command Reader or set of Command Readers and runs extra code at a predefined location. Before each Command Readers's get_reading() method, a Hook can be ran, via pre_reading(), processing the incoming data, saving information about it for later, modifying it, or any other useful actions. Alternatively, a Hook can run after get_reading(), via post_reading(), altering the resulting response, using information from prior state, or other more sophisticated techniques.

For information on creating your own hooks, see base_hook

Moving to 0.9.0 from a previous release