Skip to content

Commit

Permalink
HAL_PX4: make usb_connected() more robust
Browse files Browse the repository at this point in the history
thanks to a suggestion from Phillip Kocmoud, this should fix issues
with the XUAV-X2
  • Loading branch information
tridge committed Jul 8, 2015
1 parent 2f8a7f3 commit f4a9f98
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion libraries/AP_HAL_PX4/GPIO.cpp
Expand Up @@ -242,7 +242,13 @@ bool PX4GPIO::attach_interrupt(uint8_t interrupt_num, AP_HAL::Proc p, uint8_t mo
*/
bool PX4GPIO::usb_connected(void)
{
return stm32_gpioread(GPIO_OTGFS_VBUS);
struct stat st;
/*
we use a combination of voltage on the USB connector and the
existance of the /dev/ttyACM0 character device. This copes with
systems where the VBUS may go high even with no USB connected
*/
return stm32_gpioread(GPIO_OTGFS_VBUS) && stat("/dev/ttyACM0", &st) == 0;
}


Expand Down

0 comments on commit f4a9f98

Please sign in to comment.