pub struct PortValueSingleFormat {
pub port_id: u8,
pub data: Vec<i8>,
}Expand description
The PortValueSingleFormat is a list of port id & value pairs, except that the values may be different lengths (u8, u16, u32, f32) depending on the port configuration. For now we just save the payload and then later on will provide a method to split it out into port-value pairs based on a separate port type mapping.
Notes on Value Format
- The valuetypes are signed, i.e. the variants are i8, i16, i32, f32. This: https://lego.github.io/lego-ble-wireless-protocol-docs/index.html#port-value-single says that the values are unsigned, but this is seemingly incorrect. Many sensors can report negative values, as can be seen by requesting Port Mode Information::Raw range.
- The values are not a single value but an array, the length of which is given
by the “number_of_datasets”-member of Value Format.
(“Single” in PortValueSingle refers to single sensor mode, but single sensors can)
and do provide provide array data, ex. color RGB or accelerometer XYZ-data.) - There are some inconsistencies looking at port mode information: HubLeds in RBG reports taking 8 bit values in the range 0-255, though this doesn’t concern the parser of incoming values. As regards sensors; TechnicHubTiltSensor mode CFG, as well as MoveHubInternalTilt modes IM_CF and CALIB: These all report that they will provide 8 bit values in range 0-255. But these are the only ones I’ve been able to find. On the whole it seems better to correctly support the multitude of sensors and modes.
Fields§
§port_id: u8§data: Vec<i8>Implementations§
Trait Implementations§
Source§impl Clone for PortValueSingleFormat
impl Clone for PortValueSingleFormat
Source§fn clone(&self) -> PortValueSingleFormat
fn clone(&self) -> PortValueSingleFormat
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PortValueSingleFormat
impl Debug for PortValueSingleFormat
impl Eq for PortValueSingleFormat
Source§impl PartialEq for PortValueSingleFormat
impl PartialEq for PortValueSingleFormat
impl StructuralPartialEq for PortValueSingleFormat
Auto Trait Implementations§
impl Freeze for PortValueSingleFormat
impl RefUnwindSafe for PortValueSingleFormat
impl Send for PortValueSingleFormat
impl Sync for PortValueSingleFormat
impl Unpin for PortValueSingleFormat
impl UnsafeUnpin for PortValueSingleFormat
impl UnwindSafe for PortValueSingleFormat
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more