Skip to content
Open
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
26 changes: 13 additions & 13 deletions Data API/TCP_binary/Python/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ def decode(self, data):
print('\n\n')
print('[RTLOC BINARY API]')

if pkg_type is ord('D'):
if pkg_type == ord('D'):
print(' > Data')
(version, data_len, msg_id, frame_nr, frame_size, time_cnt) = unpack('<BBIIHB', data[i:i+13])
# print(version, data_len, msg_id, frame_nr, frame_size)

# print(" >> version = " + str(version))
if version is 3:
if version == 3:
i = i+13
else:
i = i+12
Expand Down Expand Up @@ -91,7 +91,7 @@ def decode(self, data):
bytes_remaining -= 1
i = i + 1

if(tag_type is ord('D')):
if(tag_type == ord('D')):
print(" >>> distances")
anchor_cnt = unpack('<B', data[i:i+1])[0]
i += 1
Expand All @@ -116,14 +116,14 @@ def decode(self, data):
# Add anchor array to tag_tmp array on tag_data element (3)
tag_tmp[3] = anchor

elif tag_type is ord('Q'):
elif tag_type == ord('Q'):
print(" >>> quaternions ")
tag_tmp[4] = list(unpack('<ffff', data[i:i+16]))

# print(tag_tmp[4])
i = i + 16
bytes_remaining -= 16
elif tag_type is ord('R'):
elif tag_type == ord('R'):
print(" >>> raw data ")
raw_sample_cnt = unpack('<B', data[i:i+1])[0]
i = i + 1
Expand All @@ -146,15 +146,15 @@ def decode(self, data):
tag_tmp[5] = raw_samples
# print(tag_tmp[5])

elif tag_type is ord('P'):
elif tag_type == ord('P'):
print(" >>> positions ")
tag_tmp[6] = list(unpack('<iii', data[i:i+12]))

i += 12
bytes_remaining -= 12
print(" >>>> pos = [" + str(tag_tmp[6][0]) + ", " + str(tag_tmp[6][1]) + ", " + str(tag_tmp[6][2]) + "]")

elif tag_type is ord('U'):
elif tag_type == ord('U'):
#TODO: implement userdata parsing
# print(" >>> userdata: ")
userdata_cnt = unpack('<B', data[i:i+1])[0]
Expand All @@ -165,7 +165,7 @@ def decode(self, data):
bytes_remaining -= userdata_cnt
# tag_tmp[7] = userdata

elif tag_type is ord('I'):
elif tag_type == ord('I'):
# TODO - add parsing of impulse response
print(" >>> impulse response")
print(" >>>> ERR - implement IR first ")
Expand All @@ -178,7 +178,7 @@ def decode(self, data):

# print("\n")

elif pkg_type is ord('A'):
elif pkg_type == ord('A'):
print(' > Anchorlist')
#NOTE: 24/01/2019 - version of this API updated to ver=1. Use cxRTLS40039 to use the following line, otherwise stick to version 0 (whicch doesn't have anchor_cnt)
(version, block_length, anchor_cnt) = unpack('<BBH', data[i:i+4])
Expand All @@ -197,7 +197,7 @@ def decode(self, data):

print(anchorlist)

elif pkg_type is ord('T'):
elif pkg_type == ord('T'):
print(' > Taglist')
#NOTE: 24/01/2019 - version of this API updated to ver=1. Use cxRTLS40039 to use the following line, otherwise stick to version 0 (whicch doesn't have tag_cnt)
(version, block_length, tag_cnt) = unpack('<BBH', data[i:i+4])
Expand All @@ -216,7 +216,7 @@ def decode(self, data):

print(taglist)

elif pkg_type is ord('E'):
elif pkg_type == ord('E'):
print(" > External Impulse")
# External Impulse Array
(version, block_length, imp_type, ext_imp_frame, ext_imp_offset) = unpack('<BBBIH', data[i:i+9])
Expand All @@ -232,7 +232,7 @@ def decode(self, data):
print(' >> date: ' + str(ext_imp_gps_day) + '/' + str(ext_imp_gps_month)+ '/'+ str(ext_imp_gps_year))
print(' >> time: ' + str(ext_imp_gps_hour) + ":" + str(ext_imp_gps_min) + ":"+ str(ext_imp_gps_sec) + "."+ str(ext_imp_gps_milli))

elif pkg_type is ord('X'):
elif pkg_type == ord('X'):
print(' > Node Status')
(version, block_length, node_cnt) = unpack('<BBH', data[i:i+4])
i += 4
Expand All @@ -256,4 +256,4 @@ def decode(self, data):
print('Unknown message type')
else:
#Issue in the parsing, so break out of the while loop.
i += (MAXDATASIZE + 1)
i += (MAXDATASIZE + 1)