File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments