error_handler_dissector.lua 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. function error_handler_dissectors(buffer, pinfo, tree, TC_TM_PROTOCOL, offset, instance)
  2. -- Define the fields of the protocol
  3. local f_fault_status_ind = ProtoField.uint8("TC_TM_PROTOCOL.fault_status_ind", "Fault Status Indication", base.HEX)
  4. local f_total_error_groups = ProtoField.uint8("TC_TM_PROTOCOL.total_error_groups", "Total Number of Error Groups", base.DEC)
  5. -- Define the fields for each error group and fault status
  6. local f_error_group_io = ProtoField.uint8("TC_TM_PROTOCOL.error_group_io", "Total Number of Errors in IO", base.DEC)
  7. local f_fault_status_io = ProtoField.uint32("TC_TM_PROTOCOL.fault_status_io", "Fault Status of Group IO", base.HEX)
  8. local f_error_group_ahw_set_1 = ProtoField.uint8("TC_TM_PROTOCOL.error_group_ahw_set_1", "Total Number of Errors in AHW_SET-1", base.DEC)
  9. local f_fault_status_ahw_set_1 = ProtoField.uint32("TC_TM_PROTOCOL.fault_status_ahw_set_1", "Fault Status of Group AHW_SET-1", base.HEX)
  10. local f_error_group_ahw_set_2 = ProtoField.uint8("TC_TM_PROTOCOL.error_group_ahw_set_2", "Total Number of Errors in AHW_SET-2", base.DEC)
  11. local f_fault_status_ahw_set_2 = ProtoField.uint32("TC_TM_PROTOCOL.fault_status_ahw_set_2", "Fault Status of Group AHW_SET-2", base.HEX)
  12. local f_error_group_system_1 = ProtoField.uint8("TC_TM_PROTOCOL.error_group_system_1", "Total Number of Errors in SYSTEM Group 1", base.DEC)
  13. local f_fault_status_system_1 = ProtoField.uint32("TC_TM_PROTOCOL.fault_status_system_1", "Fault Status of Group SYSTEM 1", base.HEX)
  14. local f_error_group_system_2 = ProtoField.uint8("TC_TM_PROTOCOL.error_group_system_2", "Total Number of Errors in SYSTEM Group 2", base.DEC)
  15. local f_fault_status_system_2 = ProtoField.uint32("TC_TM_PROTOCOL.fault_status_system_2", "Fault Status of Group SYSTEM 2", base.HEX)
  16. local f_error_group_comms = ProtoField.uint8("TC_TM_PROTOCOL.error_group_comms", "Total Number of Errors in COMMS", base.DEC)
  17. local f_fault_status_comms = ProtoField.uint32("TC_TM_PROTOCOL.fault_status_comms", "Fault Status of Group COMMS", base.HEX)
  18. local f_error_group_adcs = ProtoField.uint8("TC_TM_PROTOCOL.error_group_adcs", "Total Number of Errors in ADCS", base.DEC)
  19. local f_fault_status_adcs = ProtoField.uint32("TC_TM_PROTOCOL.fault_status_adcs", "Fault Status of Group ADCS", base.HEX)
  20. local f_error_group_eps = ProtoField.uint8("TC_TM_PROTOCOL.error_group_eps", "Total Number of Errors in EPS", base.DEC)
  21. local f_fault_status_eps = ProtoField.uint32("TC_TM_PROTOCOL.fault_status_eps", "Fault Status of Group EPS", base.HEX)
  22. -- Add all fields to the protocol
  23. tm_protocol.fields = {
  24. f_fault_status_ind, f_total_error_groups,
  25. f_error_group_io, f_fault_status_io,
  26. f_error_group_ahw_set_1, f_fault_status_ahw_set_1,
  27. f_error_group_ahw_set_2, f_fault_status_ahw_set_2,
  28. f_error_group_system_1, f_fault_status_system_1,
  29. f_error_group_system_2, f_fault_status_system_2,
  30. f_error_group_comms, f_fault_status_comms,
  31. f_error_group_adcs, f_fault_status_adcs,
  32. f_error_group_eps, f_fault_status_eps
  33. }
  34. -- Create a subtree for the protocol
  35. local subtree = tree:add(TC_TM_PROTOCOL, buffer(), "ERROR HANDLER")
  36. -- Fault Status Indication (1 byte)
  37. subtree:add(f_fault_status_ind, buffer(offset, 1):le_uint())
  38. offset = offset + 1
  39. -- Total Number of Error Groups (1 byte)
  40. subtree:add(f_total_error_groups, buffer(offset, 1):le_uint())
  41. offset = offset + 1
  42. -- Dissect each error group based on the description
  43. -- Group IO
  44. --local error_group_io = buffer(offset, 1):le_uint()
  45. subtree:add(f_error_group_io, buffer(offset, 1):le_unit())
  46. offset = offset + 1
  47. local temp
  48. local temp1
  49. temp = buffer(offset, 4):le_uint()
  50. for i = 0, error_group_io - 1 do
  51. temp1 = (temp >> i) & 0x01
  52. if temp1 == 0 then
  53. subtree:add(f_fault_status_io, temp):set_text(string.format("NOFAULT"))
  54. elseif temp1 == 1 then
  55. subtree:add(f_fault_status_io, temp):set_text(string.format("FAULT"))
  56. end
  57. end
  58. offset = offset + 4
  59. -- Group AHW_SET-1
  60. --local error_group_ahw_set_1 = buffer(offset, 1):uint()
  61. subtree:add(f_error_group_ahw_set_1, buffer(offset, 1):le_uint())
  62. offset = offset + 1
  63. temp = buffer(offset, 4):le_uint()
  64. for i = 0, error_group_ahw_set_1 - 1 do
  65. temp1 = (temp >> i) & 0x01
  66. if temp1 == 0 then
  67. subtree:add(f_fault_status_ahw_set_1, temp):set_text(string.format("NOFAULT"))
  68. elseif temp1 == 1 then
  69. subtree:add(f_fault_status_ahw_set_1, temp):set_text(string.format("FAULT"))
  70. end
  71. end
  72. offset = offset + 4
  73. -- Group AHW_SET-2
  74. --local error_group_ahw_set_2 = buffer(offset, 1):uint()
  75. subtree:add(f_error_group_ahw_set_2, buffer(offset, 1):le_uint())
  76. offset = offset + 1
  77. temp = buffer(offset, 4):le_uint()
  78. for i = 0, error_group_ahw_set_2 - 1 do
  79. temp1 = (temp >> i) & 0x01
  80. if temp1 == 0 then
  81. subtree:add(f_fault_status_ahw_set_2, temp):set_text(string.format("NOFAULT"))
  82. elseif temp1 == 1 then
  83. subtree:add(f_fault_status_ahw_set_2, temp):set_text(string.format("FAULT"))
  84. end
  85. end
  86. offset = offset + 4
  87. -- Group SYSTEM 1
  88. --local error_group_system_1 = buffer(offset, 1):uint()
  89. subtree:add(f_error_group_system_1, buffer(offset, 1):le_uint())
  90. offset = offset + 1
  91. temp = buffer(offset, 4):le_uint()
  92. for i = 0, error_group_system_1 - 1 do
  93. temp1 = (temp >> i) & 0x01
  94. if temp1 == 0 then
  95. subtree:add(f_fault_status_system_1, temp):set_text(string.format("NOFAULT"))
  96. elseif temp1 == 1 then
  97. subtree:add(f_fault_status_system_2, temp):set_text(string.format("FAULT"))
  98. end
  99. end
  100. offset = offset + 4
  101. -- Group SYSTEM 2
  102. --local error_group_system_2 = buffer(offset, 1):uint()
  103. subtree:add(f_error_group_system_2, buffer(offset, 1):le_uint())
  104. offset = offset + 1
  105. temp = buffer(offset, 4):le_uint()
  106. for i = 0, error_group_system_2 - 1 do
  107. temp1 = (temp >> i) & 0x01
  108. if temp1 == 0 then
  109. subtree:add(f_fault_status_system_2, temp):set_text(string.format("NOFAULT"))
  110. elseif temp1 == 1 then
  111. subtree:add(f_fault_status_system_2, temp):set_text(string.format("FAULT"))
  112. end
  113. end
  114. offset = offset + 4
  115. -- Group COMMS
  116. --local error_group_comms = buffer(offset, 1):uint()
  117. subtree:add(f_error_group_comms, buffer(offset, 1):le_uint())
  118. offset = offset + 1
  119. temp = buffer(offset, 4):le_uint()
  120. for i = 0, error_group_comms - 1 do
  121. temp1 = (temp >> i) & 0x01
  122. if temp1 == 0 then
  123. subtree:add(f_fault_status_comms, temp):set_text(string.format("NOFAULT"))
  124. elseif temp1 == 1 then
  125. subtree:add(f_fault_status_comms, temp):set_text(string.format("FAULT"))
  126. end
  127. end
  128. offset = offset + 4
  129. -- Group ADCS
  130. --local error_group_adcs = buffer(offset, 1):uint()
  131. subtree:add(f_error_group_adcs, buffer(offset, 1):le_uint())
  132. offset = offset + 1
  133. temp = buffer(offset, 4):le_uint()
  134. for i = 0, error_group_adcs - 1 do
  135. temp1 = (temp >> i) & 0x01
  136. if temp1 == 0 then
  137. subtree:add(f_fault_status_adcs, temp):set_text(string.format("NOFAULT"))
  138. elseif temp1 == 1 then
  139. subtree:add(f_fault_status_adcs, temp):set_text(string.format("FAULT"))
  140. end
  141. end
  142. offset = offset + 4
  143. -- Group EPS
  144. --local error_group_eps = buffer(offset, 1):uint()
  145. subtree:add(f_error_group_eps, buffer(offset, 1):le_uint())
  146. offset = offset + 1
  147. temp = buffer(offset, 4):le_uint()
  148. for i = 0, error_group_eps - 1 do
  149. temp1 = (temp >> i) & 0x01
  150. if temp1 == 0 then
  151. subtree:add(f_fault_status_eps, temp):set_text(string.format("NOFAULT"))
  152. elseif temp1 == 1 then
  153. subtree:add(f_fault_status_eps, temp):set_text(string.format("FAULT"))
  154. end
  155. end
  156. offset = offset + 4
  157. end