From 64a9e69e66d89db265425e8dd13d40e11652f6ea Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 15 Jun 2017 11:10:25 -0600 Subject: [PATCH] Review from last PR; more dangling whitespace at end of lines. --- wireless/ieee802154/i8sak/README.txt | 8 ++-- wireless/ieee802154/i8sak/i8sak.h | 2 +- wireless/ieee802154/i8sak/i8sak_acceptassoc.c | 3 +- wireless/ieee802154/i8sak/i8sak_assoc.c | 10 ++++- wireless/ieee802154/i8sak/i8sak_blaster.c | 7 ++++ wireless/ieee802154/i8sak/i8sak_main.c | 39 ++++++++++++------- wireless/ieee802154/i8sak/i8sak_poll.c | 4 +- wireless/ieee802154/i8sak/i8sak_sniffer.c | 4 +- wireless/ieee802154/i8sak/i8sak_startpan.c | 4 +- wireless/ieee802154/i8sak/i8sak_tx.c | 16 ++++++-- wireless/ieee802154/i8sak/wpanlistener.c | 3 +- wireless/ieee802154/i8sak/wpanlistener.h | 24 ++++++------ 12 files changed, 85 insertions(+), 39 deletions(-) diff --git a/wireless/ieee802154/i8sak/README.txt b/wireless/ieee802154/i8sak/README.txt index b96740771..173d38c9e 100644 --- a/wireless/ieee802154/i8sak/README.txt +++ b/wireless/ieee802154/i8sak/README.txt @@ -3,7 +3,7 @@ IEEE 802.15.4 Swiss Army Knife (i8sak, or i8) Description =========== -The i8sak app is a useful CLI for testing various IEEE 802.15.4 functionality. +The i8sak app is a useful CLI for testing various IEEE 802.15.4 functionality. It also serves as a starting place for learning how to interface with the NuttX IEEE 802.15.4 MAC layer. @@ -50,7 +50,7 @@ just use it once. The acceptassoc command, without any arguments, informs the i8sak instance to accept all association requests. The acceptassoc command also allows you to only accept requests from a single device by specifying the extended address with option --e. +-e. For instance: ``` @@ -102,7 +102,7 @@ transactions: 2a) ACK Frame Type - ACK Sequence Number - 1 - + 3) Association Response Frame Type - CMD Sequence Number - 0 @@ -136,7 +136,7 @@ Because the devmode is PAN Coordinator, the i8sak app knows to send the data as an indirect transaction. If you were running the i8sak app on a device that is a coordinator, but not the PAN coordinator, you can force the i8sak app to send the transaction directly, rather than to the parent coordinator, by using -the -d option. +the -d option. NOTE: Currently, the indirect transaction timeout is disabled. This means frames must be extracted or space may run out. This is only for the testing phase as it diff --git a/wireless/ieee802154/i8sak/i8sak.h b/wireless/ieee802154/i8sak/i8sak.h index e8bc0e1ad..7beece2a5 100644 --- a/wireless/ieee802154/i8sak/i8sak.h +++ b/wireless/ieee802154/i8sak/i8sak.h @@ -118,7 +118,7 @@ enum i8sak_cmd_e struct i8sak_s { /* Support singly linked list */ - + FAR struct i8sak_s *flink; bool initialized : 1; diff --git a/wireless/ieee802154/i8sak/i8sak_acceptassoc.c b/wireless/ieee802154/i8sak/i8sak_acceptassoc.c index e09ae9e17..5edace40a 100644 --- a/wireless/ieee802154/i8sak/i8sak_acceptassoc.c +++ b/wireless/ieee802154/i8sak/i8sak_acceptassoc.c @@ -74,7 +74,8 @@ void i8sak_acceptassoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[] { struct wpanlistener_eventfilter_s filter; bool acceptall = true; /* start off assuming we are going to allow all connections */ - int option, optcnt; + int option; + int optcnt; optcnt = 0; while ((option = getopt(argc, argv, ":he:")) != ERROR) diff --git a/wireless/ieee802154/i8sak/i8sak_assoc.c b/wireless/ieee802154/i8sak/i8sak_assoc.c index 08d54e67e..d03e0b5a7 100644 --- a/wireless/ieee802154/i8sak/i8sak_assoc.c +++ b/wireless/ieee802154/i8sak/i8sak_assoc.c @@ -79,7 +79,10 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) { struct ieee802154_assoc_req_s assocreq; struct wpanlistener_eventfilter_s filter; - int fd, option, optcnt, ret; + int fd; + int option; + int optcnt; + int ret; /* If the addresses has never been automatically or manually set before, set * it assuming that we are the default device address and the endpoint is the @@ -103,28 +106,33 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) "Usage: %s [-h]\n" " -h = this help menu\n" , argv[0]); + /* Must manually reset optind if we are going to exit early */ optind = -1; return; + case 's': /* Parse extended address and put it into the i8sak instance */ i8sak->ep.saddr = i8sak_str2luint16(optarg); i8sak->ep.mode= IEEE802154_ADDRMODE_SHORT; break; + case 'e': /* Parse extended address and put it into the i8sak instance */ i8sak_str2eaddr(optarg, &i8sak->ep.eaddr[0]); i8sak->ep.mode = IEEE802154_ADDRMODE_EXTENDED; break; + case ':': fprintf(stderr, "ERROR: missing argument\n"); /* Must manually reset optind if we are going to exit early */ optind = -1; i8sak_cmd_error(i8sak); /* This exits for us */ + case '?': fprintf(stderr, "ERROR: unknown argument\n"); /* Must manually reset optind if we are going to exit early */ diff --git a/wireless/ieee802154/i8sak/i8sak_blaster.c b/wireless/ieee802154/i8sak/i8sak_blaster.c index 3cf410ef2..432b99a2c 100644 --- a/wireless/ieee802154/i8sak/i8sak_blaster.c +++ b/wireless/ieee802154/i8sak/i8sak_blaster.c @@ -97,6 +97,7 @@ void i8sak_blaster_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) " -p = set period (and start blaster)\n" "Note: No option starts blaster with defaults\n" , argv[0]); + /* Must manually reset optind if we are going to exit early */ optind = -1; @@ -104,23 +105,29 @@ void i8sak_blaster_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) case 'q': /* Quit blaster */ i8sak->blasterenabled = false; break; + case 'p': /* Inline change blaster period */ i8sak->blasterperiod = atoi(optarg); i8sak_blaster_start(i8sak); break; + case 'f': /* Inline change blaster frame */ i8sak->payload_len = i8sak_str2payload(optarg, &i8sak->payload[0]); i8sak_blaster_start(i8sak); break; + case ':': fprintf(stderr, "ERROR: missing argument\n"); + /* Must manually reset optind if we are going to exit early */ optind = -1; i8sak_cmd_error(i8sak); /* This exits for us */ break; + case '?': fprintf(stderr, "ERROR: unknown argument\n"); + /* Must manually reset optind if we are going to exit early */ optind = -1; diff --git a/wireless/ieee802154/i8sak/i8sak_main.c b/wireless/ieee802154/i8sak/i8sak_main.c index fec63aa83..7bc94efe8 100644 --- a/wireless/ieee802154/i8sak/i8sak_main.c +++ b/wireless/ieee802154/i8sak/i8sak_main.c @@ -112,12 +112,12 @@ static const struct i8sak_command_s g_i8sak_commands[] = #define NCOMMANDS (sizeof(g_i8sak_commands) / sizeof(struct i8sak_command_s)) -sq_queue_t g_i8sak_free; -sq_queue_t g_i8sak_instances; -struct i8sak_s g_i8sak_pool[CONFIG_IEEE802154_I8SAK_NINSTANCES]; -bool g_i8sak_initialized = false; -bool g_activei8sak_set = false; -FAR struct i8sak_s *g_activei8sak; +static sq_queue_t g_i8sak_free; +static sq_queue_t g_i8sak_instances; +static struct i8sak_s g_i8sak_pool[CONFIG_IEEE802154_I8SAK_NINSTANCES]; +static bool g_i8sak_initialized = false; +static bool g_activei8sak_set = false; +static FAR struct i8sak_s *g_activei8sak; /**************************************************************************** * Private Function Prototypes @@ -204,7 +204,9 @@ int i8sak_tx(FAR struct i8sak_s *i8sak, int fd) int i8sak_str2payload(FAR const char *str, FAR uint8_t *buf) { - int str_len, ret, i = 0; + int str_len; + int ret; + int i = 0; str_len = strlen(str); @@ -213,7 +215,8 @@ int i8sak_str2payload(FAR const char *str, FAR uint8_t *buf) ret = str_len >> 1; /* Check if the number of chars is a multiple of 2 and that the number of - * bytes does not exceed the max MAC frame payload supported */ + * bytes does not exceed the max MAC frame payload supported. + */ if ((str_len & 1) || (ret > IEEE802154_MAX_MAC_PAYLOAD_SIZE)) { @@ -418,7 +421,9 @@ static void i8sak_switch_instance(FAR char *devname) { FAR struct i8sak_s *i8sak; - /* Search list of i8sak instances for one associated with the provided device */ + /* Search list of i8sak instances for one associated with the provided + * device. + */ i8sak = (FAR struct i8sak_s *)sq_peek(&g_i8sak_instances); @@ -447,7 +452,8 @@ static void i8sak_switch_instance(FAR char *devname) } /* Update our "sticky" i8sak instance. Must come before call to setup so that - * the shared active global i8sak is correct */ + * the shared active global i8sak is correct. + */ g_activei8sak = i8sak; @@ -465,7 +471,9 @@ static void i8sak_switch_instance(FAR char *devname) static int i8sak_setup(FAR struct i8sak_s *i8sak, FAR const char *devname) { char daemonname[I8SAK_DAEMONNAME_FMTLEN]; - int i, ret, fd; + int i; + int ret; + int fd; if (i8sak->initialized) { @@ -651,7 +659,9 @@ int i8_main(int argc, char *argv[]) #endif { FAR const struct i8sak_command_s *i8sakcmd; - int i, ret, argind; + int argind; + int ret; + int i; if (!g_i8sak_initialized) { @@ -681,11 +691,14 @@ int i8_main(int argc, char *argv[]) if (argc == 2) { - /* Close silently to allow user to set devname without any other operation */ + /* Close silently to allow user to set devname without any + * other operation. + */ return EXIT_SUCCESS; } } + /* Argument must be command */ } diff --git a/wireless/ieee802154/i8sak/i8sak_poll.c b/wireless/ieee802154/i8sak/i8sak_poll.c index 671c5a876..fa59dc2ed 100644 --- a/wireless/ieee802154/i8sak/i8sak_poll.c +++ b/wireless/ieee802154/i8sak/i8sak_poll.c @@ -80,7 +80,9 @@ void i8sak_poll_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) { struct ieee802154_poll_req_s pollreq; struct wpanlistener_eventfilter_s eventfilter; - int ret, fd, option; + int option; + int fd; + int ret; ret = OK; while ((option = getopt(argc, argv, ":h")) != ERROR) diff --git a/wireless/ieee802154/i8sak/i8sak_sniffer.c b/wireless/ieee802154/i8sak/i8sak_sniffer.c index 8ed5caa35..253ca8b4f 100644 --- a/wireless/ieee802154/i8sak/i8sak_sniffer.c +++ b/wireless/ieee802154/i8sak/i8sak_sniffer.c @@ -75,7 +75,9 @@ void i8sak_sniffer_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) { - int ret, fd, option; + int option; + int fd; + int ret; ret = OK; while ((option = getopt(argc, argv, "h")) != ERROR) diff --git a/wireless/ieee802154/i8sak/i8sak_startpan.c b/wireless/ieee802154/i8sak/i8sak_startpan.c index 19be57f1e..c1dd5fcb7 100644 --- a/wireless/ieee802154/i8sak/i8sak_startpan.c +++ b/wireless/ieee802154/i8sak/i8sak_startpan.c @@ -73,7 +73,9 @@ void i8sak_startpan_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) { struct ieee802154_reset_req_s resetreq; struct ieee802154_start_req_s startreq; - int fd, i, option; + int option; + int fd; + int i; while ((option = getopt(argc, argv, ":h")) != ERROR) { diff --git a/wireless/ieee802154/i8sak/i8sak_tx.c b/wireless/ieee802154/i8sak/i8sak_tx.c index 3c8f28485..856d7dcb3 100644 --- a/wireless/ieee802154/i8sak/i8sak_tx.c +++ b/wireless/ieee802154/i8sak/i8sak_tx.c @@ -80,7 +80,10 @@ void i8sak_tx_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) enum ieee802154_devmode_e devmode; struct wpanlistener_eventfilter_s eventfilter; bool sendasdev = false; - int fd, ret, option, argind; + int argind; + int option; + int fd; + int ret; ret = OK; argind = 1; @@ -94,20 +97,25 @@ void i8sak_tx_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) " -h = this help menu\n" " -d = send as device instead of coord\n" , argv[0]); + /* Must manually reset optind if we are going to exit early */ optind = -1; return; + case 'd': sendasdev = true; argind++; break; + case ':': fprintf(stderr, "ERROR: missing argument\n"); + /* Must manually reset optind if we are going to exit early */ optind = -1; i8sak_cmd_error(i8sak); /* This exits for us */ + case '?': fprintf(stderr, "ERROR: unknown argument\n"); ret = ERROR; @@ -139,7 +147,8 @@ void i8sak_tx_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) if (!sendasdev) { /* If we are acting as an endpoint, send as normal CSMA (non-indirect) - * If we are a coordinator or PAN coordinator, send as indirect */ + * If we are a coordinator or PAN coordinator, send as indirect. + */ if (devmode == IEEE802154_DEVMODE_ENDPOINT) { @@ -154,7 +163,8 @@ void i8sak_tx_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) { /* We cannot send a frame as direct if we are the PAN coordinator. Maybe * this should be the hook for sending payload in beacon? But for now, - * let's just thow an error. */ + * let's just thow an error. + */ if (devmode == IEEE802154_DEVMODE_PANCOORD) { diff --git a/wireless/ieee802154/i8sak/wpanlistener.c b/wireless/ieee802154/i8sak/wpanlistener.c index 4a354029a..4fdd344ba 100644 --- a/wireless/ieee802154/i8sak/wpanlistener.c +++ b/wireless/ieee802154/i8sak/wpanlistener.c @@ -448,7 +448,8 @@ static pthread_addr_t wpanlistener_framethread(pthread_addr_t arg) FAR struct wpanlistener_s *handle = (FAR struct wpanlistener_s *)arg; FAR struct wpanlistener_framereceiver_s *receiver; struct mac802154dev_rxframe_s frame; - int i, ret; + int ret; + int i; while (handle->threadrun) { diff --git a/wireless/ieee802154/i8sak/wpanlistener.h b/wireless/ieee802154/i8sak/wpanlistener.h index 8501a0339..5d1ee14aa 100644 --- a/wireless/ieee802154/i8sak/wpanlistener.h +++ b/wireless/ieee802154/i8sak/wpanlistener.h @@ -53,12 +53,12 @@ #if !defined(CONFIG_WPANLISTENER_NFRAMERECEIVERS) || CONFIG_WPANLISTENER_NFRAMERECEIVERS <= 0 # undef CONFIG_WPANLISTENER_NFRAMERECEIVERS -# define CONFIG_WPANLISTENER_NFRAMERECEIVERS 3 +# define CONFIG_WPANLISTENER_NFRAMERECEIVERS 3 #endif #if !defined(CONFIG_WPANLISTENER_NEVENTRECEIVERS) || CONFIG_WPANLISTENER_NEVENTRECEIVERS <= 0 # undef CONFIG_WPANLISTENER_NEVENTRECEIVERS -# define CONFIG_WPANLISTENER_NEVENTRECEIVERS 3 +# define CONFIG_WPANLISTENER_NEVENTRECEIVERS 3 #endif /**************************************************************************** @@ -142,10 +142,10 @@ struct wpanlistener_s sq_queue_t eventreceivers_free; sq_queue_t framereceivers_free; - struct wpanlistener_framereceiver_s + struct wpanlistener_framereceiver_s framereceiver_pool[CONFIG_WPANLISTENER_NFRAMERECEIVERS]; - struct wpanlistener_eventreceiver_s + struct wpanlistener_eventreceiver_s eventreceiver_pool[CONFIG_WPANLISTENER_NEVENTRECEIVERS]; }; @@ -167,7 +167,7 @@ struct wpanlistener_s * OK on success; a negated errno on failure * * Assumptions: - * + * ****************************************************************************/ int wpanlistener_setup(FAR struct wpanlistener_s *handle, int fd); @@ -185,7 +185,7 @@ int wpanlistener_setup(FAR struct wpanlistener_s *handle, int fd); * OK on success; a negated errno on failure * * Assumptions: - * + * ****************************************************************************/ int wpanlistener_start(FAR struct wpanlistener_s *handle); @@ -203,7 +203,7 @@ int wpanlistener_start(FAR struct wpanlistener_s *handle); * OK on success; a negated errno on failure * * Assumptions: - * + * ****************************************************************************/ int wpanlistener_stop(FAR struct wpanlistener_s *handle); @@ -224,12 +224,12 @@ int wpanlistener_stop(FAR struct wpanlistener_s *handle); * arg - user specified argument to send to the callback * oneshot - whether the receiver is automatically unregistered after the * first notification - * + * * Returned Value: * OK if successful; a negated errno on failure * * Assumptions: - * + * ****************************************************************************/ int wpanlistener_add_framereceiver(FAR struct wpanlistener_s *handle, @@ -258,7 +258,7 @@ int wpanlistener_add_framereceiver(FAR struct wpanlistener_s *handle, * OK if successful; a negated errno on failure * * Assumptions: - * + * ****************************************************************************/ int wpanlistener_add_eventreceiver(FAR struct wpanlistener_s *handle, @@ -281,7 +281,7 @@ int wpanlistener_add_eventreceiver(FAR struct wpanlistener_s *handle, * OK on success; a negated errno on failure * * Assumptions: - * + * ****************************************************************************/ int wpanlistener_remove_framereceiver(FAR struct wpanlistener_s *handle, @@ -302,7 +302,7 @@ int wpanlistener_remove_framereceiver(FAR struct wpanlistener_s *handle, * OK on success; a negated errno on failure * * Assumptions: - * + * ****************************************************************************/ int wpanlistener_remove_eventreceiver(FAR struct wpanlistener_s *handle,