36 #include "rosflight.h" 51 strcpy(newest_msg.
msg, msg);
187 if (target_system ==
sysid_)
198 if (target_system ==
sysid_)
209 if (target_system ==
sysid_)
222 if (target_system ==
sysid_)
236 bool reboot_flag =
false;
237 bool reboot_to_bootloader_flag =
false;
277 reboot_to_bootloader_flag =
true;
287 if (reboot_flag || reboot_to_bootloader_flag)
319 switch (control.
mode)
350 for (
int i = 0;
i < 14;
i++)
434 uint8_t control_mode = 0;
610 period_us_(period_us),
612 send_function_(send_function)
632 period_us_ = (rate_hz == 0) ? 0 : 1000000 / rate_hz;
virtual void send_diff_pressure(uint8_t system_id, float velocity, float pressure, float temperature)=0
void send_parameter_list()
void send_output_raw(void)
void set_streaming_rate(uint8_t stream_id, int16_t param_id)
virtual float rc_read(uint8_t channel)=0
const LogMessage & oldest() const
static volatile int16_t gyro[3]
void param_set_float_callback(uint8_t target_system, const char *const param_name, float param_value) override
void send_diff_pressure(void)
float diff_pressure_velocity
void log(CommLinkInterface::LogSeverity severity, const char *fmt,...)
void stream(uint64_t now_us)
LogMessageBuffer log_buffer_
void update_system_id(uint16_t param_id)
uint16_t lookup_param_id(const char name[PARAMS_NAME_LENGTH])
Gets the id of a parameter from its name.
void set_rate(uint32_t rate_hz)
const control_t & combined_control() const
const float * get_outputs() const
bool start_imu_calibration(void)
virtual void send_rc_raw(uint8_t system_id, uint32_t timestamp_ms, const uint16_t channels[8])=0
void timesync_callback(int64_t tc1, int64_t ts1) override
virtual void send_attitude_quaternion(uint8_t system_id, uint64_t timestamp_us, const turbomath::Quaternion &attitude, const turbomath::Vector &angular_velocity)=0
void set_defaults(void)
Set all parameters to default values.
bool read(void)
Read parameter values from non-volatile memory.
static constexpr int LOG_BUF_SIZE
bool set_param_float(uint16_t id, float value)
Sets the value of a floating point parameter by ID and calls the parameter callback.
CommManager(ROSflight &rf, CommLinkInterface &comm_link)
uint32_t get_loop_time_us()
void set_new_aux_command(aux_command_t new_aux_command)
bool offboard_control_active()
void heartbeat_callback() override
void send_named_value_int(const char *const name, int32_t value)
StateManager::BackupData backup_data_buffer_
virtual void send_battery_status(uint8_t system_id, float voltage, float current)=0
bool battery_monitor_present
void send_param_value(uint16_t param_id)
virtual void send_baro(uint8_t system_id, float altitude, float pressure, float temperature)=0
void send_gnss_full(void)
float get_param_float(uint16_t id) const
Get the value of a floating point parameter by id.
const State & state() const
virtual void send_timesync(uint8_t system_id, int64_t tc1, int64_t ts1)=0
static constexpr int LOG_MSG_SIZE
virtual void send_gnss(uint8_t system_id, const GNSSData &data)=0
virtual void init(uint32_t baud_rate, uint32_t dev)=0
bool rc_override_active()
virtual void serial_flush()=0
Stream(uint32_t period_us, std::function< void(void)> send_function)
virtual void send_param_value_float(uint8_t system_id, uint16_t index, const char *const name, float value, uint16_t param_count)=0
virtual void send_heartbeat(uint8_t system_id, bool fixed_wing)=0
void set_external_attitude_update(const turbomath::Quaternion &q)
virtual void board_reset(bool bootloader)=0
virtual void send_log_message(uint8_t system_id, LogSeverity severity, const char *text)=0
static const channelConfig_t channels[CC_CHANNELS_PER_TIMER]
void send_battery_status(void)
param_type_t get_param_type(uint16_t id) const
Get the type of a parameter.
uint32_t last_sent_gnss_tow_
CommLinkInterface & comm_link_
virtual void send_error_data(uint8_t system_id, const StateManager::BackupData &error_data)=0
bool start_gyro_calibration(void)
bool start_baro_calibration(void)
#define GIT_VERSION_STRING
virtual uint64_t clock_micros()=0
const State & state() const
void send_heartbeat(void)
void set_new_offboard_command(control_t new_offboard_command)
void param_change_callback(uint16_t param_id) override
virtual uint16_t num_sensor_errors()=0
void aux_command_callback(const CommLinkInterface::AuxCommand &command) override
virtual void send_version(uint8_t system_id, const char *const version)=0
virtual void clock_delay(uint32_t milliseconds)=0
Stream streams_[STREAM_COUNT]
turbomath::Quaternion attitude
void get_filtered_IMU(turbomath::Vector &accel, turbomath::Vector &gyro, uint64_t &stamp_us)
virtual void send_imu(uint8_t system_id, uint64_t timestamp_us, const turbomath::Vector &accel, const turbomath::Vector &gyro, float temperature)=0
const char * get_param_name(uint16_t id) const
Get the name of a parameter.
virtual void send_named_value_int(uint8_t system_id, uint32_t timestamp_ms, const char *const name, int32_t value)=0
aux_channel_t channel[NUM_TOTAL_OUTPUTS]
void send_backup_data(const StateManager::BackupData &backup_data)
void param_set_int_callback(uint8_t target_system, const char *const param_name, int32_t param_value) override
virtual uint32_t clock_millis()=0
void param_request_list_callback(uint8_t target_system) override
turbomath::Vector angular_velocity
LogMessage buffer_[LOG_BUF_SIZE]
void offboard_control_callback(const CommLinkInterface::OffboardControl &control) override
virtual void send_command_ack(uint8_t system_id, Command command, bool success)=0
void external_attitude_callback(const turbomath::Quaternion &q) override
int get_param_int(uint16_t id) const
Get the value of an integer parameter by id.
bool start_diff_pressure_calibration(void)
virtual void send_output_raw(uint8_t system_id, uint32_t timestamp_ms, const float raw_outputs[14])=0
CommLinkInterface::LogSeverity severity
virtual void send_named_value_float(uint8_t system_id, uint32_t timestamp_ms, const char *const name, float value)=0
void command_callback(CommLinkInterface::Command command) override
StateManager state_manager_
void tfp_sprintf(char *s, const char *fmt, va_list va)
std::function< void(void)> send_function_
virtual void send_status(uint8_t system_id, bool armed, bool failsafe, bool rc_override, bool offboard, uint8_t error_code, uint8_t control_mode, int16_t num_errors, int16_t loop_time_us)=0
void calculate_equilbrium_torque_from_rc()
void param_request_read_callback(uint8_t target_system, const char *const param_name, int16_t param_index) override
virtual void send_gnss_full(uint8_t system_id, const GNSSFull &data)=0
CommandManager command_manager_
uint64_t offboard_control_time_
void send_named_value_float(const char *const name, float value)
virtual void send_param_value_int(uint8_t system_id, uint16_t index, const char *const name, int32_t value, uint16_t param_count)=0
uint8_t send_params_index_
void add_message(CommLinkInterface::LogSeverity severity, char msg[LOG_MSG_SIZE])
bool write(void)
Write current parameter values to non-volatile memory.
const Data & data() const
bool set_param_int(uint16_t id, int32_t value)
Sets the value of a parameter by ID and calls the parameter change callback.
virtual void send_mag(uint8_t system_id, const turbomath::Vector &mag)=0
void send_low_priority(void)
virtual void send_sonar(uint8_t system_id, uint8_t type, float range, float max_range, float min_range)=0
void send_next_param(void)
uint32_t last_sent_gnss_full_tow_