tm_get_sband_version.lua 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. function tm_get_sband_version(buffer, pinfo, tree, sband_version, offset)
  2. -- Define ProtoFields
  3. local f_file_cnt = ProtoField.uint8("sband_version.file_cnt", "File Count", base.DEC)
  4. local f_file_name_cnt = ProtoField.uint8("sband_version.file_name_cnt", "File Name Count", base.DEC)
  5. local f_seconds = ProtoField.uint8("sband_version.seconds", "Seconds", base.DEC)
  6. local f_minutes = ProtoField.uint8("sband_version.minutes", "Minutes", base.DEC)
  7. local f_hours = ProtoField.uint8("sband_version.hours", "Hours", base.DEC)
  8. local f_year = ProtoField.uint16("sband_version.year", "Year", base.DEC)
  9. local f_months = ProtoField.uint8("sband_version.months", "Months", base.DEC)
  10. local f_day = ProtoField.uint8("sband_version.day", "Day", base.DEC)
  11. local f_file_name = ProtoField.bytes("sband_version.file_name", "File Name")
  12. local f_start_adr = ProtoField.uint32("sband_version.start_adr", "Start Address", base.HEX)
  13. local f_len = ProtoField.uint32("sband_version.len", "Length", base.DEC)
  14. local f_flags = ProtoField.uint8("sband_version.flags", "Flags", base.HEX)
  15. -- Register the fields in the protocol
  16. sband_version.fields = {
  17. f_file_cnt, f_file_name_cnt,
  18. f_seconds, f_minutes, f_hours, f_year, f_months, f_day,
  19. f_file_name, f_start_adr, f_len, f_flags
  20. }
  21. -- Create the subtree for `version_date_struct`
  22. local subtree = tree:add(sband_version, buffer(), "TM GET SBAND VERSION")
  23. -- Parse `file_cnt`
  24. local cnt = buffer(offset, 1):le_uint()
  25. subtree:add(f_file_cnt, buffer(offset, 1))
  26. offset = offset + 1
  27. -- Parse `file_name_cnt`
  28. --subtree:add(f_file_name_cnt, buffer(offset, 1))
  29. --offset = offset + 1
  30. -- Parse `VERSION_DATE_STRUCT`
  31. for i = 0 , cnt - 1 do
  32. local version_subtree = subtree:add(buffer(offset), "VERSION_DATE_STRUCT")
  33. -- Parse the packed date/time fields (32 bits)
  34. local date_time_value = buffer(offset, 4):le_uint()
  35. version_subtree:add(f_seconds, (date_time_value & 0x3F)) -- 6 bits
  36. version_subtree:add(f_minutes, ((date_time_value >> 6) & 0x3F)) -- 6 bits
  37. version_subtree:add(f_hours, ((date_time_value >> 12) & 0x1F)) -- 5 bits
  38. version_subtree:add(f_year, ((date_time_value >> 17) & 0x3F)) -- 6 bits
  39. version_subtree:add(f_months, ((date_time_value >> 23) & 0x0F)) -- 4 bits
  40. version_subtree:add(f_day, ((date_time_value >> 27) & 0x1F)) -- 5 bits
  41. offset = offset + 4
  42. -- Parse `FileName` (4 bytes)
  43. version_subtree:add(f_file_name, buffer(offset, 4))
  44. offset = offset + 4
  45. -- Parse `start_adr` (32 bits)
  46. version_subtree:add_le(f_start_adr, buffer(offset, 4))
  47. offset = offset + 4
  48. -- Parse the packed `len` and `Flags` fields (32 bits)
  49. local len_flags_value = buffer(offset, 4):le_uint()
  50. version_subtree:add(f_len, (len_flags_value & 0x0FFFFFFF)) -- 28 bits
  51. version_subtree:add(f_flags, ((len_flags_value >> 28) & 0x0F)) -- 4 bits
  52. offset = offset + 4
  53. end
  54. end