Created
October 14, 2023 23:54
-
-
Save anselmobattisti/3d16b2cb054a483a71a704c8fd560903 to your computer and use it in GitHub Desktop.
Extract Data NT11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import OrderedDict | |
msg = "" | |
positions = OrderedDict([ | |
("Start_Bit", 2), | |
("Packet_Length", 1), | |
("Protocol_Number", 1), | |
("Location_Source_Type", 1), | |
("Terminal_ID", 8), | |
("Internal_Date_Time", 6), | |
("Data_Time_GPS", 6), | |
("Quantity_of_GPS", 1), | |
("Latitude", 4), | |
("Longitude", 4), | |
("Speed", 1), | |
("Course_Status", 2), | |
("LBS Length", 1), | |
("MCC", 2), | |
("MNC", 1), | |
("LAC", 2), | |
("Cell_ID", 3), | |
("Terminal_Information", 1), | |
("Power_Voltage", 2), | |
("Battery_Voltage", 1), | |
("GSM_Signal_Strength", 1), | |
("Alarm_Language", 2), | |
("Milleage", 3), | |
("TotalHoursSum", 3), | |
("Serial_Number", 2), | |
("Error_Check", 2), | |
("Stop_Bit", 2) | |
]) | |
start = 0 | |
for k, v in positions.items(): | |
end = (start + v*2) | |
value = msg[start:end] | |
dec = int("0x{}".format(value),16) | |
print("{}: \nhex {}, dec {}\n".format(k, value, dec)) | |
start = end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment