Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anselmobattisti/3d16b2cb054a483a71a704c8fd560903 to your computer and use it in GitHub Desktop.
Save anselmobattisti/3d16b2cb054a483a71a704c8fd560903 to your computer and use it in GitHub Desktop.
Extract Data NT11
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