Device Drivers
Last updated
Last updated
Device drivers implement a protocol on a raw transport stream, TCP or UDP. For examples see our open repository of device modules.
Backoffice can be used to define settings.
Use Transport Layer Security (TLS) for encrypted communications
UDP for stateless communication (UDP connections are always considered connected)
Multicast IP’s are automatically detected and subscribed to the multicast group
Use Make Break if you want the module to disconnect when there is nothing to communicate
Some devices require you work this way, this helps automate the process
Requests are added the transmit queue by calling send(raw_cmd, options_hash)
.
The raw_cmd
can be in a number of formats:
String => will be transmitted as is
Array of bytes => will be automatically converted to a string for sending
Hex String => will be converted to a binary string if requested send('0xbeef', hex_string: true)
The options are as follows:
Option | Default Value | Description |
| true | do we want to wait for a response before we continue processing |
| 0 | minimum delay time between sends (milliseconds) |
| 0 | time to delay the next transmit after receiving data (milliseconds) |
| 3 | number of times we’ll accept an ignore response before retrying the request |
| 2 | number of times we’ll retry a command if it has failed |
| 5000 | amount of time we’ll wait for a response to a command before retrying (milliseconds) |
| 50 | so we can perform commands in preference to others (see section on priorities) |
| false | causes the transport to disconnect once a response has been received |
| nil/false | removes any other queued commands once it starts transmitting |
| nil | command type (e.g. |
| nil | callback to occur when that request completes. Will not be called if another request with the same name overrides this request. |
| nil | alternative receive function or block. Called in stead of |
It’s expected that the received
function or on_receive
callback return a result for the current command. When data is received, this function is called to see if
The command was a success
This data has nothing to do with the command in question
Some devices push data
Some kind of failure
The expected values that should be returned by this function:
Value | Description |
| We’ve finished processing this command, move on to the next |
| The command didn’t have the desired result, maybe the device was busy. Please send this command again |
| This data was not in response to our action. Continue waiting. |
| The command failed and it should not be retried. Abort differs from success as it is logged. |
| Waits for the command to resolved by the deferrable passed to the |
Priorities ensure requests are processed in a sane order. For example if you are polling a projector for status and it only accepts one command every 300 milliseconds you don’t want to wait for the polling, which might be 4 or 5 requests, to complete before executing a more important request like selecting a new input.
Sometimes a query might be made for control flow purposes so it is often useful to differentiate between user initiated requests and polling.
Priorities are also increased on a contextual basis. This is how retries, for instance, make their way back to the front of the queue - which is what you would expect. There is a configuration option called priority_bonus
which increases the priority of a command in the following circumstances:
Any request made when processing a response to a request
If you request volume status whilst processing the switching of an input, the query will receive a bonus and jump towards the front of the queue
When a command fails and is retried, it also receives a bonus.
NOTE:: given default values, if you send commands in the received function and then return failed so the command is retried, the commands sent will be executed before the retry. You can counter this effect by providing lower priorities in this context.
Helper functions interact with the local state of a driver. Defining a setting, for instance, will not overwrite any shared system state.
Name | Description |
| disconnects the current connection. It does not wait to send any buffered data |
| returns the IP address or hostname defined in the database |
| returns the port number defined in the database |
| allows you to set custom default options for commands |
| allows you to set custom processing configurations |
| overrides the default connection indicator (useful for UDP devices) |
| persists a setting value in the database that impacts the current driver instance |
For the various defaults and configuration options see the command processor.
When you include ::Orchestrator::Constants
some common configuration and default options are exposed in a more declarative manner.