Skip to content

Commit

Permalink
Merge branch 'user/Evan012/at_command_support_multiple_message_parse'…
Browse files Browse the repository at this point in the history
… of github.com:UBC-Solar/sunlink into user/Evan012/at_command_support_multiple_message_parse
  • Loading branch information
EvanO12 committed May 31, 2024
2 parents 7eb3d7f + a0c438c commit 2347def
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions link_telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,46 @@ def upload_logs(args, live_filters, log_filters, endpoint):
# Call the memorator log uploader function
memorator_upload_script(sendToParser, live_filters, log_filters, args, endpoint)

def process_message(message: str, buffer: str = "") -> list:

# Add buffer to the start of the message
message = buffer + message

# Split the message by 7e and one of 88, 97, 10 (types of radio messages we get)
pattern = '(?=7E....88|7E....97|7E....10)'
parts = re.split(pattern, message)

if len(parts) > 1:
buffer = parts.pop()

return [bytes.fromhex(part).decode('latin-1') for part in parts]


"""""
smaller_parts = []
for part in parts:
if part[3] == '10':
if part[17] == CAN_BYTE:
smaller_parts.extend(split_api_packet(part, CAN_MSG_LENGTH, CAN_BYTE))
elif part[17] == IMU_BYTE:
smaller_parts.extend(split_api_packet(part, IMU_MSG_LENGTH, IMU_BYTE))
elif part[17] == GPS_BYTE:
smaller_parts.extend(split_api_packet(part, GPS_MSG_LENGTH, GPS_BYTE))
else:
smaller_parts.extend(UNKNOWN_BYTE + part)
elif part[3] == '88':
smaller_parts.extend(LOCAL_AT_BYTE + part)
elif part[3] == '97':
smaller_parts.extend(REMOTE_AT_BYTE + part)
else:
smaller_parts.extend(UNKNOWN_BYTE + part)
return [bytes.fromhex(part).decode('latin-1') for part in smaller_parts] , buffer
def split_api_packet(message, message_size, message_byte):
return [message_byte + message[i: i + message_size] for i in range(19, len(message), message_size)]
"""
"""
Purpose: Sends data and filters to parser and registers a callback to process the response
Parameters:
Expand Down Expand Up @@ -589,6 +627,7 @@ def main():
elif not args.log:
log_filters = ["NONE"]


# <----- Configuration confirmation ----->
if not args.log_upload:
print_config_table(args, live_filters)
Expand Down

0 comments on commit 2347def

Please sign in to comment.