diff --git a/sw/airborne/firmwares/fixedwing/fixedwing_datalink.c b/sw/airborne/firmwares/fixedwing/fixedwing_datalink.c index 06f4e85df5..d111a660fc 100644 --- a/sw/airborne/firmwares/fixedwing/fixedwing_datalink.c +++ b/sw/airborne/firmwares/fixedwing/fixedwing_datalink.c @@ -78,22 +78,22 @@ void firmware_parse_msg(void) case DL_MOVE_WP: { if (DL_MOVE_WP_ac_id(dl_buffer) != AC_ID) { break; } uint8_t wp_id = DL_MOVE_WP_wp_id(dl_buffer); - float a = MOfMM(DL_MOVE_WP_alt(dl_buffer)); /* Computes from (lat, long) in the referenced UTM zone */ struct LlaCoor_f lla; lla.lat = RadOfDeg((float)(DL_MOVE_WP_lat(dl_buffer) / 1e7)); lla.lon = RadOfDeg((float)(DL_MOVE_WP_lon(dl_buffer) / 1e7)); + lla.alt = MOfMM(DL_MOVE_WP_alt(dl_buffer)); struct UtmCoor_f utm; utm.zone = nav_utm_zone0; utm_of_lla_f(&utm, &lla); - nav_move_waypoint(wp_id, utm.east, utm.north, a); + nav_move_waypoint(wp_id, utm.east, utm.north, utm.alt); /* Waypoint range is limited. Computes the UTM pos back from the relative coordinates */ utm.east = waypoints[wp_id].x + nav_utm_east0; utm.north = waypoints[wp_id].y + nav_utm_north0; - DOWNLINK_SEND_WP_MOVED(DefaultChannel, DefaultDevice, &wp_id, &utm.east, &utm.north, &a, &nav_utm_zone0); + DOWNLINK_SEND_WP_MOVED(DefaultChannel, DefaultDevice, &wp_id, &utm.east, &utm.north, &utm.alt, &nav_utm_zone0); } break; #endif /** NAV */ diff --git a/sw/airborne/firmwares/fixedwing/nav.c b/sw/airborne/firmwares/fixedwing/nav.c index d87d40a634..6d74d66c79 100644 --- a/sw/airborne/firmwares/fixedwing/nav.c +++ b/sw/airborne/firmwares/fixedwing/nav.c @@ -252,7 +252,6 @@ bool nav_compute_final_from_glide(uint8_t wp_af, uint8_t wp_td, float glide) waypoints[wp_af].x = waypoints[wp_td].x + x_1 * h_0 * glide; waypoints[wp_af].y = waypoints[wp_td].y + y_1 * h_0 * glide; - waypoints[wp_af].a = waypoints[wp_af].a; return false; } diff --git a/sw/airborne/modules/computer_vision/video_thread_nps.c b/sw/airborne/modules/computer_vision/video_thread_nps.c index c9049f02ab..f1111e0d7d 100644 --- a/sw/airborne/modules/computer_vision/video_thread_nps.c +++ b/sw/airborne/modules/computer_vision/video_thread_nps.c @@ -66,7 +66,10 @@ void video_thread_periodic(void) video_thread.is_running = ! video_thread.is_running; #endif - cv_run_device(NULL,&img); + // Calling this function will not work because video_config_t is NULL (?) and img + // has no timestamp + // Commenting out for now + // cv_run_device(NULL,&img); image_free(&img); } diff --git a/sw/airborne/modules/datalink/mavlink.c b/sw/airborne/modules/datalink/mavlink.c index 457816897b..550d8f72fc 100644 --- a/sw/airborne/modules/datalink/mavlink.c +++ b/sw/airborne/modules/datalink/mavlink.c @@ -265,14 +265,16 @@ void mavlink_common_message_handler(const mavlink_message_t *msg) cmd.param_index = settings_idx_from_param_id(cmd.param_id); } - mavlink_msg_param_value_send(MAVLINK_COMM_0, - mavlink_param_names[cmd.param_index], - settings_get_value(cmd.param_index), - MAV_PARAM_TYPE_REAL32, - NB_SETTING, - cmd.param_index); - MAVLinkSendMessage(); - + // Send message only if the param_index was found (Coverity Scan) + if (cmd.param_index > -1) { + mavlink_msg_param_value_send(MAVLINK_COMM_0, + mavlink_param_names[cmd.param_index], + settings_get_value(cmd.param_index), + MAV_PARAM_TYPE_REAL32, + NB_SETTING, + cmd.param_index); + MAVLinkSendMessage(); + } break; } diff --git a/sw/airborne/modules/nav/nav_smooth.c b/sw/airborne/modules/nav/nav_smooth.c index 33fd8a371c..297b18769c 100644 --- a/sw/airborne/modules/nav/nav_smooth.c +++ b/sw/airborne/modules/nav/nav_smooth.c @@ -160,22 +160,22 @@ static inline float ground_speed_of_course(float x) /* Compute the ground speed for courses 0, 360/NB_ANGLES, ... (NB_ANGLES-1)360/NB_ANGLES */ static void compute_ground_speed(float airspeed, - float wind_x, - float wind_y) + float wind_east, + float wind_north) { uint8_t i; float alpha = 0; - float c = wind_x * wind_x + wind_y * wind_y - airspeed * airspeed; + float c = wind_north * wind_north + wind_east * wind_east - airspeed * airspeed; for (i = 0; i < NB_ANGLES; i++, alpha += ANGLE_STEP) { /* g^2 -2 scal g + c = 0 */ - float scal = wind_x * cos(alpha) + wind_y * sin(alpha); + float scal = wind_north * cos(alpha) + wind_east * sin(alpha); float delta = 4 * (scal * scal - c); ground_speeds[i] = scal + sqrt(delta) / 2.; Bound(ground_speeds[i], NOMINAL_AIRSPEED / 4, 2 * NOMINAL_AIRSPEED); } } -/* Adjusting a circle around CA, tangent in A, to end at snav_desired_tow */ +/* Adjusting a circle around CA, tangent in A, to end at snav_desired_tow */ bool snav_on_time(float nominal_radius) { nominal_radius = fabs(nominal_radius); diff --git a/sw/airborne/modules/nav/nav_survey_poly_osam.c b/sw/airborne/modules/nav/nav_survey_poly_osam.c index 3f00016996..c460e7d08c 100644 --- a/sw/airborne/modules/nav/nav_survey_poly_osam.c +++ b/sw/airborne/modules/nav/nav_survey_poly_osam.c @@ -289,7 +289,6 @@ bool nav_survey_poly_osam_setup(uint8_t EntryWP, uint8_t Size, float sw, float O EntryRadius = -EntryRadius; dSweep = -sw; } else { - EntryRadius = EntryRadius; dSweep = sw; } diff --git a/sw/logalizer/sdlogger_download.c b/sw/logalizer/sdlogger_download.c index 8640154190..4485406505 100644 --- a/sw/logalizer/sdlogger_download.c +++ b/sw/logalizer/sdlogger_download.c @@ -588,8 +588,22 @@ int main ( int argc, char** argv) /* Obtain sd2log directory */ char *pprz_home; pprz_home = getenv( "PAPARAZZI_HOME" ); - strcat(sd2log, pprz_home); - strcat(sd2log, "/sw/logalizer/sd2log temp.tlm"); + + char *sd2log_home = "/sw/logalizer/sd2log temp.tlm"; + + // check if the pprz_home path fits into the sd2log buffer + if (strlen(pprz_home) < (sizeof(sd2log) - strlen(sd2log_home))) { + strcat(sd2log, pprz_home); + strcat(sd2log, sd2log_home); + } + else { + // pprz_home path too long for the buffer + // exit to prevent buffer overflow + printf("PPRZ_HOME path too long for the buffer, exiting...\n"); + exit(-1); + } + + /* Get the setting ID with a python script */ /* TODO: would be nicer to have a C xml parser */ diff --git a/sw/simulator/nps/nps_fdm_jsbsim.cpp b/sw/simulator/nps/nps_fdm_jsbsim.cpp index 1aba9abc54..4d89830d60 100644 --- a/sw/simulator/nps/nps_fdm_jsbsim.cpp +++ b/sw/simulator/nps/nps_fdm_jsbsim.cpp @@ -506,10 +506,24 @@ static void init_jsbsim(double dt) char buf[1024]; string rootdir; + string jsbsim_home = "/conf/simulator/jsbsim/"; string jsbsim_ic_name; - sprintf(buf, "%s/conf/simulator/jsbsim/", getenv("PAPARAZZI_HOME")); - rootdir = string(buf); + char* pprz_home = getenv("PAPARAZZI_HOME"); + + int cnt = -1; + if (strlen(pprz_home) < sizeof(buf)) { + cnt = snprintf(buf, strlen(pprz_home) + 1, "%s", pprz_home); + rootdir = string(buf) + jsbsim_home; + } + + // check the results + if (cnt < 0){ + // Either pprz_home path too long for the buffer + // or writing the string was not successful. + cout << "PPRZ_HOME not set correctly, exiting..." << endl; + exit(-1); + } /* if jsbsim initial conditions are defined, use them * otherwise use flightplan location diff --git a/sw/simulator/nps/nps_flightgear.c b/sw/simulator/nps/nps_flightgear.c index 8ed8a25bf4..42dcf7f89b 100644 --- a/sw/simulator/nps/nps_flightgear.c +++ b/sw/simulator/nps/nps_flightgear.c @@ -160,6 +160,7 @@ void nps_flightgear_send() struct FGNetGUI gui; gui.version = FG_NET_GUI_VERSION; + gui.padding1 = 0; // initialize the padding variable to zero gui.latitude = fdm.lla_pos.lat; gui.longitude = fdm.lla_pos.lon; diff --git a/sw/simulator/nps/nps_radio_control_spektrum.c b/sw/simulator/nps/nps_radio_control_spektrum.c index 16cfc0dfab..d065a8a1fe 100644 --- a/sw/simulator/nps/nps_radio_control_spektrum.c +++ b/sw/simulator/nps/nps_radio_control_spektrum.c @@ -33,6 +33,7 @@ int nps_radio_control_spektrum_init(const char *device) return -1; } struct termios termios; + termios.c_iflag = 0; // properly initialize variable /* input modes */ termios.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | INPCK | ISTRIP | INLCR | IGNCR | ICRNL | IUCLC | IXON | IXANY | IXOFF | IMAXBEL);