gps_data_reader_bjarki18 0.1.1

A crate which uses rpi_embedded to read data from a gps module.
Documentation
use std::time::Duration;
use std::thread;
use rpi_embedded::uart::{Uart, Parity};


pub enum GpsVal {
	Uart(u32),
	Baud(u32),
}

pub struct GPS {
	latitude: String, //latitude
	longitude: String, //longitude
	north_south: String, //direction, either north or south
	east_west: String, //direction, either east or west
	satellites: String, //num of satellites in use
	altitude: String, //altitude in meters
	data_time: String //age of gps data in seconds
}

impl GPS {
	pub fn new() -> Self{
	
		let mut _out = Self{
			latitude: "".to_string(),
			longitude: "".to_string(),
			north_south: "".to_string(),
			east_west: "".to_string(),
			satellites: "".to_string(),
			altitude: "".to_string(),
			data_time: "".to_string()
		};
		_out
	
	}
	pub fn print_data(&mut self) {
		let print_str = format!(
			"\n
			Latitude: {}\n
			Longitude: {}\n
			Altitude: {}\n
			Orientation: {}{}\n
			Num of active satellites: {}\n
			Time since last data read: {}\n
			",self.latitude,self.longitude,self.altitude,self.north_south,self.east_west,self.satellites,self.data_time);
			println!("{}",print_str);
	}
	
	pub fn set_data(&mut self, vektor: Vec<&str>){
		self.latitude = vektor[2].to_string();
		self.longitude = vektor[4].to_string();
		self.north_south = vektor[3].to_string();
		self.east_west = vektor[5].to_string();
		self.satellites = vektor[7].to_string();
		self.altitude = vektor[9].to_string() + &vektor[10].to_string();

	} 
		


}




fn main() {

	let mut gps = GPS::new();
	let mut uart = Uart::new(9600, Parity::None, 8, 1).expect("Uart fail");
	uart.set_read_mode(1, Duration::default()).expect("read mode fail");
	
	thread::sleep(Duration::from_millis(500));
	
	loop{
		let res = uart.read_line().expect("read line fail");
		let my_vec = res.split(',');
		let vec: Vec<&str> = my_vec.collect();
		if vec[0] == "$GPGGA" {
			gps.set_data(vec);
			gps.print_data();
		}		
	}

}