Return an open gpsd socket if gpsd is running and responsive, else None.
(host='127.0.0.1', port=2947, timeout=2)
| 106 | minutes = float(raw[2:]) |
| 107 | else: |
| 108 | degrees = int(raw[:3]) |
| 109 | minutes = float(raw[3:]) |
| 110 | decimal = degrees + minutes / 60.0 |
| 111 | if direction in ('S', 'W'): |
| 112 | decimal = -decimal |
| 113 | return round(decimal, 7) |
| 114 | except (ValueError, IndexError): |
| 115 | return None |
| 116 | |
| 117 | |
| 118 | def _port_is_espressif(port): |
| 119 | """Return True iff udev reports an Espressif device on `port`. |
| 120 | |
| 121 | Used to distinguish ESP32 companions (Huginn/Piglet) from other serial |
| 122 | devices that share USB-UART bridge chips (CP210x, CH340) — the chip alone |
| 123 | isn't enough to identify ESP32, the device-level strings are. |
| 124 | """ |
| 125 | try: |
| 126 | import subprocess |
| 127 | r = subprocess.run( |
| 128 | ['udevadm', 'info', '-a', port], |
| 129 | capture_output=True, text=True, timeout=3 |
| 130 | ) |
no test coverage detected