Crates.io | crate_IA7_GPS |
lib.rs | crate_IA7_GPS |
version | 0.2.0 |
source | src |
created_at | 2020-09-30 20:23:59.898199 |
updated_at | 2020-09-30 23:20:57.186414 |
description | Get data from GPS with UART |
homepage | |
repository | |
max_upload_size | |
id | 294745 |
size | 8,312 |
How to use crate_IA7_GPS
connect your GPS to the raspberry berry via Tx and Rx pin.
create a structure like that :
let mut data= GpsData { Uart_ : Uart::new(9600, Parity::None, 8, 1)?, id : "0".to_string(), time : "0".to_string(), lat : "0".to_string(), long : "0".to_string(), nbSat : "0".to_string(), hdop : "0".to_string(), alti : "0".to_string(), };
Initialisation with data.init()
Getting data with data.getdata()
All the useful data will be set in the structure () id time latitude longitude Number of sat altitude
example :
fn main() -> Result<(), Box
let mut data= GpsData {
Uart_ : Uart::new(9600, Parity::None, 8, 1)?,
id : "0".to_string(),
time : "0".to_string(),
lat : "0".to_string(),
long : "0".to_string(),
nbSat : "0".to_string(),
hdop : "0".to_string(),
alti : "0".to_string(),
};
data.init();
// println!("Start");
loop {
data.getData();
println!("lat : {} N", data.lat);
println!("long : {} W", data.long);
thread::sleep(Duration::from_millis(1000));
}
Ok(())
}