Converted commander to use px4_posix calls

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
Mark Charlebois
2015-04-15 19:38:59 -07:00
parent bba26c3430
commit 694427e4ba
7 changed files with 99 additions and 93 deletions
+20 -19
View File
@@ -42,6 +42,7 @@
*/
#include <px4_defines.h>
#include <px4_posix.h>
#include <stdio.h>
#include <unistd.h>
#include <stdint.h>
@@ -124,10 +125,10 @@ int buzzer_init()
tune_durations[TONE_NOTIFY_NEUTRAL_TUNE] = 500000;
tune_durations[TONE_ARMING_WARNING_TUNE] = 3000000;
buzzer = open(TONEALARM0_DEVICE_PATH, O_WRONLY);
buzzer = px4_open(TONEALARM0_DEVICE_PATH, O_WRONLY);
if (buzzer < 0) {
warnx("Buzzer: open fail\n");
warnx("Buzzer: px4_open fail\n");
return ERROR;
}
@@ -136,12 +137,12 @@ int buzzer_init()
void buzzer_deinit()
{
close(buzzer);
px4_close(buzzer);
}
void set_tune_override(int tune)
{
ioctl(buzzer, TONE_SET_ALARM, tune);
px4_ioctl(buzzer, TONE_SET_ALARM, tune);
}
void set_tune(int tune)
@@ -152,7 +153,7 @@ void set_tune(int tune)
if (tune_end == 0 || new_tune_duration != 0 || hrt_absolute_time() > tune_end) {
/* allow interrupting current non-repeating tune by the same tune */
if (tune != tune_current || new_tune_duration != 0) {
ioctl(buzzer, TONE_SET_ALARM, tune);
px4_ioctl(buzzer, TONE_SET_ALARM, tune);
}
tune_current = tune;
@@ -230,22 +231,22 @@ int led_init()
blink_msg_end = 0;
/* first open normal LEDs */
leds = open(LED0_DEVICE_PATH, 0);
leds = px4_open(LED0_DEVICE_PATH, 0);
if (leds < 0) {
warnx("LED: open fail\n");
warnx("LED: px4_open fail\n");
return ERROR;
}
/* the blue LED is only available on FMUv1 & AeroCore but not FMUv2 */
(void)ioctl(leds, LED_ON, LED_BLUE);
(void)px4_ioctl(leds, LED_ON, LED_BLUE);
/* switch blue off */
led_off(LED_BLUE);
/* we consider the amber led mandatory */
if (ioctl(leds, LED_ON, LED_AMBER)) {
warnx("Amber LED: ioctl fail\n");
if (px4_ioctl(leds, LED_ON, LED_AMBER)) {
warnx("Amber LED: px4_ioctl fail\n");
return ERROR;
}
@@ -253,7 +254,7 @@ int led_init()
led_off(LED_AMBER);
/* then try RGB LEDs, this can fail on FMUv1*/
rgbleds = open(RGBLED0_DEVICE_PATH, 0);
rgbleds = px4_open(RGBLED0_DEVICE_PATH, 0);
if (rgbleds < 0) {
warnx("No RGB LED found at " RGBLED0_DEVICE_PATH);
@@ -265,11 +266,11 @@ int led_init()
void led_deinit()
{
if (leds >= 0) {
close(leds);
px4_close(leds);
}
if (rgbleds >= 0) {
close(rgbleds);
px4_close(rgbleds);
}
}
@@ -278,7 +279,7 @@ int led_toggle(int led)
if (leds < 0) {
return leds;
}
return ioctl(leds, LED_TOGGLE, led);
return px4_ioctl(leds, LED_TOGGLE, led);
}
int led_on(int led)
@@ -286,7 +287,7 @@ int led_on(int led)
if (leds < 0) {
return leds;
}
return ioctl(leds, LED_ON, led);
return px4_ioctl(leds, LED_ON, led);
}
int led_off(int led)
@@ -294,7 +295,7 @@ int led_off(int led)
if (leds < 0) {
return leds;
}
return ioctl(leds, LED_OFF, led);
return px4_ioctl(leds, LED_OFF, led);
}
void rgbled_set_color(rgbled_color_t color)
@@ -303,7 +304,7 @@ void rgbled_set_color(rgbled_color_t color)
if (rgbleds < 0) {
return;
}
ioctl(rgbleds, RGBLED_SET_COLOR, (unsigned long)color);
px4_ioctl(rgbleds, RGBLED_SET_COLOR, (unsigned long)color);
}
void rgbled_set_mode(rgbled_mode_t mode)
@@ -312,7 +313,7 @@ void rgbled_set_mode(rgbled_mode_t mode)
if (rgbleds < 0) {
return;
}
ioctl(rgbleds, RGBLED_SET_MODE, (unsigned long)mode);
px4_ioctl(rgbleds, RGBLED_SET_MODE, (unsigned long)mode);
}
void rgbled_set_pattern(rgbled_pattern_t *pattern)
@@ -321,7 +322,7 @@ void rgbled_set_pattern(rgbled_pattern_t *pattern)
if (rgbleds < 0) {
return;
}
ioctl(rgbleds, RGBLED_SET_PATTERN, (unsigned long)pattern);
px4_ioctl(rgbleds, RGBLED_SET_PATTERN, (unsigned long)pattern);
}
float battery_remaining_estimate_voltage(float voltage, float discharged, float throttle_normalized)