Skip to content

Commit d5ef789

Browse files
committed
feat(soro_gps): add gps connection example
1 parent 90d3471 commit d5ef789

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

lib/soro_gps/examples/laptop.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//! This example should work on a laptop/desktop computer.
2+
//!
3+
//! I'm using it now to test the GPS connection without any ROS 2 stuff to mess
4+
//! with anything.
5+
6+
use soro_gps::Gps;
7+
8+
fn main() {
9+
// IMPORTANT: change this to the GPS' serial connection file.
10+
//
11+
// on Windows, you might be outta luck, but macOS and Linux should allow
12+
// grabbing this with: `ls /dev | grep TODOOOOOOOOOOOOooOoOOooooOOOOOoOOooooOOOOOOOooooOOOOOoOOooooOOOOOOOooooOOOOOoOOooooOOOOOOO`
13+
const DEVICE_PATH: &str = "TODO";
14+
15+
// then, "make a connection" by reading from that file!
16+
let mut gps: Gps = match Gps::new(DEVICE_PATH.into()) {
17+
Ok(gps) => gps,
18+
Err(e) => {
19+
tracing::error!("GPS connection error: {e}");
20+
panic!();
21+
}
22+
};
23+
24+
// continuously grab GPS information
25+
loop {
26+
match gps.get() {
27+
Some(gps_info) => {
28+
log::info!("New GPS message: {gps_info:?}")
29+
}
30+
31+
None => {
32+
tracing::error!("GPS disconnected! Waiting 2s and trying again...");
33+
std::thread::sleep(core::time::Duration::from_millis(2_000));
34+
continue;
35+
}
36+
}
37+
}
38+
}

0 commit comments

Comments
 (0)