return CMD_RET_SUCCESS;
}
- /* reset getopt() */
- optind = 0;
-
int opt;
while ((opt = getopt(argc, argv, PSTR("darwo:"))) != -1) {
switch (opt) {
memcpy_P(&boot_param, cfboot, sizeof boot_param);
default_stages = boot_param.stages;
- /* reset getopt() */
- optind = 0;
-
int opt;
while ((opt = getopt(argc, argv, PSTR("vna:s:c:t:i:"))) != -1) {
switch (opt) {
uint32_t addr;
bool hold = 0;
- /* reset getopt() */
- optind = 0;
-
int opt;
while ((opt = getopt(argc, argv, PSTR("h"))) != -1) {
switch (opt) {
uint32_t pulsewidth = 10; /* ms */
- /* reset getopt() */
- optind = 0;
-
int opt;
while ((opt = getopt(argc, argv, PSTR("t:"))) != -1) {
switch (opt) {
char ch;
#if 0
- /* reset getopt() */
- optind = 0;
int opt;
while ((opt = getopt(argc, argv, PSTR("t:"))) != -1) {
switch (opt) {
uint8_t mem_save[ARRAY_SIZE(loop_code)];
- /* reset getopt() */
- optind = 0;
-
int opt;
while ((opt = getopt(argc, argv, PSTR("swnuc:t:"))) != -1) {
switch (opt) {
uint_fast8_t pinarg[GPIO_MAX];
uint_fast8_t pinargc;
- /* reset getopt() */
- optind = 0;
-
int opt;
while ((opt = getopt(argc, argv, PSTR("s"))) != -1) {
switch (opt) {
(void) cmdtp; (void) flag;
- /* reset getopt() */
- optind = 0;
-
int opt;
while ((opt = getopt(argc, argv, PSTR("bwl"))) != -1) {
switch (opt) {
(void) cmdtp;
(void) flag;
- optind = 0;
if (argv[0][1] != 'd') {
int opt;
while ((opt = getopt(argc, argv, PSTR("bwl"))) != -1)
(void) cmdtp; (void) flag;
- /* reset getopt() */
- optind = 0;
-
int opt;
while ((opt = getopt(argc, argv, PSTR("n"))) != -1) {
switch (opt) {
return CMD_RET_SUCCESS;
}
+
+command_ret_t do_time(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag UNUSED, int argc, char * const argv[])
+{
+ uint32_t elapsed_ms = 0;
+ command_ret_t retval;
+ uint_fast8_t repeatable;
+
+ if (argc == 1)
+ return CMD_RET_USAGE;
+
+ elapsed_ms = get_timer(0);
+ retval = cmd_process(0, argc - 1, argv + 1, &repeatable);
+ elapsed_ms = get_timer(elapsed_ms);
+
+ uint32_t min;
+ uint16_t sec, ms;
+
+ min = elapsed_ms / 1000 / 60;
+ sec = (elapsed_ms / 1000) % 60;
+ ms = elapsed_ms % 1000;
+
+ printf_P(PSTR("\ntime: %lum%u.%03us\n"), min, sec, ms);
+
+ return retval;
+}
#define OPT_USAGE 0x08
#define OPT_LONG 0x10
- /* reset getopt() */
- optind = 0;
-
int opt;
while ((opt = getopt(argc, argv, PSTR("afk"))) != -1) {
switch (opt) {
* @param argv Arguments
* @return 0 if command succeeded, else non-zero (CMD_RET_...)
*/
-command_ret_t cmd_call(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[])
+static command_ret_t cmd_call(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[])
{
command_ret_t result;
/* If OK so far, then do the command */
if (!rc) {
+ optind = 0; /* reset getopt() */
cmd_invocation_ptr = cmdtp;
rc = cmd_call(cmdtp, flag, argc, argv);
*repeatable &= (cmdtp->flags & CTBL_RPT) != 0;
),
+CMD_TBL_ITEM(
+ time, CONFIG_SYS_MAXARGS, 0, do_time,
+ "run command and print execution time",
+ "command [args...]\n"
+),
CMD_TBL_ITEM(
date, 2, 1, do_date,
"get/set date & time",
sleep , 2, 1, do_sleep,
"delay execution for some time",
"N[m][s]\n"
- " - delay execution for decimal N (milli) seconds"
+ " - delay execution for hexadecimal N (milli) seconds"
),
CMD_TBL_ITEM_COMPLETE(
run, CONFIG_SYS_MAXARGS, 1, do_run,
bool mode = 0;
command_ret_t rc = CMD_RET_SUCCESS;
- /* reset getopt() */
- optind = 0;
-
int opt;
while ((opt = getopt(argc, argv, PSTR("s"))) != -1) {
switch (opt) {
#include "common.h" /* definition of FLASH */
#include <string.h>
-int optind = 0; /* next argv[] index */
+int optind; /* next argv[] index */
char *optarg; /* option parameter if any */
ISR(INT5_vect)
{
- Stat |= S_MSG_PENDING + S_IO_0X40;
+ Stat |= S_MSG_PENDING;
+ Stat |= S_IO_0X40;
}
ISR(INT6_vect)
command_ret_t do_echo(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[]);
command_ret_t do_sleep(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[]);
+command_ret_t do_time(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[]);
#endif /* CMD_MISC_H */