function tm_get_adcs_state(buffer, pinfo, tree, adcs_protocol, offset) local f_operation_status = ProtoField.uint8("adcs_protocol.operation_status", "Operation Status", base.HEX) local f_epoch_time = ProtoField.uint32("adcs_protocol.epoch_time", "Epoch Time", base.DEC) local f_attitude_estimation_mode = ProtoField.uint8("adcs_protocol.attitude_estimation_mode", "Attitude Estimation Mode", base.DEC) local f_control_mode = ProtoField.uint8("adcs_protocol.control_mode", "Control Mode", base.DEC) local f_adcs_run_mode = ProtoField.uint8("adcs_protocol.adcs_run_mode", "ADCS Run Mode", base.DEC) local f_asgp4_mode = ProtoField.uint8("adcs_protocol.asgp4_mode", "ASGP4 Mode", base.DEC) -- Define boolean fields for enabled flags local f_cube_control_signal_enabled = ProtoField.bool("adcs_protocol.cube_control_signal_enabled", "Cube Control Signal Enabled") local f_cube_control_motor_enabled = ProtoField.bool("adcs_protocol.cube_control_motor_enabled", "Cube Control Motor Enabled") local f_cubesense1_enabled = ProtoField.bool("adcs_protocol.cubesense1_enabled", "Cubesense1 Enabled") local f_cubesense2_enabled = ProtoField.bool("adcs_protocol.cubesense2_enabled", "Cubesense2 Enabled") local f_cube_wheel1_enabled = ProtoField.bool("adcs_protocol.cube_wheel1_enabled", "Cube Wheel 1 Enabled") local f_cube_wheel2_enabled = ProtoField.bool("adcs_protocol.cube_wheel2_enabled", "Cube Wheel 2 Enabled") local f_cube_wheel3_enabled = ProtoField.bool("adcs_protocol.cube_wheel3_enabled", "Cube Wheel 3 Enabled") local f_cube_star_enabled = ProtoField.bool("adcs_protocol.cube_star_enabled", "Cube Star Enabled") local f_gps_receiver_enabled = ProtoField.bool("adcs_protocol.gps_receiver_enabled", "GPS Receiver Enabled") local f_gps_lna_power_enabled = ProtoField.bool("adcs_protocol.gps_lna_power_enabled", "GPS LNA Power Enabled") local f_motor_driver_enabled = ProtoField.bool("adcs_protocol.motor_driver_enabled", "Motor Driver Enabled") local f_sun_is_above_local_horizon = ProtoField.bool("adcs_protocol.sun_is_above_local_horizon", "Sun is Above Local Horizon") -- Communication error fields local f_cubesense1_comm_error = ProtoField.bool("adcs_protocol.cubesense1_comm_error", "Cubesense1 Communications Error") local f_cubesense2_comm_error = ProtoField.bool("adcs_protocol.cubesense2_comm_error", "Cubesense2 Communications Error") local f_cubcontrol_signal_comm_error = ProtoField.bool("adcs_protocol.cubcontrol_signal_comm_error", "CubeControl Signal Communications Error") local f_cubcontrol_motor_comm_error = ProtoField.bool("adcs_protocol.cubcontrol_motor_comm_error", "CubeControl Motor Communications Error") local f_cubewheel1_comm_error = ProtoField.bool("adcs_protocol.cubewheel1_comm_error", "Cube Wheel 1 Communications Error") local f_cubewheel2_comm_error = ProtoField.bool("adcs_protocol.cubewheel2_comm_error", "Cube Wheel 2 Communications Error") local f_cubewheel3_comm_error = ProtoField.bool("adcs_protocol.cubewheel2_comm_error", "Cube Wheel 3 Communications Error") local f_cubestar_comm_error = ProtoField.bool("adcs_protocol.cubewheel2_comm_error", "Cube star communications Error") local f_magnetometer_range_error = ProtoField.bool("adcs_protocol.magnetometer_range_error", "Magnetometer Range Error") local f_cam1_sram_overcurrent = ProtoField.bool("adcs_protocol.cam1_sram_overcurrent", "Cam1 SRAM Overcurrent Detected") local f_cam1_3v3_overcurrent = ProtoField.bool("adcs_protocol.cam1_3v3_overcurrent", "Cam1 3v3 Overcurrent Detected") local f_cam1_sensor_busy = ProtoField.bool("adcs_protocol.cam1_sensor_busy", "Cam1 Sensor Busy Error") local f_cam1_sensor_detection_error = ProtoField.bool("adcs_protocol.cam1_sensor_detection_error", "Cam1 Sensor Detection Error") local f_sun_sensor_range_error = ProtoField.bool("adcs_protocol.sun_sensor_range_error", "Sun Sensor Range Error") local f_cam2_sram_overcurrent = ProtoField.bool("adcs_protocol.cam2_sram_overcurrent", "Cam2 SRAM Overcurrent Detected") local f_cam2_3v3_overcurrent = ProtoField.bool("adcs_protocol.cam2_3v3_overcurrent", "Cam2 3v3 Overcurrent Detected") local f_cam2_sensor_busy = ProtoField.bool("adcs_protocol.cam2_sensor_busy", "Cam2 Sensor Busy Error") local f_cam2_sensor_detection_error = ProtoField.bool("adcs_protocol.cam2_sensor_detection_error", "Cam2 Sensor Detection Error") local f_nadir_sensor_range_error = ProtoField.bool("adcs_protocol.nadir_sensor_range_error", "Nadir Sensor Range Error") local f_rate_sensor_range_error = ProtoField.bool("adcs_protocol.rate_sensor_range_error", "Rate Sensor Range Error") local f_wheel_speed_range_error = ProtoField.bool("adcs_protocol.wheel_speed_range_error", "Wheel Speed Range Error") local f_coarse_sun_sensor_error = ProtoField.bool("adcs_protocol.coarse_sun_sensor_error", "Coarse Sun Sensor Error") local f_star_tracker_match_error = ProtoField.bool("adcs_protocol.star_tracker_match_error", "Star Tracker Match Error") local f_star_tracker_overcurrent = ProtoField.bool("adcs_protocol.star_tracker_overcurrent", "Star Tracker Overcurrent Detected") local f_orbit_parameters_invalid = ProtoField.bool("adcs_protocol.orbit_parameters_invalid", "Orbit Parameters are Invalid") local f_configuration_invalid = ProtoField.bool("adcs_protocol.configuration_invalid", "Configuration is Invalid") local f_control_mode_change_not_allowed = ProtoField.bool("adcs_protocol.control_mode_change_not_allowed", "Control Mode Change is not allowed") local f_estimator_change_not_allowed = ProtoField.bool("adcs_protocol.estimator_change_not_allowed", "Estimator Change is not allowed") -- Define Magnetometer Sampling Mode field (2 bytes) local f_magnetometer_sampling_mode = ProtoField.uint8("adcs_protocol.magnetometer_sampling_mode", "Magnetometer Sampling Mode", base.DEC) -- Define runtime error fields local f_cubesense1_runtime_error = ProtoField.bool("adcs_protocol.cubesense1_runtime_error", "CubeSense1 Runtime Error") local f_cubesense2_runtime_error = ProtoField.bool("adcs_protocol.cubesense2_runtime_error", "CubeSense2 Runtime Error") local f_cubecontrol_signal_runtime_error = ProtoField.bool("adcs_protocol.cubecontrol_signal_runtime_error", "CubeControl Signal Runtime Error") local f_cubecontrol_motor_runtime_error = ProtoField.bool("adcs_protocol.cubecontrol_motor_runtime_error", "CubeControl Motor Runtime Error") local f_cubewheel1_runtime_error = ProtoField.bool("adcs_protocol.cubewheel1_runtime_error", "CubeWheel1 Runtime Error") local f_a = ProtoField.bool("adcs_protocol.cubewheel1_runtime_error", "CubeWheel1 Runtime Error") local f_b = ProtoField.bool("adcs_protocol.cubewheel1_runtime_error", "CubeWheel1 Runtime Error") local f_cubewheel2_runtime_error = ProtoField.bool("adcs_protocol.cubewheel2_runtime_error", "CubeWheel2 Runtime Error") local f_cubewheel3_runtime_error = ProtoField.bool("adcs_protocol.cubewheel3_runtime_error", "CubeWheel3 Runtime Error") local f_cubestar_runtime_error = ProtoField.bool("adcs_protocol.cubestar_runtime_error", "CubeStar Runtime Error") local f_magnetometer_error = ProtoField.bool("adcs_protocol.magnetometer_error", "Magnetometer Error") local f_rate_sensor_failure = ProtoField.bool("adcs_protocol.rate_sensor_failure", "Rate Sensor Failure") -- Add all fields to the protocol adcs_protocol.fields = { f_operation_status, f_epoch_time, f_attitude_estimation_mode, f_control_mode, f_adcs_run_mode, f_asgp4_mode, f_cube_control_signal_enabled, f_cube_control_motor_enabled, f_cubesense1_enabled, f_cubesense2_enabled, f_cube_wheel1_enabled, f_cube_wheel2_enabled, f_cube_wheel3_enabled, f_cube_star_enabled, f_gps_receiver_enabled, f_gps_lna_power_enabled, f_motor_driver_enabled, f_sun_is_above_local_horizon, f_cubesense1_comm_error, f_cubesense2_comm_error, f_cubcontrol_signal_comm_error, f_cubcontrol_motor_comm_error, f_cubewheel1_comm_error, f_cubewheel2_comm_error, f_cubewheel3_comm_error, f_cubestar_comm_error, f_magnetometer_range_error, f_cam1_sram_overcurrent, f_cam1_3v3_overcurrent, f_cam1_sensor_busy, f_cam1_sensor_detection_error, f_sun_sensor_range_error, f_cam2_sram_overcurrent, f_cam2_3v3_overcurrent, f_cam2_sensor_busy, f_cam2_sensor_detection_error, f_nadir_sensor_range_error, f_rate_sensor_range_error, f_wheel_speed_range_error, f_coarse_sun_sensor_error, f_star_tracker_match_error, f_star_tracker_overcurrent, f_orbit_parameters_invalid, f_a, f_b, f_configuration_invalid, f_control_mode_change_not_allowed, f_estimator_change_not_allowed, f_magnetometer_sampling_mode, f_cubesense1_runtime_error, f_cubesense2_runtime_error, f_cubecontrol_signal_runtime_error, f_cubecontrol_motor_runtime_error, f_cubewheel1_runtime_error, f_cubewheel2_runtime_error, f_cubewheel3_runtime_error, f_cubestar_runtime_error, f_magnetometer_error, f_rate_sensor_failure } local subtree = tree:add(adcs_protocol, buffer(), "TM GET ADCS CURRENT STATE") offset = offset + 3 local data = buffer(offset,1):le_int() offset = offset + 1 if data == 0 then -- Parse Attitude Estimation Mode (8 bits) subtree:add(f_attitude_estimation_mode, buffer(offset, 1):le_uint()) offset = offset + 1 -- Parse Control Mode (8 bits) subtree:add(f_control_mode, buffer(offset, 1):le_uint()) offset = offset + 1 -- Parse ADCS Run Mode (2 bits / 2 bytes) local a=buffer(offset, 1):le_uint() subtree:add(f_adcs_run_mode, a & 0x03) -- Parse ASGP4 Mode (2 bits / 2 bytes) subtree:add(f_asgp4_mode, (a >> 2) & 0x03) subtree:add(f_cube_control_signal_enabled, (a >> 4) & 0x01) subtree:add(f_cube_control_motor_enabled,(a >> 5) & 0x01 ) subtree:add(f_cubesense1_enabled,(a >> 6) & 0x01 ) subtree:add(f_cubesense2_enabled,(a >> 7) & 0x01 ) offset = offset + 1 -- Parse CubeWheel Enabled Flags a=buffer(offset, 1):le_uint() subtree:add(f_cube_wheel1_enabled, (a >> 0) & 0x01) subtree:add(f_cube_wheel2_enabled, (a >> 1) & 0x01) subtree:add(f_cube_wheel3_enabled, (a >> 2) & 0x01) subtree:add(f_cube_star_enabled, (a >> 3) & 0x01) subtree:add(f_gps_receiver_enabled, (a >> 4) & 0x01) subtree:add(f_gps_lna_power_enabled, (a >> 5) & 0x01) -- GPS LNA Power Enabled subtree:add(f_motor_driver_enabled, (a >> 6) & 0x01) -- Motor Driver Enabled subtree:add(f_sun_is_above_local_horizon, (a >> 7) & 0x01) -- Sun is Above Local Horizon offset = offset + 1 a = buffer(offset, 1):le_uint() -- Communication error flags subtree:add(f_cubesense1_comm_error, (a >> 0) & 0x01) -- Cubesense1 Communications Error subtree:add(f_cubesense2_comm_error, (a >> 1) & 0x01) -- Cubesense2 Communications Error subtree:add(f_cubcontrol_signal_comm_error, (a >> 2) & 0x01) -- CubeControl Signal Communications Error subtree:add(f_cubcontrol_motor_comm_error, (a >> 3) & 0x01) -- CubeControl Motor Communications Error subtree:add(f_cubewheel1_comm_error, (a >> 4) & 0x01) -- Cube Wheel1 Communications Error subtree:add(f_cubewheel2_comm_error, (a >> 5) & 0x01) -- Cube Wheel2 Communications Error subtree:add(f_cubewheel3_comm_error, (a >> 6) & 0x01) subtree:add(f_cubestar_comm_error, (a >> 7) & 0x01) offset = offset + 1 a=buffer(offset, 1):le_uint() subtree:add(f_magnetometer_range_error, (a >> 0) & 0x01) -- Magnetometer Range Error subtree:add(f_cam1_sram_overcurrent, (a >> 1) & 0x01) -- Cam1 SRAM Overcurrent Detected subtree:add(f_cam1_3v3_overcurrent, (a >> 2) & 0x01) -- Cam1 3v3 Overcurrent Detected subtree:add(f_cam1_sensor_busy, (a >> 3) & 0x01) -- Cam1 Sensor Busy Error subtree:add(f_cam1_sensor_detection_error, (a >> 4) & 0x01 ) -- Cam1 Sensor Detection Error subtree:add(f_sun_sensor_range_error, (a >> 5) & 0x01) -- Sun Sensor Range Error subtree:add(f_cam2_sram_overcurrent, (a >> 6) & 0x01) -- Cam2 SRAM Overcurrent Detected subtree:add(f_cam2_3v3_overcurrent, (a >> 7) & 0x01) -- Cam2 3v3 Overcurrent Detected offset=offset+1 local data=buffer(offset, 1):le_uint() subtree:add(f_cam2_sensor_busy, (data >> 0) & 0x01) -- Cam2 Sensor Busy Error subtree:add(f_cam2_sensor_detection_error, (data >> 1) & 0x01) -- Cam2 Sensor Detection Error subtree:add(f_nadir_sensor_range_error, (data >> 2) & 0x01) -- Nadir Sensor Range Error subtree:add(f_rate_sensor_range_error, (data >> 3) & 0x01) -- Rate Sensor Range Error subtree:add(f_wheel_speed_range_error,(data >> 4) & 0x01) -- Wheel Speed Range Error -- Error flags for sensors and system issues subtree:add(f_coarse_sun_sensor_error,(data >> 5) & 0x01) -- Coarse Sun Sensor Error subtree:add(f_star_tracker_match_error, (data >> 6) & 0x01) -- Star Tracker Match Error subtree:add(f_star_tracker_overcurrent, (data >> 7) & 0x01) -- Star Tracker Overcurrent Detected offset = offset + 1 data = buffer(offset, 1):le_uint() subtree:add(f_orbit_parameters_invalid, (data >> 0) & 0x01) -- Orbit Parameters are Invalid subtree:add(f_configuration_invalid,(data >> 1) & 0x01) -- Configuration is Invalid subtree:add(f_control_mode_change_not_allowed, (data >> 2) & 0x01) -- Control Mode Change is Not Allowed subtree:add(f_estimator_change_not_allowed, (data >> 3) & 0x01) -- Estimator Change is Not Allowed -- Magnetometer Sampling Mode (2 bits) subtree:add(f_magnetometer_sampling_mode, (data >> 4) & 0x03) -- Current Magnetometer Sampling Mode -- Runtime error flags for sensors and systems subtree:add(f_a, (data >> 6 ) & 0x01) -- CubeSense1 Runtime Error subtree:add(f_b, (data >> 7) & 0x01) -- CubeSense2 Runtime Error offset=offset+1 data = buffer(offset, 1):le_uint() subtree:add(f_cubesense1_runtime_error, (data >> 0) & 0x01) -- CubeSense1 Runtime Error subtree:add(f_cubesense2_runtime_error, (data >> 1) & 0x01) -- CubeSense2 Runtime Error subtree:add(f_cubecontrol_signal_runtime_error, (data >> 2) & 0x01) -- CubeControl Signal Runtime Error subtree:add(f_cubecontrol_motor_runtime_error, (data >> 3) & 0x01) -- CubeControl Motor Runtime Error subtree:add(f_cubewheel1_runtime_error,(data >> 4) & 0x01) -- CubeWheel1 Runtime Error subtree:add(f_cubewheel2_runtime_error, (data >> 5) & 0x01) -- CubeWheel2 Runtime Error subtree:add(f_cubewheel3_runtime_error, (data >> 6) & 0x01) -- CubeWheel3 Runtime Error subtree:add(f_cubestar_runtime_error, (data >> 7) & 0x01) -- CubeStar Runtime Error offset=offset+1 data = buffer(offset, 1):le_uint() -- Magnetometer and sensor errors subtree:add(f_magnetometer_error, (data >> 0) & 0x01) -- Magnetometer Error subtree:add(f_rate_sensor_failure, (data >> 1) & 0x01) -- Rate Sensor Failure offset = offset + 1 elseif data == -1 then subtree:add(" ADCS operation failure ") elseif data == -2 then subtree:add(" TC TM error ") elseif data == -3 then subtree:add(" Interface error ") elseif data == -4 then subtree:add(" Id not support ") elseif data == -5 then subtree:add(" ADCS HW in invalid power state ") elseif data == -6 then subtree:add(" ADCS Semaphore take failure ") elseif data == -6 then subtree:add(" ADCS Operating Mode Mismatch error ") elseif data == -6 then subtree:add(" ADCS responded data is not in a valid range ") end end