tm_get_adcs_state.lua 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. function tm_get_adcs_state(buffer, pinfo, tree, adcs_protocol, offset)
  2. local f_operation_status = ProtoField.uint8("adcs_protocol.operation_status", "Operation Status", base.HEX)
  3. local f_epoch_time = ProtoField.uint32("adcs_protocol.epoch_time", "Epoch Time", base.DEC)
  4. local f_attitude_estimation_mode = ProtoField.uint8("adcs_protocol.attitude_estimation_mode", "Attitude Estimation Mode", base.DEC)
  5. local f_control_mode = ProtoField.uint8("adcs_protocol.control_mode", "Control Mode", base.DEC)
  6. local f_adcs_run_mode = ProtoField.uint8("adcs_protocol.adcs_run_mode", "ADCS Run Mode", base.DEC)
  7. local f_asgp4_mode = ProtoField.uint8("adcs_protocol.asgp4_mode", "ASGP4 Mode", base.DEC)
  8. -- Define boolean fields for enabled flags
  9. local f_cube_control_signal_enabled = ProtoField.bool("adcs_protocol.cube_control_signal_enabled", "Cube Control Signal Enabled")
  10. local f_cube_control_motor_enabled = ProtoField.bool("adcs_protocol.cube_control_motor_enabled", "Cube Control Motor Enabled")
  11. local f_cubesense1_enabled = ProtoField.bool("adcs_protocol.cubesense1_enabled", "Cubesense1 Enabled")
  12. local f_cubesense2_enabled = ProtoField.bool("adcs_protocol.cubesense2_enabled", "Cubesense2 Enabled")
  13. local f_cube_wheel1_enabled = ProtoField.bool("adcs_protocol.cube_wheel1_enabled", "Cube Wheel 1 Enabled")
  14. local f_cube_wheel2_enabled = ProtoField.bool("adcs_protocol.cube_wheel2_enabled", "Cube Wheel 2 Enabled")
  15. local f_cube_wheel3_enabled = ProtoField.bool("adcs_protocol.cube_wheel3_enabled", "Cube Wheel 3 Enabled")
  16. local f_cube_star_enabled = ProtoField.bool("adcs_protocol.cube_star_enabled", "Cube Star Enabled")
  17. local f_gps_receiver_enabled = ProtoField.bool("adcs_protocol.gps_receiver_enabled", "GPS Receiver Enabled")
  18. local f_gps_lna_power_enabled = ProtoField.bool("adcs_protocol.gps_lna_power_enabled", "GPS LNA Power Enabled")
  19. local f_motor_driver_enabled = ProtoField.bool("adcs_protocol.motor_driver_enabled", "Motor Driver Enabled")
  20. local f_sun_is_above_local_horizon = ProtoField.bool("adcs_protocol.sun_is_above_local_horizon", "Sun is Above Local Horizon")
  21. -- Communication error fields
  22. local f_cubesense1_comm_error = ProtoField.bool("adcs_protocol.cubesense1_comm_error", "Cubesense1 Communications Error")
  23. local f_cubesense2_comm_error = ProtoField.bool("adcs_protocol.cubesense2_comm_error", "Cubesense2 Communications Error")
  24. local f_cubcontrol_signal_comm_error = ProtoField.bool("adcs_protocol.cubcontrol_signal_comm_error", "CubeControl Signal Communications Error")
  25. local f_cubcontrol_motor_comm_error = ProtoField.bool("adcs_protocol.cubcontrol_motor_comm_error", "CubeControl Motor Communications Error")
  26. local f_cubewheel1_comm_error = ProtoField.bool("adcs_protocol.cubewheel1_comm_error", "Cube Wheel 1 Communications Error")
  27. local f_cubewheel2_comm_error = ProtoField.bool("adcs_protocol.cubewheel2_comm_error", "Cube Wheel 2 Communications Error")
  28. local f_cubewheel3_comm_error = ProtoField.bool("adcs_protocol.cubewheel2_comm_error", "Cube Wheel 3 Communications Error")
  29. local f_cubestar_comm_error = ProtoField.bool("adcs_protocol.cubewheel2_comm_error", "Cube star communications Error")
  30. local f_magnetometer_range_error = ProtoField.bool("adcs_protocol.magnetometer_range_error", "Magnetometer Range Error")
  31. local f_cam1_sram_overcurrent = ProtoField.bool("adcs_protocol.cam1_sram_overcurrent", "Cam1 SRAM Overcurrent Detected")
  32. local f_cam1_3v3_overcurrent = ProtoField.bool("adcs_protocol.cam1_3v3_overcurrent", "Cam1 3v3 Overcurrent Detected")
  33. local f_cam1_sensor_busy = ProtoField.bool("adcs_protocol.cam1_sensor_busy", "Cam1 Sensor Busy Error")
  34. local f_cam1_sensor_detection_error = ProtoField.bool("adcs_protocol.cam1_sensor_detection_error", "Cam1 Sensor Detection Error")
  35. local f_sun_sensor_range_error = ProtoField.bool("adcs_protocol.sun_sensor_range_error", "Sun Sensor Range Error")
  36. local f_cam2_sram_overcurrent = ProtoField.bool("adcs_protocol.cam2_sram_overcurrent", "Cam2 SRAM Overcurrent Detected")
  37. local f_cam2_3v3_overcurrent = ProtoField.bool("adcs_protocol.cam2_3v3_overcurrent", "Cam2 3v3 Overcurrent Detected")
  38. local f_cam2_sensor_busy = ProtoField.bool("adcs_protocol.cam2_sensor_busy", "Cam2 Sensor Busy Error")
  39. local f_cam2_sensor_detection_error = ProtoField.bool("adcs_protocol.cam2_sensor_detection_error", "Cam2 Sensor Detection Error")
  40. local f_nadir_sensor_range_error = ProtoField.bool("adcs_protocol.nadir_sensor_range_error", "Nadir Sensor Range Error")
  41. local f_rate_sensor_range_error = ProtoField.bool("adcs_protocol.rate_sensor_range_error", "Rate Sensor Range Error")
  42. local f_wheel_speed_range_error = ProtoField.bool("adcs_protocol.wheel_speed_range_error", "Wheel Speed Range Error")
  43. local f_coarse_sun_sensor_error = ProtoField.bool("adcs_protocol.coarse_sun_sensor_error", "Coarse Sun Sensor Error")
  44. local f_star_tracker_match_error = ProtoField.bool("adcs_protocol.star_tracker_match_error", "Star Tracker Match Error")
  45. local f_star_tracker_overcurrent = ProtoField.bool("adcs_protocol.star_tracker_overcurrent", "Star Tracker Overcurrent Detected")
  46. local f_orbit_parameters_invalid = ProtoField.bool("adcs_protocol.orbit_parameters_invalid", "Orbit Parameters are Invalid")
  47. local f_configuration_invalid = ProtoField.bool("adcs_protocol.configuration_invalid", "Configuration is Invalid")
  48. local f_control_mode_change_not_allowed = ProtoField.bool("adcs_protocol.control_mode_change_not_allowed", "Control Mode Change is not allowed")
  49. local f_estimator_change_not_allowed = ProtoField.bool("adcs_protocol.estimator_change_not_allowed", "Estimator Change is not allowed")
  50. -- Define Magnetometer Sampling Mode field (2 bytes)
  51. local f_magnetometer_sampling_mode = ProtoField.uint8("adcs_protocol.magnetometer_sampling_mode", "Magnetometer Sampling Mode", base.DEC)
  52. -- Define runtime error fields
  53. local f_cubesense1_runtime_error = ProtoField.bool("adcs_protocol.cubesense1_runtime_error", "CubeSense1 Runtime Error")
  54. local f_cubesense2_runtime_error = ProtoField.bool("adcs_protocol.cubesense2_runtime_error", "CubeSense2 Runtime Error")
  55. local f_cubecontrol_signal_runtime_error = ProtoField.bool("adcs_protocol.cubecontrol_signal_runtime_error", "CubeControl Signal Runtime Error")
  56. local f_cubecontrol_motor_runtime_error = ProtoField.bool("adcs_protocol.cubecontrol_motor_runtime_error", "CubeControl Motor Runtime Error")
  57. local f_cubewheel1_runtime_error = ProtoField.bool("adcs_protocol.cubewheel1_runtime_error", "CubeWheel1 Runtime Error")
  58. local f_a = ProtoField.bool("adcs_protocol.cubewheel1_runtime_error", "CubeWheel1 Runtime Error")
  59. local f_b = ProtoField.bool("adcs_protocol.cubewheel1_runtime_error", "CubeWheel1 Runtime Error")
  60. local f_cubewheel2_runtime_error = ProtoField.bool("adcs_protocol.cubewheel2_runtime_error", "CubeWheel2 Runtime Error")
  61. local f_cubewheel3_runtime_error = ProtoField.bool("adcs_protocol.cubewheel3_runtime_error", "CubeWheel3 Runtime Error")
  62. local f_cubestar_runtime_error = ProtoField.bool("adcs_protocol.cubestar_runtime_error", "CubeStar Runtime Error")
  63. local f_magnetometer_error = ProtoField.bool("adcs_protocol.magnetometer_error", "Magnetometer Error")
  64. local f_rate_sensor_failure = ProtoField.bool("adcs_protocol.rate_sensor_failure", "Rate Sensor Failure")
  65. -- Add all fields to the protocol
  66. adcs_protocol.fields = {
  67. f_operation_status,
  68. f_epoch_time,
  69. f_attitude_estimation_mode,
  70. f_control_mode,
  71. f_adcs_run_mode,
  72. f_asgp4_mode,
  73. f_cube_control_signal_enabled,
  74. f_cube_control_motor_enabled,
  75. f_cubesense1_enabled,
  76. f_cubesense2_enabled,
  77. f_cube_wheel1_enabled,
  78. f_cube_wheel2_enabled,
  79. f_cube_wheel3_enabled,
  80. f_cube_star_enabled,
  81. f_gps_receiver_enabled,
  82. f_gps_lna_power_enabled,
  83. f_motor_driver_enabled,
  84. f_sun_is_above_local_horizon,
  85. f_cubesense1_comm_error,
  86. f_cubesense2_comm_error,
  87. f_cubcontrol_signal_comm_error,
  88. f_cubcontrol_motor_comm_error,
  89. f_cubewheel1_comm_error,
  90. f_cubewheel2_comm_error,
  91. f_cubewheel3_comm_error,
  92. f_cubestar_comm_error,
  93. f_magnetometer_range_error,
  94. f_cam1_sram_overcurrent,
  95. f_cam1_3v3_overcurrent,
  96. f_cam1_sensor_busy,
  97. f_cam1_sensor_detection_error,
  98. f_sun_sensor_range_error,
  99. f_cam2_sram_overcurrent,
  100. f_cam2_3v3_overcurrent,
  101. f_cam2_sensor_busy,
  102. f_cam2_sensor_detection_error,
  103. f_nadir_sensor_range_error,
  104. f_rate_sensor_range_error,
  105. f_wheel_speed_range_error,
  106. f_coarse_sun_sensor_error,
  107. f_star_tracker_match_error,
  108. f_star_tracker_overcurrent,
  109. f_orbit_parameters_invalid,
  110. f_a,
  111. f_b,
  112. f_configuration_invalid,
  113. f_control_mode_change_not_allowed,
  114. f_estimator_change_not_allowed,
  115. f_magnetometer_sampling_mode,
  116. f_cubesense1_runtime_error,
  117. f_cubesense2_runtime_error,
  118. f_cubecontrol_signal_runtime_error,
  119. f_cubecontrol_motor_runtime_error,
  120. f_cubewheel1_runtime_error,
  121. f_cubewheel2_runtime_error,
  122. f_cubewheel3_runtime_error,
  123. f_cubestar_runtime_error,
  124. f_magnetometer_error,
  125. f_rate_sensor_failure
  126. }
  127. local subtree = tree:add(adcs_protocol, buffer(), "TM GET ADCS CURRENT STATE")
  128. offset = offset + 3
  129. local data = buffer(offset,1):le_int()
  130. offset = offset + 1
  131. if data == 0 then
  132. -- Parse Attitude Estimation Mode (8 bits)
  133. subtree:add(f_attitude_estimation_mode, buffer(offset, 1):le_uint())
  134. offset = offset + 1
  135. -- Parse Control Mode (8 bits)
  136. subtree:add(f_control_mode, buffer(offset, 1):le_uint())
  137. offset = offset + 1
  138. -- Parse ADCS Run Mode (2 bits / 2 bytes)
  139. local a=buffer(offset, 1):le_uint()
  140. subtree:add(f_adcs_run_mode, a & 0x03)
  141. -- Parse ASGP4 Mode (2 bits / 2 bytes)
  142. subtree:add(f_asgp4_mode, (a >> 2) & 0x03)
  143. subtree:add(f_cube_control_signal_enabled, (a >> 4) & 0x01)
  144. subtree:add(f_cube_control_motor_enabled,(a >> 5) & 0x01 )
  145. subtree:add(f_cubesense1_enabled,(a >> 6) & 0x01 )
  146. subtree:add(f_cubesense2_enabled,(a >> 7) & 0x01 )
  147. offset = offset + 1
  148. -- Parse CubeWheel Enabled Flags
  149. a=buffer(offset, 1):le_uint()
  150. subtree:add(f_cube_wheel1_enabled, (a >> 0) & 0x01)
  151. subtree:add(f_cube_wheel2_enabled, (a >> 1) & 0x01)
  152. subtree:add(f_cube_wheel3_enabled, (a >> 2) & 0x01)
  153. subtree:add(f_cube_star_enabled, (a >> 3) & 0x01)
  154. subtree:add(f_gps_receiver_enabled, (a >> 4) & 0x01)
  155. subtree:add(f_gps_lna_power_enabled, (a >> 5) & 0x01) -- GPS LNA Power Enabled
  156. subtree:add(f_motor_driver_enabled, (a >> 6) & 0x01) -- Motor Driver Enabled
  157. subtree:add(f_sun_is_above_local_horizon, (a >> 7) & 0x01) -- Sun is Above Local Horizon
  158. offset = offset + 1
  159. a = buffer(offset, 1):le_uint()
  160. -- Communication error flags
  161. subtree:add(f_cubesense1_comm_error, (a >> 0) & 0x01) -- Cubesense1 Communications Error
  162. subtree:add(f_cubesense2_comm_error, (a >> 1) & 0x01) -- Cubesense2 Communications Error
  163. subtree:add(f_cubcontrol_signal_comm_error, (a >> 2) & 0x01) -- CubeControl Signal Communications Error
  164. subtree:add(f_cubcontrol_motor_comm_error, (a >> 3) & 0x01) -- CubeControl Motor Communications Error
  165. subtree:add(f_cubewheel1_comm_error, (a >> 4) & 0x01) -- Cube Wheel1 Communications Error
  166. subtree:add(f_cubewheel2_comm_error, (a >> 5) & 0x01) -- Cube Wheel2 Communications Error
  167. subtree:add(f_cubewheel3_comm_error, (a >> 6) & 0x01)
  168. subtree:add(f_cubestar_comm_error, (a >> 7) & 0x01)
  169. offset = offset + 1
  170. a=buffer(offset, 1):le_uint()
  171. subtree:add(f_magnetometer_range_error, (a >> 0) & 0x01) -- Magnetometer Range Error
  172. subtree:add(f_cam1_sram_overcurrent, (a >> 1) & 0x01) -- Cam1 SRAM Overcurrent Detected
  173. subtree:add(f_cam1_3v3_overcurrent, (a >> 2) & 0x01) -- Cam1 3v3 Overcurrent Detected
  174. subtree:add(f_cam1_sensor_busy, (a >> 3) & 0x01) -- Cam1 Sensor Busy Error
  175. subtree:add(f_cam1_sensor_detection_error, (a >> 4) & 0x01 ) -- Cam1 Sensor Detection Error
  176. subtree:add(f_sun_sensor_range_error, (a >> 5) & 0x01) -- Sun Sensor Range Error
  177. subtree:add(f_cam2_sram_overcurrent, (a >> 6) & 0x01) -- Cam2 SRAM Overcurrent Detected
  178. subtree:add(f_cam2_3v3_overcurrent, (a >> 7) & 0x01) -- Cam2 3v3 Overcurrent Detected
  179. offset=offset+1
  180. local data=buffer(offset, 1):le_uint()
  181. subtree:add(f_cam2_sensor_busy, (data >> 0) & 0x01) -- Cam2 Sensor Busy Error
  182. subtree:add(f_cam2_sensor_detection_error, (data >> 1) & 0x01) -- Cam2 Sensor Detection Error
  183. subtree:add(f_nadir_sensor_range_error, (data >> 2) & 0x01) -- Nadir Sensor Range Error
  184. subtree:add(f_rate_sensor_range_error, (data >> 3) & 0x01) -- Rate Sensor Range Error
  185. subtree:add(f_wheel_speed_range_error,(data >> 4) & 0x01) -- Wheel Speed Range Error
  186. -- Error flags for sensors and system issues
  187. subtree:add(f_coarse_sun_sensor_error,(data >> 5) & 0x01) -- Coarse Sun Sensor Error
  188. subtree:add(f_star_tracker_match_error, (data >> 6) & 0x01) -- Star Tracker Match Error
  189. subtree:add(f_star_tracker_overcurrent, (data >> 7) & 0x01) -- Star Tracker Overcurrent Detected
  190. offset = offset + 1
  191. data = buffer(offset, 1):le_uint()
  192. subtree:add(f_orbit_parameters_invalid, (data >> 0) & 0x01) -- Orbit Parameters are Invalid
  193. subtree:add(f_configuration_invalid,(data >> 1) & 0x01) -- Configuration is Invalid
  194. subtree:add(f_control_mode_change_not_allowed, (data >> 2) & 0x01) -- Control Mode Change is Not Allowed
  195. subtree:add(f_estimator_change_not_allowed, (data >> 3) & 0x01) -- Estimator Change is Not Allowed
  196. -- Magnetometer Sampling Mode (2 bits)
  197. subtree:add(f_magnetometer_sampling_mode, (data >> 4) & 0x03) -- Current Magnetometer Sampling Mode
  198. -- Runtime error flags for sensors and systems
  199. subtree:add(f_a, (data >> 6 ) & 0x01) -- CubeSense1 Runtime Error
  200. subtree:add(f_b, (data >> 7) & 0x01) -- CubeSense2 Runtime Error
  201. offset=offset+1
  202. data = buffer(offset, 1):le_uint()
  203. subtree:add(f_cubesense1_runtime_error, (data >> 0) & 0x01) -- CubeSense1 Runtime Error
  204. subtree:add(f_cubesense2_runtime_error, (data >> 1) & 0x01) -- CubeSense2 Runtime Error
  205. subtree:add(f_cubecontrol_signal_runtime_error, (data >> 2) & 0x01) -- CubeControl Signal Runtime Error
  206. subtree:add(f_cubecontrol_motor_runtime_error, (data >> 3) & 0x01) -- CubeControl Motor Runtime Error
  207. subtree:add(f_cubewheel1_runtime_error,(data >> 4) & 0x01) -- CubeWheel1 Runtime Error
  208. subtree:add(f_cubewheel2_runtime_error, (data >> 5) & 0x01) -- CubeWheel2 Runtime Error
  209. subtree:add(f_cubewheel3_runtime_error, (data >> 6) & 0x01) -- CubeWheel3 Runtime Error
  210. subtree:add(f_cubestar_runtime_error, (data >> 7) & 0x01) -- CubeStar Runtime Error
  211. offset=offset+1
  212. data = buffer(offset, 1):le_uint()
  213. -- Magnetometer and sensor errors
  214. subtree:add(f_magnetometer_error, (data >> 0) & 0x01) -- Magnetometer Error
  215. subtree:add(f_rate_sensor_failure, (data >> 1) & 0x01) -- Rate Sensor Failure
  216. offset = offset + 1
  217. elseif data == -1 then
  218. subtree:add(" ADCS operation failure ")
  219. elseif data == -2 then
  220. subtree:add(" TC TM error ")
  221. elseif data == -3 then
  222. subtree:add(" Interface error ")
  223. elseif data == -4 then
  224. subtree:add(" Id not support ")
  225. elseif data == -5 then
  226. subtree:add(" ADCS HW in invalid power state ")
  227. elseif data == -6 then
  228. subtree:add(" ADCS Semaphore take failure ")
  229. elseif data == -6 then
  230. subtree:add(" ADCS Operating Mode Mismatch error ")
  231. elseif data == -6 then
  232. subtree:add(" ADCS responded data is not in a valid range ")
  233. end
  234. end