Skip to content
Snippets Groups Projects
Commit 9156cd13 authored by bbartels's avatar bbartels
Browse files

quad: add help instructions to virtual quad

parent 5d479d81
No related branches found
No related tags found
No related merge requests found
......@@ -22,9 +22,6 @@ CLEANUP = $(TARGET) $(OBJDIR)
default: $(TARGET)
run: $(TARGET)
$(EXEDIR)/$(NAME)
clean:
rm -rf $(CLEANUP)
......@@ -34,6 +31,7 @@ clean:
$(TARGET): $(OBJECTS) | $(EXEDIR)
$(GCC) -g -o $(TARGET) $^ -I$(INCDIR) -L$(LIBDIR) $(REQLIBS)
cp $(TARGET) ./
$(OBJDIR)/%.o : %.c | $(OBJDIR) $(INCDIR)
$(GCC) -c -g -o $@ $< -I$(INCDIR) -Wall
......
virt-quad
virt-quad-fifos/
\ No newline at end of file
......@@ -7,10 +7,14 @@
int handle_io_output(const char *name);
int handle_io_input(const char *name, const char *value_str);
void set_shm(float value, float *dest, pthread_mutex_t *lock);
void usage(char *executable_name);
struct VirtQuadIO *virt_quad_io;
int virt_quad_io_file_descriptor;
/**
* Implement each of the hardware interfaces.
*/
int setup_hardware(hardware_t *hardware) {
hardware->i2c = create_unix_i2c();
hardware->rc_receiver = create_unix_rc_receiver();
......@@ -25,18 +29,25 @@ int setup_hardware(hardware_t *hardware) {
int main(int argc, char *argv[]) {
int fd, opt;
while ((opt = getopt(argc, argv, "q")) != -1) {
while ((opt = getopt(argc, argv, "qh")) != -1) {
switch (opt) {
case 'q':
fd = open("/dev/null", O_WRONLY);
close(STDOUT_FILENO);
dup2(STDOUT_FILENO, fd);
break;
case 'h':
default: /* '?' */
fprintf(stderr, "Usage: %s [-q]\n", argv[0]);
puts("from flags");
usage(argv[0]);
exit(EXIT_FAILURE);
}
}
if (argv[1] != NULL && strcmp(argv[1], "--help") == 0) {
puts("from if");
usage(argv[0]);
exit(EXIT_FAILURE);
}
argc -= optind;
argv += optind;
......@@ -151,3 +162,27 @@ void set_shm(float value, float *dest, pthread_mutex_t *lock) {
*dest = value;
pthread_mutex_unlock(lock);
}
void usage(char *executable_name) {
printf("Usage: %s [ -h | --help | -q ] [ command ]\n", executable_name);
puts("Overview:");
puts(" The virtual quad emulates the behavior of the real quad in the Unix");
puts(" environment. Start the virtual quad in one tab (no arguments), and");
puts(" then control the I/O of the quad through commands.");
puts("Commands:");
puts(" get output");
puts(" set input value");
puts("Outpus:");
puts(" led");
puts(" motors");
puts("Inputs:");
puts(" rc_gear");
puts(" rc_flap");
puts(" rc_throttle");
puts(" rc_pitch");
puts(" rc_roll");
puts(" rc_yaw");
puts("Examples:");
printf(" %s get led # prints 0 or 1 to stdout\n", executable_name);
printf(" in%s set rc_gear 1 # sets gear to \"on\" \n", executable_name);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment