[][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>)>>>,
}

Structure for OEM6 device instance

Fields

Device connection structure

Channel for receiving log messages

Channel for receiveing response messages

Methods

impl 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 oem = OEM6::new(bus, BaudRate::Baud9600, log_recv, response_recv).unwrap();

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!("");
        }
    }
    _ => {},
}

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).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);
        }
        _ => {},
    }
}

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

oem.request_errors(false)?;

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)?;

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)?;

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)?;

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

impl Clone for OEM6
[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl Send for OEM6

impl Sync for OEM6

Blanket Implementations

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

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

impl<T> From for T
[src]

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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