[][src]Struct mai400_api::MAI400

pub struct MAI400 {
    pub conn: Arc<Mutex<Connection>>,
}

Structure for MAI-400 device instance

Fields

Device connection structure

Methods

impl MAI400
[src]

Constructor for MAI400 structure

Arguments

  • conn - The underlying connection stream to use for communication with the device

Examples

use mai400_api::*;

let mai = MAI400::new("/dev/ttyS5")?;

Request a hardware reset of the MAI-400

Errors

If this function encounters any errors, an MAIError variant will be returned.

Examples

let mai = MAI400::new("/dev/ttyS5")?;
mai.reset()?;

Set the ACS mode

Arguments

Note: Arguments should be set to 0x00 when not needed for desired mode

  • mode - ACS mode to enter
  • params - Array of signed shorts containing the arguments for configuring the requested mode

Errors

If this function encounters any errors, an MAIError variant will be returned.

Examples

let mai = MAI400::new("/dev/ttyS5")?;
mai.set_mode(9, [1, -1, -3, 0])?;

Set the ACS mode (Normal-Sun or Lat/Long-Sun)

Arguments

Note: Arguments should be set to 0x00 when not needed for desired mode

  • mode - ACS mode to enter. Should be either Normal-Sun or Lat/Long-Sun
  • sun_angle_enable - Sun angle enable (0 = no update, 1 = update)
  • sun_rot_angle - Sun rotation angle, in degrees

Errors

If this function encounters any errors, an MAIError variant will be returned.

Examples

let mai = MAI400::new("/dev/ttyS5")?;
mai.set_mode_sun(7, 1, 45.0)?;

Set the ADACS clock with the desired GPS time

Arguments

  • gps_time - New clock time (elapsed seconds after Jan 6, 1980 00:00:00)

Errors

If this function encounters any errors, an MAIError variant will be returned.

Examples

let mai = MAI400::new("/dev/ttyS5")?;
// Jan 01, 2018
mai.set_gps_time(1198800018)?;

Set orbital position and velocity at epoch for RK4 integration method of orbit propagation

Arguments

  • eci_pos - ECI position [X, Y, Z]
  • eci_vel - ECI velocity [X, Y, Z]
  • time_epoch - GPS time at Epoch

Errors

If this function encounters any errors, an MAIError variant will be returned.

Examples

let mai = MAI400::new("/dev/ttyS5")?;
mai.set_rv([0.0, 0.0, 0.0], [0.0, 0.0, 0.0], 1198800018)?;

Directly send a message without formatting or checksum calculation

Arguments

  • msg - Message to send

Errors

If this function encounters any errors, an MAIError variant will be returned.

Examples

let mai = MAI400::new("/dev/ttyS5")?;

let mut array = [0; 8];
array[0] = 0x90; // SYNC byte 1
array[1] = 0xEB; // SYNC byte 2
array[2] = 0x0;  // Data_len byte 1
array[3] = 0x0;  // Data_len byte 2
array[4] = 0x5A; // Msg_id
array[5] = 0x0;  // Addr
array[6] = 0x00; // CRC byte 1
array[7] = 0x00; // CRC byte 2

mai.passthrough(&array)?;

Wait for and read a message set from the MAI-400.

Returns a tuple potentially containing a standard telemetry message, a raw IMU telemetry message, and an IREHS telemetry packet.

Note: Messages are sent every 250ms, so, to the human eye, this should appear to be instantaneous

Errors

If this function encounters any errors, an MAIError variant will be returned.

Examples

let mai = MAI400::new("/dev/ttyS5")?;
let (std, imu, irehs) = mai.get_message()?;

if let Some(telem) = std {
    println!("Num successful commands: {}", telem.cmd_valid_cntr);
}

Trait Implementations

impl Clone for MAI400
[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl Send for MAI400

impl Sync for MAI400

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]