def get_pod_status(): temp = 0 pressure = 0 attitude = "" position = 0 i = 4 canvas.send_batch(sender, ['pod_temp_req', 'pod_pressure_req', 'pod_position_req', 'pod_attitude_req']) #wait untill all 4 responses have arrived. order of responses arriving does not matter with this method #we also make sure we do not count the same data arriving twice. while i > 0: msg_name, data = canvas.recv(receiver) #if the "temp" variable is not 0 (its default value), that means we have received the temperature data already. if(msg_name == 'pod_temp_data' and temp == 0): temp = data i -= 1 elif(msg_name == 'pod_pressure_data' and pressure == 0): pressure = data i -= 1 elif(msg_name == 'pod_attitude_data' and attitude == ""): attitude = data i -= 1 elif(msg_name == 'pod_position_data' and position == 0): position = data i -= 1 return temp, pressure, attitude, position
def main(): global receiver receiver = canvas.init_receiver() global sender sender = canvas.init_sender() canvas.add_id(receiver, id_filter) # Main loop, modelled after control node's loop while 1: #Request several data points canvas.send_batch(sender, ['pod_temp_req', 'pod_pressure_req', 'pod_attitude_req']) msg_name, data = canvas.recv(receiver) # Check data, make sure none is abnormal if (msg_name == 'pod_temp_data'): if (data > pod_temp_max): alert_ground_station(1,location) pod_shutdown() elif (data < pod_temp_min): alert_ground_station(2,location) pod_shutdown() elif (msg_name == 'pod_pressure_data'): if (data > pod_pres_max): alert_ground_station(3,location) pod_shutdown() elif (data < pod_pres_min): alert_ground_station(4,location) pod_shutdown() elif (msg_name == 'pod_attitude_data'): elif (msg_name == 'hover_height_data'): if (data > hover_height_max): alert_ground_station(7,location) pod_shutdown() elif (data < hover_height_min): alert_ground_station(8,location) pod_shutdown() time.sleep(1)
def get_pod_status(): temp = 0 pressure = 0 attitude = "" position = 0 i = 4 canvas.send_batch(sender, [ 'pod_temp_req', 'pod_pressure_req', 'pod_position_req', 'pod_attitude_req' ]) #wait untill all 4 responses have arrived. order of responses arriving does not matter with this method #we also make sure we do not count the same data arriving twice. while i > 0: msg_name, data = canvas.recv(receiver) #if the "temp" variable is not 0 (its default value), that means we have received the temperature data already. if (msg_name == 'pod_temp_data' and temp == 0): temp = data i -= 1 elif (msg_name == 'pod_pressure_data' and pressure == 0): pressure = data i -= 1 elif (msg_name == 'pod_attitude_data' and attitude == ""): attitude = data i -= 1 elif (msg_name == 'pod_position_data' and position == 0): position = data i -= 1 return temp, pressure, attitude, position