AP_HAL_Linux: PCA9685: Check for device before accessing it
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
This commit is contained in:
parent
5f34ec6578
commit
29fadc2417
@ -96,7 +96,7 @@ void RCOutput_PCA9685::init()
|
|||||||
|
|
||||||
void RCOutput_PCA9685::reset_all_channels()
|
void RCOutput_PCA9685::reset_all_channels()
|
||||||
{
|
{
|
||||||
if (!_dev->get_semaphore()->take(10)) {
|
if (!_dev || !_dev->get_semaphore()->take(10)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ void RCOutput_PCA9685::set_freq(uint32_t chmask, uint16_t freq_hz)
|
|||||||
write(i, _pulses_buffer[i]);
|
write(i, _pulses_buffer[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_dev->get_semaphore()->take(10)) {
|
if (!_dev || !_dev->get_semaphore()->take(10)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,7 +225,7 @@ void RCOutput_PCA9685::push()
|
|||||||
*d++ = length >> 8;
|
*d++ = length >> 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_dev->get_semaphore()->take_nonblocking()) {
|
if (!_dev || !_dev->get_semaphore()->take_nonblocking()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user