Command
A command is a call to do something. This can be to e.g. change the chip state, do an RPC-like call or to start a radio transmission.
It defines an operation on the block it’s part of. Command functionality is implemented in the runtime through the CommandOperation which can be used to dispatch the command.
Tip
While registers could be modelled as a command, this would be spiritually wrong. A device is supposed to do something when a command is dispatched. It can do something on its own or based the input data. And when the action is done there may be an output.
Examples would be starting radio transmission or putting the device to sleep.
Example usage:
let mut device = MyDevice::new(DeviceInterface::new());
// Dispatch the foo command
device.foo().dispatch()?;
// Commands carry data when in and/or out fields are specified
let result = device.bar().dispatch(|data| data.set_val(1234))?;
assert_eq!(result.quux(), true);
Example
/// doc comment line
command Example[8 stride 4] {
address: 0,
address-overlap: allow,
fields-in: MyFieldset,
fields-out: MyFieldset,
}
Table
| Property | Value |
|---|---|
| Identifier namespace | Operation |
| Supports repeat | yes |
| Supports basetype | no |
| Supports conversion type | no |
| Supports short properties | no |
| Supports properties | yes, see below |
| Supports subnodes | no |
Long properties
These properties are specified in the node body.
address
The address of the command
// number
address: 0
Info
- required:
yes - multiple allowed:
no - supports doc comments:
no
address-overlap
Allows addresses to overlap with other commands. This is not allowed by default to prevent copy-paste mistakes.
// allow
address-overlap: allow
Info
- required:
no - multiple allowed:
no - supports doc comments:
no
fields-in
The fieldset that represents the input data of the command. This can be a reference to an existing fieldset or a completely new inline fieldset.
// type reference
fields-in: MyFieldset,
// sub node
fields-in: fieldset MyFieldSet
Info
- required:
no - multiple allowed:
no - supports doc comments:
no
fields-out
The fieldset that represents the output data of the command. This can be a reference to an existing fieldset or a completely new inline fieldset.
// type reference
fields-out: MyFieldset,
// sub node
fields-out: fieldset MyFieldSet
Info
- required:
no - multiple allowed:
no - supports doc comments:
no