fix linux_pwm_out: return correct value for PCA9685::init()

This commit is contained in:
Beat Küng
2017-08-23 08:10:16 +02:00
committed by Lorenz Meier
parent 7a409cf843
commit 575e7be540
2 changed files with 2 additions and 8 deletions
+1 -1
View File
@@ -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;
+1 -7
View File
@@ -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;