[][src]Struct novatel_oem6_api::OEM6

pub struct OEM6 {
    pub conn: Arc<Mutex<Connection>>,
    pub log_recv: Arc<Mutex<Receiver<(Header, Vec<u8>)>>>,
    pub response_recv: Arc<Mutex<Receiver<(Header, Vec<u8>)>>>,
    pub response_abbrv_recv: Arc<Mutex<Receiver<Vec<u8>>>>,
}

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

response_abbrv_recv: Arc<Mutex<Receiver<Vec<u8>>>>

Channel for receiving abbreviated response messages

Methods

impl OEM6[src]

pub fn new(
    bus: &str,
    baud_rate: BaudRate,
    log_recv: Receiver<(Header, Vec<u8>)>,
    response_recv: Receiver<(Header, Vec<u8>)>,
    response_abbrv_recv: Receiver<Vec<u8>>
) -> OEMResult<OEM6>
[src]

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 (response_abbrv_send, response_abbrv_recv) = sync_channel(5);

let oem = OEM6::new(bus, BaudRate::Baud9600, log_recv, response_recv, response_abbrv_recv).unwrap();

pub fn request_version(&self) -> OEMResult<()>[src]

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, response_abbrv_recv).unwrap();
let rx_conn = oem.conn.clone();
thread::spawn(move || read_thread(&rx_conn, &log_send, &response_send, &response_abbrv_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]

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 of true will prevent unlog_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, response_abbrv_recv).unwrap();
let rx_conn = oem.conn.clone();
thread::spawn(move || read_thread(&rx_conn, &log_send, &response_send, &response_abbrv_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]

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 of true will prevent unlog_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, response_abbrv_recv).unwrap();

oem.request_errors(false)?;

pub fn request_unlog(&self, id: MessageID) -> OEMResult<()>[src]

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, response_abbrv_recv).unwrap();

oem.request_unlog(MessageID::BestXYZ)?;

pub fn request_unlog_all(&self, clear_holds: bool) -> OEMResult<()>[src]

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, response_abbrv_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, response_abbrv_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]

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, response_abbrv_recv).unwrap();

let packet: [u8; 6] = [0, 1, 2, 3, 4, 5];
oem.passthrough(&packet)?;

pub fn get_log(&self) -> OEMResult<Log>[src]

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, response_abbrv_recv).unwrap();
let rx_conn = oem.conn.clone();
thread::spawn(move || read_thread(&rx_conn, &log_send, &response_send, &response_abbrv_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

impl Clone for OEM6[src]

Auto Trait Implementations

impl Send for OEM6

impl Unpin for OEM6

impl Sync for OEM6

impl UnwindSafe for OEM6

impl RefUnwindSafe for OEM6

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]