Skip to content
Snippets Groups Projects
Commit 8919a4df authored by Hailong Zhu's avatar Hailong Zhu
Browse files

Merge branch 'master' of git-st.inf.tu-dresden.de:ipos/uwb

parents f37faf73 3e82fe28
No related branches found
No related tags found
No related merge requests found
......@@ -21,10 +21,10 @@ MQTT_PATH = "usertopic/SensorEventWrapper"
ser = serial.Serial('/dev/ttyUSB0', 115200, timeout=1) # open serial port
print(ser.name) # check which port was really used
def extractNumbersFromLine(line):
return re.findall(r'-?\d+\.?\d*',line)
def get_distance(line):
number_found = re.findall(r'-?\d+\.?\d*',line)
def get_distance(number_found):
return number_found[1], number_found[3]
def average(lst):
......@@ -39,8 +39,9 @@ def read_serial(number):
for x in range(number):
line = ser.readline() # read a '\n' terminated line
print(line)
if(len(line)>30):
tag, distance = get_distance(line.decode("utf-8"))
number_found = extractNumbersFromLine(line.decode("utf-8"));
if(len(number_found)>=4):
tag, distance = get_distance(number_found);
print(tag, distance)
if (tag == "3383"):
d1.append(float(distance))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment