- Imports:
- interface
wasi:buffer-pool/data-types
- interface
wasi:sensor/property
- interface
wasi:sensor/sensor
- interface
wasi:io/[email protected]
- interface
wasi:buffer-pool/buffer-pool
- interface
- Exports:
- interface
wasi:sensor/interface
- interface
WASI Sensor is an Sensor abstraction API
sensor data type
-
grayscale, bpp=8
-
r,g,b bpp=24
-
b,g,r bpp=24
-
a,r,g,b bpp=32
-
a,b,g,r bpp=32
-
YUV422 (Y1,Cb,Y2,Cr) bpp=16
-
Motion JPEG
-
width
:u32
Image width.
-
height
:u32
Image height.
-
stride-bytes
:u32
Image stride. 0 for compressed formats like mjpeg.
-
The format of a pixel.
payload
: list<u8
>dimension of depth image is updated later here
#### `record fraction`
numerator
:u32
denominator
:u32
-
The number of samples in a second. (fraction) Eg. frame rate for image sensors.
#### `type property-value` [`property-value`](#property_value)
#### `enum device-error`
not-found
invalid-argument
resource-exhausted
permission-denied
busy
timeout
cancelled
aborted
already-exists
invalid-operation
out-of-range
data-loss
hardware-error
not-supported
unknown
open the device. this might power on the device.
name
:string
- result<own<
device
>,device-error
>
get a list of names of devices available on the system.
- result<list<
string
>,device-error
>
start sending the data to buffer
self
: borrow<device
>buffer-pool
:string
- result<_,
device-error
>
stop sending the data to buffer
- result<_,
device-error
>
set property
self
: borrow<device
>key
:property-key
value
:property-value
- result<_,
device-error
>
get property
self
: borrow<device
>property
:property-key
- result<
property-value
,device-error
>
A poll API intended to let users wait for I/O events on multiple handles at once.
pollable
represents a single I/O event which may be ready, or not.
Return the readiness of a pollable. This function never blocks.
Returns true
when the pollable is ready, and false
otherwise.
block
returns immediately if the pollable is ready, and otherwise
blocks until ready.
This function is equivalent to calling poll.poll
on a list
containing only this pollable.
Poll for completion on a set of pollables.
This function takes a list of pollables, which identify I/O sources of interest, and waits until one or more of the events is ready for I/O.
The result list<u32>
contains one or more indices of handles in the
argument list that is ready for I/O.
If the list contains more elements than can be indexed with a u32
value, this function traps.
A timeout can be implemented by adding a pollable from the wasi-clocks API to the list.
This function does not return a result
; polling in itself does not
do any I/O so it doesn't fail. If any of the I/O sources identified by
the pollables has an error, it is indicated by marking the source as
being reaedy for I/O.
sensor frame/buffer management I/F
#### `type data-type` [`data-type`](#data_type)
#### `enum buffer-error`
not-found
invalid-argument
resource-exhausted
permission-denied
busy
timeout
cancelled
aborted
already-exists
invalid-operation
out-of-range
data-loss
hardware-error
not-supported
unknown
u32
#### `type timestamp` `u64`
timestamp is the elasped time in nanoseconds since a fixed point in the past. it's supposed to increase monotonically.
-
data passed by value
-
host-memory
: own<memory
>a reference to host memory
-
sequence-number
:u64
sequence number within the pool. it increases monotonically. a user of this api might observe discontiguous values when some of frames are discarded within the pool.
-
timestamp of the frame. usually the time when it was read from the underlying hardware.
-
data
: list<frame-data
>1 or more raw-data for this frame.
-
< Discard the latest frame. behave like queue
-
< Overwrite the oldest frame. behave like ring
a pool consists of a set of buffers. the number of buffers in a pool is static. when data (a frame) comes in from an associated device, it's stored in one of free buffers. when a user app request data either by block-read or poll-read, the oldest frame is returned. when the user app is done with the frame, it should notify it to the pool by dropping the frame-info and associated resources like "memory".
- result<_,
buffer-error
>
create a pool.
size: the max size of each buffer in bytes. if frame-info::data has exactly one data and its type is data-types::image, this value controls the max payload size. otherwise, it's implementation-defined.
buffer-num: the max number of buffers in the pool. for buffering-discard and buffering-overwrite, this controls how many frames can be in the pool. for other buffering modes, this is ignored.
name: the name of the pool. you can use this for device.start().
mode
:buffering-mode
size
:u32
buffer-num
:u32
name
:string
- result<own<
pool
>,buffer-error
>
try to read frames. this function returns 0 frames when
- max-results = 0
- or, no frames are immediately available
self
: borrow<pool
>max-results
:u32
- result<list<
frame-info
>,buffer-error
>
- own<
pollable
>
- result<
pool-statistics
,buffer-error
>