Skip to content

Commit

Permalink
Lawndart warning
Browse files Browse the repository at this point in the history
  • Loading branch information
rehaanahmad2013 committed May 26, 2023
1 parent c043ce3 commit e343659
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
37 changes: 31 additions & 6 deletions tools/RadioGUI/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
["rx_failure", "RX Fail", ""], ["tx_success", "TX Good", ""],
["tx_failure", "TX Fail", ""], ["rssi", "Last RSSI:", "dBm"],
["snr", "Last SNR:", "dB"],
["velocity", "Last Velocity (m/s):", ""], # WARNING: NOT CHECKED
["filter_vel", "Last Velocity (m/s):", ""], # WARNING: NOT CHECKED
]

# Build Data Window Dynamicaly
Expand All @@ -72,6 +72,10 @@
column=1, row=data_row)
data_row += 1

# label = tk.Label(dataFrame, text="Initial Velocity Text")
# label.pack()


# radiobuttons
msgtype = StringVar()
msgtype.set("base64")
Expand Down Expand Up @@ -107,21 +111,28 @@
# useful for parsing commands
# Serial.readline seems unreliable at times too
serBuffer = ""

print(data_fields.keys())
# Check velocity not over capacity. WARNING: NOT CHECKED
if ((data_fields["velocity"][1] != "") and (int(data_fields["velocity"][1]) <= -100)):
label = tk.Label(dataFrame, text="Descent velocity too high!", fg='red').grid(column=0, row=data_row)
else: label = tk.Label(dataFrame, text="Descent velocity is appropriate.").grid(column=0, row=data_row)

velocityWarningText = StringVar()
velocityWarningText.set("Velocity Data Not Received")
tk.Label(dataFrame, textvariable=velocityWarningText, fg='black').grid(column=0, row=data_row)

# Update data
def process(line):
logging.info("Got Msg: " + line.strip())
data = json.loads(line)
if data["id"] == "Radio":
# if 'data' in data:
# print(data['data'])
for key in data:
if key in data_fields:
data_fields[key][0].set(str(data[key]) + data_fields[key][1])

# if key=="filter_vel":
# print(data[key])


if (data["msg"] == "RX" or data["msg"] == "TX"):
if msgtype.get() == "base64":
try:
Expand All @@ -143,9 +154,23 @@ def process(line):
spec.loader.exec_module(telem)

# parse telemetry packet
msg = telem.decodeTelem(data["data"], pos)
msg, msgJSON = telem.decodeTelem(data["data"], pos)
print("------")
print(msg)
print(msgJSON['filter_vel'])
console.insert(END, msg + "\n")
logging.info("Decoded Telem: " + msg)
if ((data_fields["filter_vel"][1] != "") and (int(data_fields["filter_vel"][1]) <= -100)):
velocityWarningText.set("descent velocity is too fast")
tk.Label(dataFrame, textvariable=velocityWarningText, fg='red').grid(column=0, row=data_row)
# new_text = "Descent Velocity is too fast"
# label.config(text = new_text)
else:
velocityWarningText.set("Velocity nominal")
tk.Label(dataFrame, textvariable=velocityWarningText, fg='green').grid(column=0, row=data_row)

# else: label = tk.Label(dataFrame, text="Descent velocity is appropriate.").grid(column=0, row=data_row)


console.see(END)

Expand Down
2 changes: 1 addition & 1 deletion tools/RadioGUI/telem/chovy.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def decodeTelem(data, pos):
data["filter_alt"] = expand_float(data["filter_alt"], -2000.0, 40000.0, 15)
data["filter_vel"] = expand_float(data["filter_vel"], -1000.0, 1000.0, 11)

return str(data)
return str(data), data


def expand_float(input, min, max, bits, offset=0):
Expand Down
2 changes: 1 addition & 1 deletion tools/RadioGUI/telem/guppy.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def decodeTelem(data, pos):
data["filter_alt"] = expand_float(data["filter_alt"], -2000.0, 40000.0, 15)
data["filter_vel"] = expand_float(data["filter_vel"], -1000.0, 1000.0, 11)

return str(data)
return str(data), data


def expand_float(input, min, max, bits, offset=0):
Expand Down

0 comments on commit e343659

Please sign in to comment.