Sensor network stuff works now

This commit is contained in:
2026-07-06 18:53:28 -06:00
parent 9e03767e1b
commit 8444c65f66
5 changed files with 54 additions and 32 deletions
+21 -6
View File
@@ -12,19 +12,34 @@ from car_os.imu import IMU
from car_os.timer import Timer
from car_os.enums import SensorClass
def wait(start):
delta = time.monotonic_ns() - start
print("delta:", delta)
while 0 <= delta < 1000:
delta = time.monotonic_ns() - start
print("delta:", delta)
continue
return
def main():
heartbeat_timer = Timer(15)
network = NetworkHandler(SensorClass.VEHICLE, 256, 0.001, 5000, 0.1, 5001)
network = NetworkHandler(SensorClass.VEHICLE, 256, 0.1, 5000, 0.001, 5001)
network.initialize()
network_timer = Timer(0.5)
network_timer = Timer(1)
network_reset_timer = Timer(600)
pps = PPS(board.GP22)
imu = IMU(board.GP21, board.GP20, 0x0C, (44, 66, -109), (-1, 3, -1), (-7, -16, -39))
gps = GPS(board.GP27, board.GP26, 0x42)
while True:
pps.update()
delta = pps.update()
if delta > 60:
continue
heartbeat_timer.update(delta)
network_timer.update(delta)
network_reset_timer.update(delta)
gps.update(pps.utc)
imu.update(pps.utc)
@@ -37,10 +52,10 @@ def main():
if gps.time_updated:
pps.update_from_gps(gps)
if network_timer.check_timer(pps.utc):
network.update(pps.utc, network_timer)
if network_timer.check_timer():
network.update(pps.utc, network_reset_timer)
#if heartbeat_timer.check_timer(pps.utc):
#if heartbeat_timer.check_timer():
# message = bytearray(b'\xd4\x53\x6e\x4e\x00\x00\x00')
# message[4] = pps.utc[0]
# message[5] = pps.utc[1]