Explorar o código

added port config

subDesTagesMitExtraKaese %!s(int64=3) %!d(string=hai) anos
pai
achega
4e594bd903
Modificáronse 2 ficheiros con 7 adicións e 2 borrados
  1. 4 0
      raspberry-pi/config.ini
  2. 3 2
      raspberry-pi/sensors/acusticSensor.py

+ 4 - 0
raspberry-pi/config.ini

@@ -6,6 +6,10 @@
   # height in mm
   y = 450
 
+[arduino]
+  port = /dev/ttyACM0
+  baudrate = 1000000
+
 # acoustic sensor config
 [ac_sensor]
   # distance of the sensors in front of y=0 in mm

+ 3 - 2
raspberry-pi/sensors/acusticSensor.py

@@ -12,10 +12,11 @@ conn = globalArduinoSlave()
 
 class AcusticSensor:
   def __init__(self, conf, ac_queue, calibration_state):
+    self.conf = conf
     self.ac_queue               = ac_queue
     self.calibration_state      = calibration_state
     self.field_height           = float(conf["field"]["y"])
-    self.field_width           = float(conf["field"]["x"])
+    self.field_width            = float(conf["field"]["x"])
     self.sensor_y_offset        = float(conf["ac_sensor"]["y_offset"])
     self.left_sensor_x_offset   = float(conf["ac_sensor"]["left_x_offset"])
     self.right_sensor_x_offset  = float(conf["ac_sensor"]["right_x_offset"])
@@ -34,7 +35,7 @@ class AcusticSensor:
 
   def start(self):
     if not conn.isConnected():
-      conn.open()
+      conn.open(port = self.conf["arduino"]["port"], baudrate = int(self.conf["arduino"]["baudrate"]))
     conn.addRecvCallback(self._readCb)
     # generate dummy values until arduino is ready
     self.dummyActive = True