forked from Archive/PX4-Autopilot
Fix detection of USB connected state. Needs bench test without USB
This commit is contained in:
parent
0a33ef4e33
commit
64cdcfc0cc
|
@ -112,6 +112,7 @@ bool condition_airspeed_valid # set to true by the commander app if there is a
|
|||
bool condition_landed # true if vehicle is landed, always true if disarmed
|
||||
bool condition_power_input_valid # set if input power is valid
|
||||
float32 avionics_power_rail_voltage # voltage of the avionics power rail
|
||||
bool usb_connected # status of the USB power supply
|
||||
|
||||
bool rc_signal_found_once
|
||||
bool rc_signal_lost # true if RC reception lost
|
||||
|
|
|
@ -169,8 +169,6 @@ static bool _param_autosave = false;
|
|||
static unsigned int leds_counter;
|
||||
/* To remember when last notification was sent */
|
||||
static uint64_t last_print_mode_reject_time = 0;
|
||||
/* if connected via USB */
|
||||
static bool on_usb_power = false;
|
||||
|
||||
static float takeoff_alt = 5.0f;
|
||||
static int parachute_enabled = 0;
|
||||
|
@ -380,8 +378,8 @@ void usage(const char *reason)
|
|||
|
||||
void print_status()
|
||||
{
|
||||
warnx("type: %s", (status.is_rotary_wing) ? "ROTARY" : "PLANE");
|
||||
warnx("usb powered: %s", (on_usb_power) ? "yes" : "no");
|
||||
warnx("type: %s", (status.is_rotary_wing) ? "symmetric motion" : "forward motion");
|
||||
warnx("usb powered: %s", (status.usb_connected) ? "yes" : "no");
|
||||
warnx("avionics rail: %6.2f V", (double)status.avionics_power_rail_voltage);
|
||||
|
||||
/* read all relevant states */
|
||||
|
@ -911,6 +909,7 @@ int commander_thread_main(int argc, char *argv[])
|
|||
|
||||
status.condition_power_input_valid = true;
|
||||
status.avionics_power_rail_voltage = -1.0f;
|
||||
status.usb_connected = false;
|
||||
|
||||
// CIRCUIT BREAKERS
|
||||
status.circuit_breaker_engaged_power_check = false;
|
||||
|
@ -1334,6 +1333,7 @@ int commander_thread_main(int argc, char *argv[])
|
|||
|
||||
/* copy avionics voltage */
|
||||
status.avionics_power_rail_voltage = system_power.voltage5V_v;
|
||||
status.usb_connected = system_power.usb_connected;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1537,10 +1537,6 @@ int commander_thread_main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
last_idle_time = system_load.tasks[0].total_runtime;
|
||||
|
||||
/* check if board is connected via USB */
|
||||
struct stat statbuf;
|
||||
on_usb_power = (stat("/dev/ttyACM0", &statbuf) == 0);
|
||||
}
|
||||
|
||||
/* if battery voltage is getting lower, warn using buzzer, etc. */
|
||||
|
@ -1550,7 +1546,7 @@ int commander_thread_main(int argc, char *argv[])
|
|||
status.battery_warning = vehicle_status_s::VEHICLE_BATTERY_WARNING_LOW;
|
||||
status_changed = true;
|
||||
|
||||
} else if (!on_usb_power && status.condition_battery_voltage_valid && status.battery_remaining < 0.09f
|
||||
} else if (!status.usb_connected && status.condition_battery_voltage_valid && status.battery_remaining < 0.09f
|
||||
&& !critical_battery_voltage_actions_done && low_battery_voltage_actions_done) {
|
||||
/* critical battery voltage, this is rather an emergency, change state machine */
|
||||
critical_battery_voltage_actions_done = true;
|
||||
|
|
Loading…
Reference in New Issue