error_handler_dissector.lua 13 KB

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