Struct Device

Source
pub struct Device {
    pub common: Common,
}

Fields§

§common: Common

Implementations§

Source§

impl Device

Source

pub fn new<T>(io: T) -> Self
where T: AsyncRead + AsyncWrite + Unpin + Send + 'static,

Source

pub async fn set_ping_interval( &self, ping_interval: u16, ) -> Result<(), PingError>

The interval between acoustic measurements.

§Arguments
  • ping_interval [ms] - The interval between acoustic measurements.
Source

pub async fn speed_of_sound(&self) -> Result<SpeedOfSoundStruct, PingError>

The speed of sound used for distance calculations.

Source

pub async fn profile(&self) -> Result<ProfileStruct, PingError>

A profile produced from a single acoustic measurement. The data returned is an array of response strength at even intervals across the scan region. The scan region is defined as the region between <scan_start> and <scan_start + scan_length> millimeters away from the transducer. A distance measurement to the target is also provided.

Source

pub async fn set_device_id(&self, device_id: u8) -> Result<(), PingError>

Set the device ID.

§Arguments
  • device_id - Device ID (0-254). 255 is reserved for broadcast messages.
Source

pub async fn set_ping_enable(&self, ping_enabled: u8) -> Result<(), PingError>

Enable or disable acoustic measurements.

§Arguments
  • ping_enabled - 0: Disable, 1: Enable.
Source

pub async fn general_info(&self) -> Result<GeneralInfoStruct, PingError>

General information.

Source

pub async fn pcb_temperature(&self) -> Result<PcbTemperatureStruct, PingError>

Temperature of the on-board thermistor.

Source

pub async fn ping_interval(&self) -> Result<PingIntervalStruct, PingError>

The interval between acoustic measurements.

Source

pub async fn continuous_start(&self, id: u16) -> Result<(), PingError>

Command to initiate continuous data stream of profile messages.

§Arguments
  • id - The message id to stream. 1300: profile
Source

pub async fn set_range( &self, scan_start: u32, scan_length: u32, ) -> Result<(), PingError>

Set the scan range for acoustic measurements.

§Arguments
  • scan_start [mm] - Not documented
  • scan_length [mm] - The length of the scan range. Minimum 1000.
Source

pub async fn goto_bootloader(&self) -> Result<(), PingError>

Send the device into the bootloader. This is useful for firmware updates.

§Arguments
Source

pub async fn transmit_duration( &self, ) -> Result<TransmitDurationStruct, PingError>

The duration of the acoustic activation/transmission.

Source

pub async fn set_speed_of_sound( &self, speed_of_sound: u32, ) -> Result<(), PingError>

Set the speed of sound used for distance calculations.

§Arguments
  • speed_of_sound [mm/s] - The speed of sound in the measurement medium. ~1,500,000 mm/s for water.
Source

pub async fn set_gain_setting(&self, gain_setting: u8) -> Result<(), PingError>

Set the current gain setting.

§Arguments
  • gain_setting - The current gain setting. 0: 0.6, 1: 1.8, 2: 5.5, 3: 12.9, 4: 30.2, 5: 66.1, 6: 144
Source

pub async fn mode_auto(&self) -> Result<ModeAutoStruct, PingError>

The current operating mode of the device. Manual mode allows for manual selection of the gain and scan range.

Source

pub async fn range(&self) -> Result<RangeStruct, PingError>

The scan range for acoustic measurements. Measurements returned by the device will lie in the range (scan_start, scan_start + scan_length).

Source

pub async fn set_mode_auto(&self, mode_auto: u8) -> Result<(), PingError>

Set automatic or manual mode. Manual mode allows for manual selection of the gain and scan range.

§Arguments
  • mode_auto - 0: manual mode. 1: auto mode.
Source

pub async fn gain_setting(&self) -> Result<GainSettingStruct, PingError>

The current gain setting.

Source

pub async fn voltage_5(&self) -> Result<Voltage5Struct, PingError>

The 5V rail voltage.

Source

pub async fn distance(&self) -> Result<DistanceStruct, PingError>

The distance to target with confidence estimate. Relevant device parameters during the measurement are also provided.

Source

pub async fn ping_enable(&self) -> Result<PingEnableStruct, PingError>

Acoustic output enabled state.

Source

pub async fn device_id(&self) -> Result<DeviceIdStruct, PingError>

The device ID.

Source

pub async fn processor_temperature( &self, ) -> Result<ProcessorTemperatureStruct, PingError>

Temperature of the device cpu.

Source

pub async fn distance_simple(&self) -> Result<DistanceSimpleStruct, PingError>

The distance to target with confidence estimate.

Source

pub async fn firmware_version(&self) -> Result<FirmwareVersionStruct, PingError>

Device information

Source

pub async fn continuous_stop(&self, id: u16) -> Result<(), PingError>

Command to stop the continuous data stream of profile messages.

§Arguments
  • id - The message id to stop streaming. 1300: profile

Trait Implementations§

Source§

impl Debug for Device

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PingDevice for Device

Source§

fn get_common(&self) -> &Common

Source§

fn get_mut_common(&mut self) -> &mut Common

Source§

fn subscribe(&self) -> Receiver<ProtocolMessage>

Source§

async fn send_general_request(&self, requested_id: u16) -> Result<(), PingError>

Source§

async fn wait_for_message<T>( &self, receiver: Receiver<ProtocolMessage>, ) -> Result<T, PingError>
where T: MessageInfo + Sync + Clone + Send + 'static,

Source§

async fn wait_for_ack( &self, receiver: Receiver<ProtocolMessage>, message_id: u16, ) -> Result<(), PingError>

Source§

async fn request<T>(&self) -> Result<T, PingError>
where T: MessageInfo + Sync + Clone + Send + 'static,

Source§

async fn device_information(&self) -> Result<DeviceInformationStruct, PingError>

Device information
Source§

async fn protocol_version(&self) -> Result<ProtocolVersionStruct, PingError>

The protocol version
Source§

async fn set_device_id(&self, device_id: u8) -> Result<(), PingError>

Set the device ID. Read more

Auto Trait Implementations§

§

impl Freeze for Device

§

impl !RefUnwindSafe for Device

§

impl Send for Device

§

impl Sync for Device

§

impl Unpin for Device

§

impl !UnwindSafe for Device

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more