obc_dissector.lua 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. function obc_dissector(buffer, pinfo, subtree, TC_TM_PROTOCOL, offset, instance)
  2. local f_timestamp1 = ProtoField.uint64("TC_TM_PROTOCOL.timestamp1", "Timestamp", base.DEC)
  3. local f_fsm_state = ProtoField.uint8("TC_TM_PROTOCOL.fsm_state", "Fsm State", base.DEC)
  4. local f_num_resets = ProtoField.uint8("TC_TM_PROTOCOL.num_resets", "Num of resets", base.DEC)
  5. local f_io_error = ProtoField.uint16("TC_TM_PROTOCOL.io_error", "IO error", base.DEC)
  6. local f_sys_error = ProtoField.uint8("TC_TM_PROTOCOL.sys_error", "Sys error", base.DEC)
  7. local f_cpu_until = ProtoField.float("TC_TM_PROTOCOL.cpu_until", "Cpu Until", base.DEC)
  8. local f_iram_rem_heap = ProtoField.uint32("TC_TM_PROTOCOL.iram_rem_heap", "Iram rem heap", base.DEC)
  9. local f_eram_rem_heap = ProtoField.uint32("TC_TM_PROTOCOL.eram_rem_heap", "Eram rem heap", base.DEC)
  10. local f_uptime = ProtoField.uint32("TC_TM_PROTOCOL.uptime", "Uptime", base.DEC)
  11. local f_reset_cause = ProtoField.uint8("TC_TM_PROTOCOL.reset_cause", "Reset cause", base.DEC)
  12. local f_task_count = ProtoField.uint8("TC_TM_PROTOCOL.task_count", "Task Count", base.DEC)
  13. local ipc_fail_cntr = ProtoField.uint16("TC_TM_PROTOCOL.ipc_fail_cntr", "Ipc Fail Cntr", base.DEC)
  14. -- Add the fields to the protocol
  15. TC_TM_PROTOCOL.fields = {
  16. f_timestamp1, f_fsm_state, f_num_resets,f_io_error, f_sys_error, f_cpu_until, f_iram_rem_heap,
  17. f_eram_rem_heap, f_uptime, f_reset_cause, f_task_count, f_ipc_fail_cntr
  18. }
  19. for i=0, instance-1 do
  20. local subtree1 = subtree:add(TC_TM_PROTOCOL, buffer(), "HEALTH METRIC DATA OBC")
  21. -- dissect timestamp
  22. local data1
  23. --for i=0, 8 do
  24. --data1 = buffer(offset, 8):le_uint()
  25. subtree1:add(f_timestamp1, buffer(offset, 8):le_uint64())
  26. offset = offset + 8
  27. --dissect fsm_state
  28. --local data2 = buffer(offset,1):le_uint()
  29. subtree1:add(f_fsm_state, buffer(offset,1):le_uint())
  30. offset = offset + 1
  31. --dissect f_num_resets
  32. local data3 = buffer(offset,1):le_uint()
  33. subtree1:add(f_num_resets, data3)
  34. offset = offset + 1
  35. --dissect io_error
  36. subtree1:add(f_io_error , buffer(offset, 2):le_uint())
  37. offset = offset + 2
  38. --dissect sys_error
  39. --local data2 = buffer(offset,1):le_uint()
  40. subtree1:add(f_sys_error, buffer(offset, 1):le_uint())
  41. offset = offset + 1
  42. --dissect f_cpu_until
  43. local cpu_value = buffer(offset, 4):le_float()
  44. local formatted_value = string.format("%.6f", cpu_value)
  45. subtree1:add(f_cpu_until, formatted_value)
  46. offset = offset + 4
  47. --dissect f_iram_rem_heap
  48. subtree1:add(f_iram_rem_heap, buffer(offset, 4):le_uint())
  49. offset = offset + 4
  50. --dissect f_eram_rem_heap
  51. subtree1:add(f_eram_rem_heap, buffer(offset, 4):le_uint())
  52. offset = offset + 4
  53. --dissect f_uptime
  54. subtree1:add(f_uptime, buffer(offset, 4):le_uint())
  55. offset = offset + 4
  56. --dissect f_reset_cause
  57. subtree1:add(f_reset_cause, buffer(offset, 1):le_uint())
  58. offset = offset + 1
  59. --dissect f_task_count
  60. local task_count = buffer(offset, 1):le_uint()
  61. subtree1:add(f_task_count, buffer(offset, 1):le_uint())
  62. offset = offset + 1
  63. for i=0, task_count - 1 do
  64. local fail = buffer(offset, 2):le_uint()
  65. if fail == 0 then
  66. i = i + 2
  67. offset = offset + 2
  68. else
  69. subtree1:add(f_ipc_fail_cntr, buffer(offset, 2):le_uint())
  70. offset = offset + 2
  71. i = i + 2
  72. end
  73. end
  74. end
  75. end