AP_HAL_Linux: PCA9685: Check for device before accessing it

Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
This commit is contained in:
Patrick José Pereira 2019-09-25 11:34:56 -03:00 committed by Andrew Tridgell
parent 30c86eb768
commit 6c734b5006

View File

@ -96,7 +96,7 @@ void RCOutput_PCA9685::init()
void RCOutput_PCA9685::reset_all_channels()
{
if (!_dev->get_semaphore()->take(10)) {
if (!_dev || !_dev->get_semaphore()->take(10)) {
return;
}
@ -117,7 +117,7 @@ void RCOutput_PCA9685::set_freq(uint32_t chmask, uint16_t freq_hz)
write(i, _pulses_buffer[i]);
}
if (!_dev->get_semaphore()->take(10)) {
if (!_dev || !_dev->get_semaphore()->take(10)) {
return;
}
@ -225,7 +225,7 @@ void RCOutput_PCA9685::push()
*d++ = length >> 8;
}
if (!_dev->get_semaphore()->take_nonblocking()) {
if (!_dev || !_dev->get_semaphore()->take_nonblocking()) {
return;
}