[−][src]Struct novatel_oem6_api::OEM6
Structure for OEM6 device instance
Fields
conn: Arc<Mutex<Connection>>
Device connection structure
log_recv: Arc<Mutex<Receiver<(Header, Vec<u8>)>>>
Channel for receiving log messages
response_recv: Arc<Mutex<Receiver<(Header, Vec<u8>)>>>
Channel for receiveing response messages
Methods
impl OEM6
[src]
impl OEM6
pub fn new(
bus: &str,
baud_rate: BaudRate,
log_recv: Receiver<(Header, Vec<u8>)>,
response_recv: Receiver<(Header, Vec<u8>)>
) -> OEMResult<OEM6>
[src]
pub fn new(
bus: &str,
baud_rate: BaudRate,
log_recv: Receiver<(Header, Vec<u8>)>,
response_recv: Receiver<(Header, Vec<u8>)>
) -> OEMResult<OEM6>
Constructor for OEM6 structure
Arguments
- bus - Serial bus to use for communication
- baud_rate - Communication data rate
- log_recv - Receiver for log messages sent by read thread
- response_recv - Receiver for response messages sent by read thread
Errors
If this function encounters any errors, an OEMError
variant will be returned.
Examples
use novatel_oem6_api::*; use std::sync::mpsc::sync_channel; let bus = "/dev/ttyS5"; let (log_send, log_recv) = sync_channel(5); let (response_send, response_recv) = sync_channel(5); let oem = OEM6::new(bus, BaudRate::Baud9600, log_recv, response_recv).unwrap();
pub fn request_version(&self) -> OEMResult<()>
[src]
pub fn request_version(&self) -> OEMResult<()>
Request the system version information
Note: A subsequent get_log()
call is required to fetch the information
Errors
If this function encounters any errors, an OEMError
variant will be returned.
Examples
let oem = OEM6::new(bus, BaudRate::Baud9600, log_recv, response_recv).unwrap(); let rx_conn = oem.conn.clone(); thread::spawn(move || read_thread(&rx_conn, &log_send, &response_send)); oem.request_version()?; // Read the next log message, which should have the reply let entry = oem.get_log()?; match entry { Log::Version(log) => { println!("Version Info ({}):\n", log.num_components); for component in log.components.iter() { println!( "Type: {} Model: {} SN: {}", component.comp_type, component.model, component.serial_num ); println!(" HW Version: {}", component.hw_version); println!(" SW Version: {}", component.sw_version); println!(" Boot Version: {}", component.boot_version); println!( " Compiled: {} {}", component.compile_date, component.compile_time ); println!(""); } } _ => {}, }
pub fn request_position(
&self,
interval: f64,
offset: f64,
hold: bool
) -> OEMResult<()>
[src]
pub fn request_position(
&self,
interval: f64,
offset: f64,
hold: bool
) -> OEMResult<()>
Request BestXYZ position log/s from the device
Note: Subsequent get_log()
calls are required to fetch the information
Arguments
- interval - Frequency, in seconds, at which the OEM6 should emit position log messages
- offset - Offset, in seconds, of the message emit frequency
- hold - Whether the
unlog_all
command should be able to apply to this log. A value oftrue
will preventunlog_all
from applying to this log.
Errors
If this function encounters any errors, an OEMError
variant will be returned.
Examples
let oem = OEM6::new(bus, BaudRate::Baud9600, log_recv, response_recv).unwrap(); let rx_conn = oem.conn.clone(); thread::spawn(move || read_thread(&rx_conn, &log_send, &response_send)); oem.request_position(1.0, 0.0, false)?; // Continually read the position log messages loop { // Read the next log message, which should have the reply let entry = oem.get_log()?; match entry { Log::BestXYZ(log) => { println!("Best XYZ Data:"); println!(" Position: {:?}", log.position); println!(" Velocity: {:?}", log.velocity); } _ => {}, } }
pub fn request_errors(&self, hold: bool) -> OEMResult<()>
[src]
pub fn request_errors(&self, hold: bool) -> OEMResult<()>
Request that the device send error messages as they occur
Arguments
- hold - Whether the
unlog_all
command should be able to apply to this log. A value oftrue
will preventunlog_all
from applying to this log.
Errors
If this function encounters any errors, an OEMError
variant will be returned.
Examples
let oem = OEM6::new(bus, BaudRate::Baud9600, log_recv, response_recv).unwrap(); oem.request_errors(false)?;
pub fn request_unlog(&self, id: MessageID) -> OEMResult<()>
[src]
pub fn request_unlog(&self, id: MessageID) -> OEMResult<()>
Request that automatic logging for a particular log type be stopped
Arguments
- id - Message ID which should no longer be logged
Errors
If this function encounters any errors, an OEMError
variant will be returned.
Examples
let oem = OEM6::new(bus, BaudRate::Baud9600, log_recv, response_recv).unwrap(); oem.request_unlog(MessageID::BestXYZ)?;
pub fn request_unlog_all(&self, clear_holds: bool) -> OEMResult<()>
[src]
pub fn request_unlog_all(&self, clear_holds: bool) -> OEMResult<()>
Request that all automatic logging be stopped
Arguments
- clear_holds - Specifies whether log messages which were set with the
hold
option should also be unlogged
Errors
If this function encounters any errors, an OEMError
variant will be returned.
Examples
let oem = OEM6::new(bus, BaudRate::Baud9600, log_recv, response_recv).unwrap(); // Request position information every second and prevent unlogging with unlog_all() oem.request_position(1.0, 0.0, true)?; // Unlog everything. Previous request for position information will remain intact oem.request_unlog_all(false)?;
let oem = OEM6::new(bus, BaudRate::Baud9600, log_recv, response_recv).unwrap(); // Request position information every second and prevent unlogging with unlog_all() oem.request_position(1.0, 0.0, true)?; // Unlog everything. This will override the position request's `hold=true` value and // also unlog that request oem.request_unlog_all(true)?;
pub fn passthrough(&self, msg: &[u8]) -> OEMResult<()>
[src]
pub fn passthrough(&self, msg: &[u8]) -> OEMResult<()>
Directly send a message without formatting or checksum calculation
Note: The message will not be verified by checking for a command response
Arguments
- msg - Message to send
Errors
If this function encounters any errors, an OEMError
variant will be returned.
Examples
let oem = OEM6::new(bus, BaudRate::Baud9600, log_recv, response_recv).unwrap(); let packet: [u8; 6] = [0, 1, 2, 3, 4, 5]; oem.passthrough(&packet)?;
pub fn get_log(&self) -> OEMResult<Log>
[src]
pub fn get_log(&self) -> OEMResult<Log>
Fetch a log message from the OEM6 read thread
Errors
If this function encounters any errors, an OEMError
variant will be returned.
Examples
let oem = OEM6::new(bus, BaudRate::Baud9600, log_recv, response_recv).unwrap(); let rx_conn = oem.conn.clone(); thread::spawn(move || read_thread(&rx_conn, &log_send, &response_send)); let entry = oem.get_log()?; match entry { Log::Version(log) => println!("Received version information: {:?}", log), Log::BestXYZ(log) => println!("Received position information: {:?}", log), Log::RxStatusEvent(log) => println!("Received system event: {:?}", log), _ => println!("Received unknown log type"), }
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
type Owned = T
fn to_owned(&self) -> T
[src]
fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
fn clone_into(&self, target: &mut T)
[src]
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
try_from
)Performs the conversion.
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Gets the TypeId
of self
. Read more