mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-03 17:18:52 +08:00
fix linux_pwm_out: return correct value for PCA9685::init()
This commit is contained in:
@@ -82,7 +82,7 @@ public:
|
||||
*/
|
||||
PCA9685(int bus, int address);
|
||||
|
||||
int init() override { return _fd >= 0; }
|
||||
int init() override { return _fd >= 0 ? 0 : -1; }
|
||||
|
||||
int send_output_pwm(const uint16_t *pwm, int num_outputs) override;
|
||||
|
||||
|
||||
@@ -217,13 +217,7 @@ void task_main(int argc, char *argv[])
|
||||
pwm_out = new NavioSysfsPWMOut(_device, _max_num_outputs);
|
||||
}
|
||||
|
||||
/**
|
||||
* if the _protocol is "pca9685" and the driver is executed correctly,
|
||||
* the return value of "pwm_out->init()" will be higher than 0.
|
||||
*/
|
||||
bool check_pwm_device = (strcmp(_protocol, "pca9685") == 0) ? (0 > pwm_out->init()) : (pwm_out->init() != 0);
|
||||
|
||||
if (check_pwm_device) {
|
||||
if (pwm_out->init() != 0) {
|
||||
PX4_ERR("PWM output init failed");
|
||||
delete pwm_out;
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user