gpsd_client

Crates.iogpsd_client
lib.rsgpsd_client
version0.1.6
sourcesrc
created_at2024-01-09 19:32:18.275333
updated_at2024-06-11 13:49:57.300228
descriptionSimple gpsd client that get the information from a gps device.
homepage
repository
max_upload_size
id1094440
size22,682
(paulmillo)

documentation

https://docs.rs/gpsd_client

README

The gpsd_client module contains types and functions to connect to [gpsd] https://gpsd.io/index.html to get gps coordinates and how many satellites you are receiving information from and how many satellites the information is being used.

The gps-client uses a TcpStream to connect to the gpsd socket server to read and write information to gpsd. This package was modeled from the python3 gpsd package.

Update

You now have the ability to change the time format from %Y-%m-%dT%H:%M:%S.%fZ. The connection has now been set up to tell gpsd to use NMEA

Testing

gpsd_client was test with gpsd: 3.22 on Linux Debian Distro. From more information about gpsd just check out the documentation at https://gpsd.io/index.html.

Examples

use gpsd_client::*;
use std::thread;
use std::time::Duration;
use std::process;

fn main() {
      // Connecting to the gpsd socket server.
      let mut gps: GPS = match GPS::connect() {
          Ok(t) => t,
          Err(e) => {
              println!("{e}");
              process::exit(1);
          }
      };

      let mut count: i32 = 0;

      loop {
          count += 1;
          // Getting the data from the gps device.
          let data: GPSData = gps.current_data().unwrap();
          println!("{data:#?}");
          let my_time: String = data.convert_time("America/Chicago").unwrap();
          let mph: f32 = data.convert_speed(true);
          let direction: String = data.travel_direction();
          println!(
              "Lat: {}, Lon: {}, Time: {}, Speed: {:.1}, Direction: {}",
              data.lat, data.lon, my_time, mph, direction
          );
          if count == 5 { break; }
          thread::sleep(Duration::from_millis(500));
      }

      // Closing the TcpStream and BufReader to the gpsd socket server.
      gps.close();
}
Commit count: 0

cargo fmt