(Re)point the GPS reader at a serial port — called by the wardriving device monitor when a GPS puck is hot-plugged or re-enumerates. Idempotent: if already reading that port, do nothing. Prefers gpsd when it is running (it owns the serial device). This is what makes GPS
(self, port)
| 312 | # fix landed makes that visible instead of inferred. |
| 313 | self.start_time = 0 |
| 314 | self.first_fix_time = 0 |
| 315 | self.connected = False |
| 316 | self.error = None |
| 317 | # Tracks whether the current position came from an external source |
| 318 | # (e.g. a USB-connected Piglet companion reporting its own GPS). |
| 319 | # Set by update_external_fix(); cleared once a local receiver |
| 320 | # produces a real fix. |
| 321 | self._external_source = None |
| 322 | |
| 323 | def start(self): |
| 324 | """Start GPS reading thread.""" |
| 325 | if self._running: |
| 326 | return |
| 327 | |
| 328 | # Clock TTFF from the moment the reader is asked to run, not from the |
| 329 | # first sentence — the gap before data arrives is part of the problem |
| 330 | # when a receiver is struggling. |
| 331 | self.start_time = time.time() |
| 332 | self.first_fix_time = 0 |
| 333 | |
| 334 | if not self.port: |
| 335 | self.port = detect_gps_device(exclude_ports=self._exclude_ports) |
| 336 | if not self.port: |
| 337 | self.error = "No GPS device detected" |
| 338 | logger.warning(self.error) |
| 339 | return False |
| 340 | |
| 341 | if self.port == 'gpsd': |
no test coverage detected