Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions low_level/comms.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,15 @@ def send(self, data_to_send):
except serial.serialutil.SerialTimeoutException as err:
print(repr(err))
print("ERROR: Write Has Timed Out")
callback_exception_handler("ERROR: Write Has Timed Out")
# callback_exception_handler("ERROR: Write Has Timed Out")
except serial.serialutil.PortNotOpenError as err:
print(repr(err))
print("ERROR: Port " + config.COM_PORT + " Not Open")
callback_exception_handler("ERROR: Port" + config.COM_PORT + " Not Open")
# callback_exception_handler("ERROR: Port" + config.COM_PORT + " Not Open")
except serial.serialutil.SerialException as err:
print(repr(err))
print("ERROR: The handle is invalid")
callback_exception_handler("ERROR: The handle is invalid")
# callback_exception_handler("ERROR: The handle is invalid")


class StateMachineState(Enum):
Expand Down Expand Up @@ -284,7 +284,7 @@ def reading_data(self, rx_byte):
except struct.error as err:
print(repr(err))
print("ERROR: Data Length is not 4 bytes")
callback_exception_handler("ERROR: Data Length is not 4 bytes")
# callback_exception_handler("ERROR: Data Length is not 4 bytes")
self.got_data_length = True

# Read a byte into Data Buffer
Expand All @@ -301,15 +301,15 @@ def reading_data(self, rx_byte):
# Check the data type against all known data types
if not any(x.value == data_type for x in DataType):
invalid_frame = True
callback_exception_handler("ERROR: Frame Data Type Field does not match actual type.")
# callback_exception_handler("ERROR: Frame Data Type Field does not match actual type.")

# Get the data type name to use with comparing against the right data length
data_type_key = DataType(data_type).name

# Check the actual data length against the expected length for the data type
if self.data_length != DataTypeSize[data_type_key].value:
invalid_frame = True
callback_exception_handler("ERROR: Frame Data Length Field does not match actual length.")
# callback_exception_handler("ERROR: Frame Data Length Field does not match actual length.")

if invalid_frame is False:
# Append data length and data fields onto frame buffer
Expand Down Expand Up @@ -405,7 +405,7 @@ def comms_init(port, baud_rate):
GPIO.add_event_detect(DIO0_GPIO, GPIO.RISING,
callback=comms_handler.radio.rx_interrupt, bouncetime=100)

signal.signal(signal.SIGINT, signal_handler)
# signal.signal(signal.SIGINT, signal_handler)


def comms_send(data):
Expand Down
2 changes: 1 addition & 1 deletion low_level/continuous.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def adjust_continuous(calls_per_second):
except ZeroDivisionError as err:
print("\n", repr(err))
print("ERROR: Rate is 0, cannot run continuously")
callback_exception_handler("ERROR: Rate is 0, cannot run continuously")
# callback_exception_handler("ERROR: Rate is 0, cannot run continuously")


