#include <stdio.h>
#include <getopt.h>
#include <signal.h>
static int running;
typedef enum p_mode_t{
NONE,
POWERON,
POWEROFF
} p_mode_t;
static void __send_pulses(void)
{
int i, ch, val;
for(i=1; i<=8; i++){
}
printf("\r");
for(i=1;i<=ch;i++){
}
fflush(stdout);
return;
}
static void __signal_handler(__attribute__ ((unused)) int dummy)
{
running=0;
return;
}
static void __print_usage(void)
{
printf("\n");
printf(" Options\n");
printf(" -s Enable 6V power rail for servos.\n");
printf(" -e Disable 6V power rail for ESCs.\n");
printf(" -h Print this messege.\n\n");
return;
}
int main(int argc, char *argv[])
{
int c;
p_mode_t mode = NONE;
opterr = 0;
while ((c = getopt(argc, argv, "seh")) != -1){
switch (c){
case 's':
mode = POWERON;
break;
case 'e':
mode = POWEROFF;
break;
case 'h':
__print_usage();
return -1;
break;
default:
fprintf(stderr,"Invalid Argument \n");
__print_usage();
return -1;
}
}
if(mode == NONE){
fprintf(stderr,"You must select a power mode -s or -e\n");
__print_usage();
return -1;
}
if(mode == POWERON){
fprintf(stderr,"ERROR: failed to run rc_adc_init()\n");
return -1;
}
fprintf(stderr,"ERROR: battery disconnected or insufficiently charged to drive motors\n");
return -1;
}
fprintf(stderr,"failed to enable power rail\n");
return -1;
}
}
printf("1:Thr ");
printf("2:Roll ");
printf("3:Pitch ");
printf("4:Yaw ");
printf("5:Kill ");
printf("6:Mode ");
printf("7:Aux1 ");
printf("8:Aux2 ");
printf("\n");
printf("Waiting for DSM Connection");
fflush(stdout);
signal(SIGINT, __signal_handler);
running=1;
while(running){
printf("\rSeconds since last DSM packet: ");
printf(" ");
fflush(stdout);
}
}
printf("\n");
return 0;
}