Startup abstraction layer#
Above the standard layer, only two functions are added: pull()
,
and call()
.
No other elements will be added, so in order to provide a sandbox in a minimal way, you can simply remove these two functions.
The abstraction layer is event-based; all information is provided through events initially piled up, that help building the picture of what the computer’s physical system resembles.
Event interfaces#
All events are provided as tables with no additional metadata. These classes represent the properties present in such tables, and their types and roles.
- class Event#
An event on the component abstraction, as returned by
pull()
. Note that attributes include, but are not limited to the list provided below.- type: string#
Type of the event, to be used as a discriminator.
Bus events#
Device events#
- class DeviceAttachEvent: DeviceEvent#
Event raised when a device is attached.
- type: string#
Set to
"device_attach"
.
- bus: number#
Numeric identifier of the bus to which the device has been attached to.
- address: string#
The address the device was attached on the bus.
- device_type: string#
Type of the device, as documented in Device reference.
- class DeviceDetachEvent: DeviceEvent#
Event raised when a device is detached.
- type: string#
Set to
"device_detach"
.
Operations#
- pull(timeout_sec)#
Pull the next event out of the queue, while waiting for
timeout_sec
seconds at a maximum.Note
Fractional seconds are allowed and will be fulfilled within the underlying platform’s capabilities.
If
timeout_sec
is lesser or equal to 0, the function will return immediately with an event if available, or withnil
otherwise.Note
This function can also be used to sleep, in a power-saving effort. Therefore, if all your processes are either awaiting an external event or other processes, it is recommended to call this method with long timeouts.
If a timeout has occurred, the returned event will be
nil
.- Parameters:
timeout_sec (
number
) – Timeout in seconds.- Returns:
The next event in the queue, or
nil
.- Return type:
- call(id, name, ...)#
Call the method identified by its name
name
on the component which the identifier isid
with the given arguments.- Parameters:
id (
number
) – Identifier of the component of which to call the method.name (
string
) – The name of the method to call.
- Returns:
The raw return value of the method, or
nil
if the method doesn’t exist on the given peripheral.