error_handler_dissector.lua 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. function error_handler_dissectors(buffer, pinfo, tree, TC_TM_PROTOCOL, offset, num_of_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 code present 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 Error code present 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 Error code present 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 Error code present 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 Error code present 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 Error code present 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 Error code present 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 Error code present 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 Error code present 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. TC_TM_PROTOCOL.fields = {
  24. 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. for i = 0, num_of_instance - 1 do
  37. local subtree1 = subtree:add(TC_TM_PROTOCOL, buffer(), "INSTANCE "..i)
  38. -- Fault Status Indication (1 byte)
  39. --subtree1:add(f_fault_status_ind, buffer(offset, 1):le_uint())
  40. --offset = offset + 1
  41. -- Total Number of Error Groups (1 byte)
  42. subtree1:add(f_total_error_groups, buffer(offset, 1):le_uint())
  43. offset = offset + 1
  44. -- Dissect each error group based on the description
  45. -- Group IO
  46. local error_group_io = buffer(offset, 1):le_uint()
  47. subtree1:add(f_error_group_io, buffer(offset, 1):le_uint())
  48. offset = offset + 1
  49. local err_io_def = {
  50. "ERR_IO_I2C_FAIL",
  51. "ERR_IO_SPI_FAIL",
  52. "ERR_IO_CAN_FAIL",
  53. "ERR_IO_UART_FAIL",
  54. "ERR_IO_QSPI_FAIL",
  55. "ERR_IO_MAX"
  56. }
  57. local temp
  58. local temp1
  59. temp = buffer(offset, 4):le_uint()
  60. for i = 1 , error_group_io do
  61. temp1 = (temp >> i) & 0x01
  62. if temp1 == 0 then
  63. subtree1:add(f_fault_status_io, temp):set_text(string.format("ERROR CODE %d : NOFAULT - %s",i - 1,err_io_def[i]))
  64. elseif temp1 == 1 then
  65. subtree1:add(f_fault_status_io, temp):set_text(string.format("ERROR CODE %d : FAULT",i - 1,err_io_def[i]))
  66. end
  67. end
  68. offset = offset + 4
  69. -- Group AHW_SET-1
  70. local error_group_ahw_set_1 = buffer(offset, 1):uint()
  71. subtree1:add(f_error_group_ahw_set_1, buffer(offset, 1):le_uint())
  72. offset = offset + 1
  73. local err_ahw_def_set_1 = {
  74. "ERR_IMU_BMX160_OBC_1",
  75. "ERR_IMU_BMX160_OBC_2",
  76. "ERR_IMU_BMX160_XXX",
  77. "ERR_DIGITAL_THERMOSTAT_DS620_EDGE",
  78. "ERR_DIGITAL_THERMOSTAT_DS620_PS",
  79. "ERR_HSC_ADM1176_EDGE",
  80. "ERR_HSC_ADM1176_PS_2",
  81. "ERR_HSC_ADM1176_PS_1",
  82. "ERR_TEMP_SENSOR_MCP9843_OBC",
  83. "ERR_TEMP_SENSOR_MCP9843_PS",
  84. "ERR_TEMP_SENSOR_MCP9843_EDGE",
  85. "ERR_TEMP_SENSOR_MCP9843_GPS",
  86. "ERR_TEMP_SENSOR_MCP9843_SPE01",
  87. "ERR_TEMP_SENSOR_MCP9843_SPE02",
  88. "ERR_TEMP_SENSOR_MCP9843_SPW01",
  89. "ERR_TEMP_SENSOR_MCP9843_SPW02",
  90. "ERR_TEMP_SENSOR_MCP9843_SPB01",
  91. "ERR_PSM_INA230_OBC",
  92. "ERR_PSM_INA230_PS",
  93. "ERR_GPIO_EXPANDER_PCAL6408A_PS",
  94. "ERR_GPIO_EXPANDER_MCP23008_EDGE_1",
  95. "ERR_GPIO_EXPANDER_MCP23008_EDGE_2",
  96. "ERR_GPIO_EXPANDER_MCP23008_OBC_1",
  97. "ERR_GPIO_EXPANDER_MCP23008_OBC_2",
  98. "ERR_GPIO_EXPANDER_MCP23008_GPS",
  99. "ERR_THRUSTER_MORPHEUS_OBC",
  100. "ERR_VOLTAGE_SEQUENCER_UCD9801_OBC",
  101. "ERR_DATA_LOGGER_ADS7828_PS",
  102. "ERR_EXT_MEM_MX25L512_QSPI",
  103. "ERR_EXT_MEM_MT25QL512_QSPI",
  104. "ERR_EXT_MEM_S25HL512T_QSPI",
  105. "ERR_EXT_MEM_MT28EW128_FMC",
  106. "ERR_AHW_ONE_MAX"
  107. }
  108. temp = buffer(offset, 4):le_uint()
  109. for i = 1 , error_group_ahw_set_1 do
  110. temp1 = (temp >> i) & 0x01
  111. if temp1 == 0 then
  112. subtree1:add(f_fault_status_ahw_set_1, temp):set_text(string.format("ERROR CODE %d : NOFAULT - %s",i-1,err_ahw_def_set_1[i]))
  113. elseif temp1 == 1 then
  114. subtree1:add(f_fault_status_ahw_set_1, temp):set_text(string.format("ERROR CODE %d : FAULT - %s",i-1,err_ahw_def_set_1[i]))
  115. end
  116. end
  117. offset = offset + 4
  118. -- Group AHW_SET-2
  119. local error_group_ahw_set_2 = buffer(offset, 1):uint()
  120. subtree1:add(f_error_group_ahw_set_2, buffer(offset, 1):le_uint())
  121. offset = offset + 1
  122. local err_ahw_def_set_2 =
  123. {
  124. "ERR_UART_EXPANDER_MAX14830_OBC",
  125. "ERR_AHW_TWO_MAX"
  126. }
  127. temp = buffer(offset, 4):le_uint()
  128. for i = 1 , error_group_ahw_set_2 do
  129. temp1 = (temp >> i) & 0x01
  130. if temp1 == 0 then
  131. subtree1:add(f_fault_status_ahw_set_2, temp):set_text(string.format("ERROR CODE %d : NOFAULT - %s",i - 1,err_ahw_def_set_2[i]))
  132. elseif temp1 == 1 then
  133. subtree1:add(f_fault_status_ahw_set_2, temp):set_text(string.format("ERROR CODE %d : FAULT",i - 1,err_ahw_def_set_2[i]))
  134. end
  135. end
  136. offset = offset + 4
  137. local err_system_def = {
  138. "ERR_IRAM_HEAP_FREE_LESSER_THAN_16K",
  139. "ERR_IRAM_HEAP_FREE_LESSER_THAN_8K",
  140. "ERR_ERAM_HEAP_FREE_LESSER_THAN_16K",
  141. "ERR_ERAM_HEAP_FREE_LESSER_THAN_8K",
  142. "ERR_CMALLOC_FREE_LESSER_THAN_4K",
  143. "ERR_OBC_FW_UPDATE_FAIL",
  144. "ERR_SYS_MAX"
  145. }
  146. -- Group SYSTEM 1
  147. local error_group_system_1 = buffer(offset, 1):uint()
  148. subtree1:add(f_error_group_system_1, buffer(offset, 1):le_uint())
  149. offset = offset + 1
  150. temp = buffer(offset, 4):le_uint()
  151. for i = 1, error_group_system_1 do
  152. temp1 = (temp >> i) & 0x01
  153. if temp1 == 0 then
  154. subtree1:add(f_fault_status_system_1, temp):set_text(string.format("ERROR CODE %d : NOFAULT - %s",i - 1,err_system_def[i]))
  155. elseif temp1 == 1 then
  156. subtree1:add(f_fault_status_system_2, temp):set_text(string.format("ERROR CODE %d : FAULT - %s",i - 1,err_system_def[i]))
  157. end
  158. end
  159. offset = offset + 4
  160. -- Group SYSTEM 2
  161. local error_group_system_2 = buffer(offset, 1):uint()
  162. subtree1:add(f_error_group_system_2, buffer(offset, 1):le_uint())
  163. offset = offset + 1
  164. local err_services_def =
  165. {
  166. "ERR_SER_1",
  167. "ERR_SER_MAX"
  168. }
  169. temp = buffer(offset, 4):le_uint()
  170. for i = 1, error_group_system_2 do
  171. temp1 = (temp >> i) & 0x01
  172. if temp1 == 0 then
  173. subtree1:add(f_fault_status_system_2, temp):set_text(string.format("ERROR CODE %d : NOFAULT - %s",i - 1,err_services_def[i]))
  174. elseif temp1 == 1 then
  175. subtree1:add(f_fault_status_system_2, temp):set_text(string.format("ERROR CODE %d : FAULT - %s",i - 1,err_services_def[i]))
  176. end
  177. end
  178. offset = offset + 4
  179. -- Group COMMS
  180. local error_group_comms = buffer(offset, 1):uint()
  181. subtree1:add(f_error_group_comms, buffer(offset, 1):le_uint())
  182. offset = offset + 1
  183. local err_comms_modules_def =
  184. {
  185. "ERR_COMMS_PKT_DROP",
  186. "ERR_COMMS_PKT_LEN_MISMATCH",
  187. "ERR_COMMS_SBAND_BUSY",
  188. "ERR_COMMS_SBAND_TCP_READ_FAIL",
  189. "ERR_COMMS_SBAND_TCP_CONNECTION_FAIL",
  190. "ERR_COMMS_SBAND_OFF_VOLT_TEMP_EXCEED",
  191. "ERR_COMMS_NACK_RCV_UHF",
  192. "ERR_COMMS_RESTART_UHF",
  193. "ERR_COMMS_SBAND_RSP_CMD",
  194. "ERR_COMMS_SBAND_BUSY_TCP_WRITE",
  195. "ERR_COMMS_SBAND_READ_UDP_RX_FAIL",
  196. "ERR_COMMS_SBAND_UDP_TX_CONNECTION_FAIL",
  197. "ERR_COMMS_SBAND_SEND_UDP_TX_FAIL",
  198. "ERR_COMMS_SBAND_READ_UDP_TX_FAIL",
  199. "ERR_COMMS_SBAND_FW_UPD_FAIL",
  200. "ERR_COMMS_UHF_RSP_TIMEOUT",
  201. "ERR_COMMS_SBAND_CFG_STE_SET_RESET_FAIL",
  202. "ERR_COMMS_SBAND_CFG_GET_FEATURE_SELECT_FAIL",
  203. "ERR_COMMS_SBAND_CFG_GET_DEVICE_CFG_FAIL",
  204. "ERR_COMMS_SBAND_CFG_SET_DEVICE_CFG_FAIL",
  205. "ERR_COMMS_SBAND_CFG_SET_DEVICE_CFG_RX_TX_ON_FAIL",
  206. "ERR_COMMS_SBAND_CFG_SET_IP_ADR_CFG_FAIL",
  207. "ERR_COMMS_SBAND_CFG_SET_RX_RCV_CFG_FAIL",
  208. "ERR_COMMS_SBAND_DFU_STE_SET_RESET_FAIL",
  209. "ERR_COMMS_SBAND_DFU_GET_FEATURE_SELECT_FAIL",
  210. "ERR_COMMS_SBAND_DFU_GET_DEVICE_CFG_FAIL",
  211. "ERR_COMMS_SBAND_DFU_SET_DEVICE_CFG_FAIL",
  212. "ERR_COMMS_SBAND_DFU_SET_DEVICE_CFG_RX_TX_ON_FAIL",
  213. "ERR_COMMS_SBAND_DFU_SET_IP_ADR_CFG_FAIL",
  214. "ERR_COMMS_SBAND_DFU_SET_RX_RCV_CFG_FAIL",
  215. "ERR_COMMS_MAX"
  216. }
  217. temp = buffer(offset, 4):le_uint()
  218. for i = 1, error_group_comms do
  219. temp1 = (temp >> i) & 0x01
  220. if temp1 == 0 then
  221. subtree1:add(f_fault_status_comms, temp):set_text(string.format("ERROR CODE %d : NO FAULT- %s",i - 1,err_comms_modules_def[i]))
  222. elseif temp1 == 1 then
  223. subtree1:add(f_fault_status_comms, temp):set_text(string.format("ERROR CODE %d : FAULT - %s",i - 1,err_comms_modules_def[i]))
  224. end
  225. end
  226. offset = offset + 4
  227. -- Group ADCS
  228. local error_group_adcs = buffer(offset, 1):uint()
  229. subtree1:add(f_error_group_adcs, buffer(offset, 1):le_uint())
  230. offset = offset + 1
  231. local err_adcs_module_def =
  232. {
  233. "ERR_IO_INTERFACE_ERR",
  234. "ERR_OPERATION_FAILURE",
  235. "ERR_TC_TM_ERROR",
  236. "ERR_INVLD_PWR_STATE",
  237. "ERR_ADCS_MAX"
  238. }
  239. temp = buffer(offset, 4):le_uint()
  240. for i = 1, error_group_adcs do
  241. temp1 = (temp >> i) & 0x01
  242. if temp1 == 0 then
  243. subtree1:add(f_fault_status_adcs, temp):set_text(string.format("ERROR CODE %d : NOFAULT - %s",i - 1,err_adcs_module_def[i] ))
  244. elseif temp1 == 1 then
  245. subtree1:add(f_fault_status_adcs, temp):set_text(string.format("ERROR CODE %d : FAULT - %s",i - 1,err_adcs_module_def[i]))
  246. end
  247. end
  248. offset = offset + 4
  249. -- Group EPS
  250. local error_group_eps = buffer(offset, 1):uint()
  251. subtree1:add(f_error_group_eps, buffer(offset, 1):le_uint())
  252. offset = offset + 1
  253. local err_eps_def =
  254. {
  255. "ERR_EPS_COM_FAIL",
  256. "ERR_EPS_CRC_FAIL",
  257. "ERR_EPS_RESP_ERR",
  258. "ERR_EPS_CTRL_FW_MISMATCH",
  259. "ERR_EPS_MAX"
  260. }
  261. temp = buffer(offset, 4):le_uint()
  262. for i = 1, error_group_eps do
  263. temp1 = (temp >> i) & 0x01
  264. if temp1 == 0 then
  265. subtree1:add(f_fault_status_eps, temp):set_text(string.format("ERROR CODE %d : NOFAULT- %s",i - 1,err_eps_def[i]))
  266. elseif temp1 == 1 then
  267. subtree1:add(f_fault_status_eps, temp):set_text(string.format("ERROR CODE %d : FAULT - %s",i - 1,err_eps_def[i]))
  268. end
  269. end
  270. offset = offset + 4
  271. end
  272. end