lager drivers install. Then every user
can drive its nets with the standard CLI. The driver code is stored on the box
only.
Bundle layout
pyserial and the lager
package that is on the box.
The manifest
The manifest gives the driver’s type, its net settings and its actions. The CLI builds thelager <type> command from it, and the box checks every call against
it.
Each param and arg has a
type: str, int, float, bool or choice. A param
can also be net, which names another saved net of the given role; the driver
then uses that net to reach the hardware. Fields can also have required,
default, min and max (numbers only), choices (for choice) and help.
Names are lower case letters, digits and _; the CLI shows hold_time as
--hold-time.
The driver
- Only methods marked with
@actioncan be called, and each must be named in the manifest. The method gets the action’s args as keyword arguments, with the types the manifest gives. setup()runs before the action andteardown()runs after it, also when the action raises an exception.- Return a dict, a value or
None. A dict’smessageis printed by the CLI; the other keys are shown below it, and--jsonprints the whole result. - An exception becomes an error for the user, with its type and message.
print()output andself.loggo to the box log, not to the user.
How a call runs
Each call runs the driver in a new process on the box. A driver that crashes or hangs cannot stop the box. The box loads Lager before the call, so the process starts quickly. It loadsdriver.py again for each call, so an
installed update takes effect on the next call. Two calls on the same net run one after the other. If a
lager uart session holds the UART net that the driver uses, the call is refused
until that session closes.
Using a driver from a script
Alager python script can use a custom net directly:
Install and use it
lager python script. It is
kept out of the public Lager code, but a person who can connect to the box can
read it.
