]> cloudbase.mooo.com Git - z180-stamp.git/blobdiff - avr/cmd_gpio.c
some cleanup, more debugging
[z180-stamp.git] / avr / cmd_gpio.c
index 84723d2372453f2d14e9f0913284cc4b03bf6f58..8f50ca3a2cfd9c59fd2a4bd86e9e93534e0ec599 100644 (file)
@@ -1,9 +1,12 @@
-#include "common.h"
-#include <stdlib.h>
-#include <string.h>
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include "cmd_gpio.h"
 #include <ctype.h>
 
-#include "command.h"
 #include "print-utils.h"
 #include "getopt-min.h"
 #include "env.h"
@@ -29,7 +32,9 @@ static void pinnames_get(void)
        memset(pin_names, 0, sizeof(pin_names));
        pin_names_width = 0;
 
-       if ((lp = getenv(PSTR(ENV_PINALIAS))) != NULL) {
+/* TODO: enters endless loop on wrong parameters */
+
+       if ((lp = getenv_str(PSTR(ENV_PINALIAS))) != NULL) {
                pin_names[namestr] = strdup(lp);
                ptr = strtok_P(pin_names[namestr], delim1);
                while (ptr != NULL) {
@@ -168,7 +173,7 @@ static uint_fast8_t pinarg_get(char * arg, uint_fast8_t pinarg[])
 }
 
 
-command_ret_t do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
+command_ret_t do_gpio(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char *const argv[])
 {
        char printheader = 1;
        uint_fast8_t pinarg[GPIO_MAX];
@@ -177,7 +182,7 @@ command_ret_t do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
        (void) cmdtp; (void) flag;
 
        /* reset getopt() */
-       optind = 1;
+       optind = 0;
 
        int opt;
        while ((opt = getopt(argc, argv, PSTR("s"))) != -1) {