def continuous_stop():
Expand Down
2 changes: 1 addition & 1 deletion low_level/packet.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def packetize(data_to_packet, data_type, is_continuous, message_object_database,
except ZeroDivisionError as err:
print("\n", repr(err))
print("ERROR: Rate is 0, cannot run continuously")
callback_exception_handler("ERROR: Rate is 0, cannot run continuously")
# callback_exception_handler("ERROR: Rate is 0, cannot run continuously")


def delimiter_scan_and_add(data_to_scan):
Expand Down
10 changes: 5 additions & 5 deletions telecommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def timeout(self):
telecommand_database[:] = [telecommand for telecommand in telecommand_database if
not tc_search_for_id_match(telecommand, self.ID)]
# Increment the timeout counter
callback_telecommand_timeout()
# callback_telecommand_timeout()


def telecommand_register_callback(tc_update_function_ptr, tc_timeout_function_ptr, exception_handler_function_ptr):
Expand All @@ -74,7 +74,7 @@ def tc_request_send(telecommand_number, telecommand_data, telecommand_data_type,
except ValueError as err:
print(str(repr(err)))
print("ERROR: Telecommand Request Channel is invalid")
callback_exception_handler("Telecommand Request Channel is invalid")
# callback_exception_handler("Telecommand Request Channel is invalid")

try:
if telecommand_data_type == "String":
Expand Down Expand Up @@ -118,7 +118,7 @@ def tc_request_send(telecommand_number, telecommand_data, telecommand_data_type,
except UnboundLocalError as err:
print(repr(err))
print("ERROR: Could not format message")
callback_exception_handler("ERROR: Could not format message, " + type_error)
# callback_exception_handler("ERROR: Could not format message, " + type_error)


def tc_search_for_id_match(telecommand, id_to_match, action=None):
Expand Down Expand Up @@ -157,7 +157,7 @@ def tc_response(telecommand_packet):
telecommand_response_status = TelecommandResponseState.INVALID_COMMAND_ARGUMENT.name

# Pass the status back up to the GUI to display
callback_telecommand_response_update(str(telecommand_number), telecommand_response_status)
# callback_telecommand_response_update(str(telecommand_number), telecommand_response_status)

def tc_time_send(telecommand_number, unix_time_seconds, millisec_through_sec):
try:
Expand All @@ -178,5 +178,5 @@ def tc_time_send(telecommand_number, unix_time_seconds, millisec_through_sec):
except UnboundLocalError as err:
print(repr(err))
print("ERROR: Could not format message")
callback_exception_handler("ERROR: Could not format message, " + type_error)
# callback_exception_handler("ERROR: Could not format message, " + type_error)

10 changes: 5 additions & 5 deletions telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def timeout(self):
telemetry_database[:] = [telemetry for telemetry in telemetry_database if
not tlm_search_for_id_match(telemetry, self.ID)]
# Increment the timeout counter
callback_telemetry_timeout()
# callback_telemetry_timeout()


def telemetry_register_callback(tlm_update_function_ptr, tlm_rejection_update_function_ptr, tlm_timeout_function_ptr,
Expand Down Expand Up @@ -80,11 +80,11 @@ def tlm_request_send(tlm_channel, is_continuous):
except UnboundLocalError as err:
print("ERROR: ", err)
print("INFO: Could not format message")
callback_exception_handler("ERROR: Could not format message")
# callback_exception_handler("ERROR: Could not format message")
except ValueError as err:
print("ERROR: ", err)
print("INFO: Telemetry Request Channel is invalid")
callback_exception_handler("ERROR: Telemetry Request Channel is invalid")
# callback_exception_handler("ERROR: Telemetry Request Channel is invalid")


def tlm_search_for_id_match(telemetry, id_to_match, action=None):
Expand Down Expand Up @@ -112,7 +112,7 @@ def tlm_response(telemetry_packet):
not tlm_search_for_id_match(telemetry, tlm_channel, "STOP_TIMEOUT")]

# Pass the data back up to the GUI to display
callback_telemetry_response_update(str(tlm_channel), str(tlm_data))
# callback_telemetry_response_update(str(tlm_channel), str(tlm_data))


def tlm_rejection_response(telemetry_packet):
Expand All @@ -134,4 +134,4 @@ def tlm_rejection_response(telemetry_packet):
tlm_rejection_message = "INVALID_DATA_LENGTH"

# Pass the data back up to the GUI to display
callback_telemetry_rejection_response_update(str(tlm_channel), tlm_rejection_message)
# callback_telemetry_rejection_response_update(str(tlm_channel), tlm_rejection_message)
52 changes: 52 additions & 0 deletions web_server/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import flask
from flask import request, jsonify

app = flask.Flask(__name__)
app.config["DEBUG"] = True

@app.route('/api/v1/ping', methods=['GET'])
def api_all():
return jsonify({
'pong': 'success',
})


@app.route('/api/v1/telecommand/send/request', methods=['POST'])
def send_telecommand_request():
# TODO: need to add data validation here.
# TODO: How does middleware flask work? Need to add Auth JWT M2M token validation.
body = request.json
telecommand_number = body['telecommand_number']
telecommand_data = body['telecommand_data']
telecommand_data_type = body['telecommand_data_type']
is_continuous = body['is_continuous']

print('============mercury py==============')
print('TC: {}'.format(telecommand_number))
print('Data: {}'.format(telecommand_data))
print('DataType: {}'.format(telecommand_data_type))
print('Is continuous: {}'.format(is_continuous))
print('==========================')
# TODO: Talk to Jamie about connecting this to the right functions.

return 'OK'

@app.route('/api/v1/telemetry/send/request', methods=['POST'])
def send_telemetry_request():
body = request.json
tlm_channel = body['tlm_channel']
is_continuous = body['is_continuous']

print('============mercury py==============')
print('Channel: {}'.format(tlm_channel))
print('Is continuous: {}'.format(is_continuous))
print('==========================')
# TODO: Talk to Jamie about connecting this to the right functions.

return 'OK'

@app.route('/api/v1/transmit/test', methods=['POST'])
def transmit_test():
return 'OK'

app.run()