This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
commit aa581fe5ce6d20bafe61239a6d99d84ecedc77c0 Author: Alin Jerpelea <[email protected]> AuthorDate: Thu Jun 10 18:40:35 2021 +0200 system: nxstyle fixes fixes for errors reported by the nxstyle tool Signed-off-by: Alin Jerpelea <[email protected]> --- system/cdcacm/cdcacm.h | 6 +- system/cdcacm/cdcacm_main.c | 13 +- system/cfgdata/cfgdata_main.c | 13 +- system/composite/composite.h | 2 +- system/critmon/critmon.c | 35 +- system/dhcpc/renew_main.c | 2 +- system/flash_eraseall/flash_eraseall_main.c | 2 +- system/i2c/i2c_dev.c | 16 +- system/mdio/mdio_main.c | 6 +- system/netdb/netdb_main.c | 2 +- system/nsh/nsh_main.c | 2 +- system/ntpc/ntpcstart_main.c | 2 +- system/ntpc/ntpcstop_main.c | 2 +- system/ping6/ping6.c | 44 +- system/spi/spi_devif.c | 2 +- system/spi/spi_main.c | 39 +- system/stackmonitor/stackmonitor.c | 42 +- system/termcurses/tcurses_vt100.c | 766 ++++++++++++++++++++-------- system/termcurses/termcurses.c | 4 +- system/usbmsc/usbmsc.h | 4 +- system/zmodem/host/crc32.h | 2 +- system/zmodem/host/nuttx/ascii.h | 3 +- system/zmodem/host/nuttx/config.h | 3 +- system/zmodem/rz_main.c | 20 +- system/zmodem/sz_main.c | 15 +- system/zmodem/zm_proto.c | 2 +- system/zmodem/zm_receive.c | 2 +- system/zmodem/zm_send.c | 24 +- system/zmodem/zm_state.c | 83 +-- system/zmodem/zm_utils.c | 51 +- system/zmodem/zm_watchdog.c | 5 +- 31 files changed, 831 insertions(+), 383 deletions(-) diff --git a/system/cdcacm/cdcacm.h b/system/cdcacm/cdcacm.h index acfd56e..bc255a0 100644 --- a/system/cdcacm/cdcacm.h +++ b/system/cdcacm/cdcacm.h @@ -1,5 +1,5 @@ /**************************************************************************** - * system/cdcacm/cdcacm.h + * apps/system/cdcacm/cdcacm.h * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -34,7 +34,9 @@ /**************************************************************************** * Pre-Processor Definitions ****************************************************************************/ + /* Configuration ************************************************************/ + /* Prerequisites */ #ifndef CONFIG_USBDEV @@ -112,7 +114,7 @@ struct cdcacm_state_s ****************************************************************************/ /**************************************************************************** - * Public Functions + * Public Functions Prototypes ****************************************************************************/ #endif /* __SYSTEM_CDCACM_CDCACM_H */ diff --git a/system/cdcacm/cdcacm_main.c b/system/cdcacm/cdcacm_main.c index 73f7d9b..e3f08b1 100644 --- a/system/cdcacm/cdcacm_main.c +++ b/system/cdcacm/cdcacm_main.c @@ -1,5 +1,5 @@ /**************************************************************************** - * system/cdcacm/cdcacm_main.c + * apps/system/cdcacm/cdcacm_main.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -62,8 +62,8 @@ int main(int argc, FAR char *argv[]) struct boardioc_usbdev_ctrl_s ctrl; int ret; - /* Check if there is a non-NULL USB mass storage device handle (meaning that the - * USB mass storage device is already configured). + /* Check if there is a non-NULL USB mass storage device handle + * (meaning that the USB mass storage device is already configured). */ if (g_cdcacm.handle) @@ -90,7 +90,8 @@ int main(int argc, FAR char *argv[]) ret = boardctl(BOARDIOC_USBDEV_CONTROL, (uintptr_t)&ctrl); if (ret < 0) { - printf("sercon: ERROR: Failed to create the CDC/ACM serial device: %d\n", -ret); + printf("sercon: ERROR: " + "Failed to create the CDC/ACM serial device: %d\n", -ret); return EXIT_FAILURE; } @@ -124,7 +125,9 @@ int serdis_main(int argc, char *argv[]) usbtrace_enable(0); - /* Then disconnect the device and uninitialize the USB mass storage driver */ + /* Then disconnect the device and uninitialize the USB mass storage + * driver + */ ctrl.usbdev = BOARDIOC_USBDEV_CDCACM; ctrl.action = BOARDIOC_USBDEV_DISCONNECT; diff --git a/system/cfgdata/cfgdata_main.c b/system/cfgdata/cfgdata_main.c index 6576c9c..e81e45f 100644 --- a/system/cfgdata/cfgdata_main.c +++ b/system/cfgdata/cfgdata_main.c @@ -77,7 +77,6 @@ static void cfgdatacmd_help(void) #else printf(" unset id,instance\n"); #endif - } /**************************************************************************** @@ -183,7 +182,7 @@ static void cfgdatacmd_parse_byte_array(struct config_data_s *cfg, { /* Hex byte */ - sscanf(&argv[x][c+2], "%x", &val); + sscanf(&argv[x][c + 2], "%x", &val); cfg->configdata[count] = (uint8_t) val; } else @@ -491,7 +490,7 @@ static void cfgdatacmd_print(int argc, char *argv[]) /* Display the data */ - isstring = cfg.configdata[cfg.len-1] == 0; + isstring = cfg.configdata[cfg.len - 1] == 0; for (x = 0; x < cfg.len - 1; x++) { /* Test for all ascii characters */ @@ -519,7 +518,7 @@ static void cfgdatacmd_print(int argc, char *argv[]) printf("0x%02X ", cfg.configdata[x]); - if (((x + 1) & 7) == 0 && x+1 != cfg.len) + if (((x + 1) & 7) == 0 && x + 1 != cfg.len) { printf("\n"); } @@ -589,7 +588,7 @@ static void cfgdatacmd_show_all_config_items(void) /* Test if data is a string */ - isstring = cfg.configdata[cfg.len-1] == 0; + isstring = cfg.configdata[cfg.len - 1] == 0; for (x = 0; x < cfg.len - 1; x++) { /* Test for all ascii characters */ @@ -612,7 +611,7 @@ static void cfgdatacmd_show_all_config_items(void) char fmtstr2[10]; #ifdef CONFIG_MTD_CONFIG_NAMED - sprintf(fmtstr2, "\n%ds", CONFIG_MTD_CONFIG_NAME_LEN+6); + sprintf(fmtstr2, "\n%ds", CONFIG_MTD_CONFIG_NAME_LEN + 6); #else strcpy(fmtstr2, "\n%18s"); #endif @@ -624,7 +623,7 @@ static void cfgdatacmd_show_all_config_items(void) printf("0x%02X ", cfg.configdata[x]); - if (((x + 1) & 7) == 0 && x+1 != cfg.len) + if (((x + 1) & 7) == 0 && x + 1 != cfg.len) { printf(fmtstr2, " "); } diff --git a/system/composite/composite.h b/system/composite/composite.h index 8f369bb..0bef05e 100644 --- a/system/composite/composite.h +++ b/system/composite/composite.h @@ -1,5 +1,5 @@ /**************************************************************************** - * system/composite/composite.h + * apps/system/composite/composite.h * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/system/critmon/critmon.c b/system/critmon/critmon.c index c400cd2..f54a45e 100644 --- a/system/critmon/critmon.c +++ b/system/critmon/critmon.c @@ -113,7 +113,6 @@ static FAR char *critmon_isolate_value(FAR char *line) ****************************************************************************/ static int critmon_process_directory(FAR struct dirent *entryp) - { FAR const char *tmpstr; FAR char *filepath; @@ -131,12 +130,14 @@ static int critmon_process_directory(FAR struct dirent *entryp) /* Read the task status to get the task name */ filepath = NULL; - ret = asprintf(&filepath, CONFIG_SYSTEM_CRITMONITOR_MOUNTPOINT "/%s/status", + ret = asprintf(&filepath, + CONFIG_SYSTEM_CRITMONITOR_MOUNTPOINT "/%s/status", entryp->d_name); if (ret < 0 || filepath == NULL) { errcode = errno; - fprintf(stderr, "Csection Monitor: Failed to create path to status file: %d\n", + fprintf(stderr, + "Csection Monitor: Failed to create path to status file: %d\n", errcode); return -errcode; } @@ -182,12 +183,14 @@ static int critmon_process_directory(FAR struct dirent *entryp) filepath = NULL; - ret = asprintf(&filepath, CONFIG_SYSTEM_CRITMONITOR_MOUNTPOINT "/%s/critmon", + ret = asprintf(&filepath, + CONFIG_SYSTEM_CRITMONITOR_MOUNTPOINT "/%s/critmon", entryp->d_name); if (ret < 0 || filepath == NULL) { errcode = errno; - fprintf(stderr, "Csection Monitor: Failed to create path to Csection file: %d\n", + fprintf(stderr, "Csection Monitor: " + "Failed to create path to Csection file: %d\n", errcode); ret = -EINVAL; goto errout_with_name; @@ -306,11 +309,13 @@ static void critmon_global_crit(void) filepath = NULL; - ret = asprintf(&filepath, CONFIG_SYSTEM_CRITMONITOR_MOUNTPOINT "/critmon"); + ret = asprintf(&filepath, + CONFIG_SYSTEM_CRITMONITOR_MOUNTPOINT "/critmon"); if (ret < 0 || filepath == NULL) { errcode = errno; - fprintf(stderr, "Csection Monitor: Failed to create path to Csection file: %d\n", + fprintf(stderr, "Csection Monitor: " + "Failed to create path to Csection file: %d\n", errcode); return; } @@ -418,7 +423,8 @@ static int critmon_daemon(int argc, char **argv) if (++errcount > 100) { - fprintf(stderr, "Csection Monitor: Too many errors ... exiting\n"); + fprintf(stderr, + "Csection Monitor: Too many errors ... exiting\n"); exitcode = EXIT_FAILURE; break; } @@ -450,13 +456,14 @@ static int critmon_daemon(int argc, char **argv) { /* Failed to process the thread directory */ - fprintf(stderr, - "Csection Monitor: Failed to process sub-directory: %s\n", + fprintf(stderr, "Csection Monitor: " + "Failed to process sub-directory: %s\n", entryp->d_name); if (++errcount > 100) { - fprintf(stderr, "Csection Monitor: Too many errors ... exiting\n"); + fprintf(stderr, "Csection Monitor: " + "Too many errors ... exiting\n"); exitcode = EXIT_FAILURE; break; } @@ -497,13 +504,15 @@ int main(int argc, char **argv) g_critmon.started = true; g_critmon.stop = false; - ret = task_create("Csection Monitor", CONFIG_SYSTEM_CRITMONITOR_DAEMON_PRIORITY, + ret = task_create("Csection Monitor", + CONFIG_SYSTEM_CRITMONITOR_DAEMON_PRIORITY, CONFIG_SYSTEM_CRITMONITOR_DAEMON_STACKSIZE, (main_t)critmon_daemon, (FAR char * const *)NULL); if (ret < 0) { int errcode = errno; - printf("Csection Monitor ERROR: Failed to start the stack monitor: %d\n", + printf("Csection Monitor ERROR: " + "Failed to start the stack monitor: %d\n", errcode); } else diff --git a/system/dhcpc/renew_main.c b/system/dhcpc/renew_main.c index bbb20a3..bc0297e 100644 --- a/system/dhcpc/renew_main.c +++ b/system/dhcpc/renew_main.c @@ -1,5 +1,5 @@ /**************************************************************************** - * system/dhcpc/renew_main.c + * apps/system/dhcpc/renew_main.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/system/flash_eraseall/flash_eraseall_main.c b/system/flash_eraseall/flash_eraseall_main.c index fd43a98..3381529 100644 --- a/system/flash_eraseall/flash_eraseall_main.c +++ b/system/flash_eraseall/flash_eraseall_main.c @@ -1,5 +1,5 @@ /**************************************************************************** - * apps/system/flash_eraseall/flash_eraseall.c + * apps/system/flash_eraseall/flash_eraseall_main.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/system/i2c/i2c_dev.c b/system/i2c/i2c_dev.c index 121f952..d147386 100644 --- a/system/i2c/i2c_dev.c +++ b/system/i2c/i2c_dev.c @@ -86,15 +86,16 @@ int i2ccmd_dev(FAR struct i2ctool_s *i2ctool, int argc, char **argv) argndx += nargs; } - /* There should be exactly two more things on the command line: The first and - * last addresses to be probed. + /* There should be exactly two more things on the command line: + * The first and last addresses to be probed. */ if (argndx + 1 < argc) { first = strtol(argv[argndx], NULL, 16); last = strtol(argv[argndx + 1], NULL, 16); - if (first < 0 || first > 0x7f || last < 0 || last > 0x7f || first > last) + if (first < 0 || first > 0x7f || last < 0 || + last > 0x7f || first > last) { i2ctool_printf(i2ctool, g_i2cargrange, argv[0]); goto errout; @@ -119,13 +120,15 @@ int i2ccmd_dev(FAR struct i2ctool_s *i2ctool, int argc, char **argv) fd = i2cdev_open(i2ctool->bus); if (fd < 0) { - i2ctool_printf(i2ctool, "Failed to get bus %d\n", i2ctool->bus); - goto errout; + i2ctool_printf(i2ctool, "Failed to get bus %d\n", + i2ctool->bus); + goto errout; } /* Probe each address */ - i2ctool_printf(i2ctool, " 0 1 2 3 4 5 6 7 8 9 a b c d e f\n"); + i2ctool_printf(i2ctool, + " 0 1 2 3 4 5 6 7 8 9 a b c d e f\n"); for (i = 0; i < 128; i += 16) { i2ctool_printf(i2ctool, "%02x: ", i); @@ -160,6 +163,7 @@ int i2ccmd_dev(FAR struct i2ctool_s *i2ctool, int argc, char **argv) { i2ctool_printf(i2ctool, "-- "); } + i2ctool_flush(i2ctool); } diff --git a/system/mdio/mdio_main.c b/system/mdio/mdio_main.c index 2921cd8..b37eecd 100644 --- a/system/mdio/mdio_main.c +++ b/system/mdio/mdio_main.c @@ -1,5 +1,5 @@ /**************************************************************************** - * system/mdio/mdio_main.c + * apps/system/mdio/mdio_main.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -112,7 +112,7 @@ int get_phy_reg(uint16_t phy_id, uint16_t reg_num, uint16_t *val) ret = ioctl(g_listen_fd, SIOCGMIIREG, (unsigned long) &ifr); - if(ret == OK) + if (ret == OK) { *val = ifr.ifr_mii_val_out; } @@ -156,7 +156,7 @@ int main(int argc, FAR char *argv[]) uint16_t val_in; uint16_t val_out; - /*--- SETUP --------------------------------------------------------------*/ + /* -- SETUP ------------------------------------------------------------- */ if (argc == 1) { diff --git a/system/netdb/netdb_main.c b/system/netdb/netdb_main.c index 53f0893..9252011 100644 --- a/system/netdb/netdb_main.c +++ b/system/netdb/netdb_main.c @@ -1,5 +1,5 @@ /**************************************************************************** - * apps/system/netdb/netdb.c + * apps/system/netdb/netdb_main.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/system/nsh/nsh_main.c b/system/nsh/nsh_main.c index 6f5a4bd..a13a7a8 100644 --- a/system/nsh/nsh_main.c +++ b/system/nsh/nsh_main.c @@ -1,5 +1,5 @@ /**************************************************************************** - * system/nsh/nsh_main.c + * apps/system/nsh/nsh_main.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/system/ntpc/ntpcstart_main.c b/system/ntpc/ntpcstart_main.c index 8f8e86e..3812c13 100644 --- a/system/ntpc/ntpcstart_main.c +++ b/system/ntpc/ntpcstart_main.c @@ -1,5 +1,5 @@ /**************************************************************************** - * system/ntpc/ntpcstart_main.c + * apps/system/ntpc/ntpcstart_main.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/system/ntpc/ntpcstop_main.c b/system/ntpc/ntpcstop_main.c index 62b3351..be1e911 100644 --- a/system/ntpc/ntpcstop_main.c +++ b/system/ntpc/ntpcstop_main.c @@ -1,5 +1,5 @@ /**************************************************************************** - * system/ntpc/ntpc_main.c + * apps/system/ntpc/ntpcstop_main.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/system/ping6/ping6.c b/system/ping6/ping6.c index a25d5cd..4ef3772 100644 --- a/system/ping6/ping6.c +++ b/system/ping6/ping6.c @@ -1,5 +1,5 @@ /**************************************************************************** - * apps/system/ping/ping.c + * apps/system/ping6/ping6.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -51,28 +51,36 @@ * Name: show_usage ****************************************************************************/ -static void show_usage(FAR const char *progname, int exitcode) noreturn_function; +static void show_usage(FAR const char *progname, int exitcode) + noreturn_function; static void show_usage(FAR const char *progname, int exitcode) { #if defined(CONFIG_LIBC_NETDB) && defined(CONFIG_NETDB_DNSCLIENT) - printf("\nUsage: %s [-c <count>] [-i <interval>] [-W <timeout>] [-s <size>] <hostname>\n", progname); + printf("\nUsage: %s [-c <count>] [-i <interval>] " + "[-W <timeout>] [-s <size>] <hostname>\n", progname); printf(" %s -h\n", progname); printf("\nWhere:\n"); - printf(" <hostname> is either an IPv6 address or the name of the remote host\n"); + printf(" <hostname> is either an IPv6 address " + "or the name of the remote host\n"); printf(" that is requested the ICMPv6 ECHO reply.\n"); #else - printf("\nUsage: %s [-c <count>] [-i <interval>] [-W <timeout>] [-s <size>] <ip-address>\n", progname); + printf("\nUsage: %s [-c <count>] [-i <interval>] [-W <timeout>] " + "[-s <size>] <ip-address>\n", progname); printf(" %s -h\n", progname); printf("\nWhere:\n"); - printf(" <ip-address> is the IPv6 address request the ICMPv6 ECHO reply.\n"); + printf(" <ip-address> is the IPv6 address request " + "the ICMPv6 ECHO reply.\n"); #endif printf(" -c <count> determines the number of pings. Default %u.\n", ICMPv6_NPINGS); - printf(" -i <interval> is the default delay between pings (milliseconds).\n"); + printf(" -i <interval> is the default delay between pings " + "(milliseconds).\n"); printf(" Default %d.\n", ICMPv6_POLL_DELAY); - printf(" -W <timeout> is the timeout for wait response (milliseconds).\n"); + printf(" -W <timeout> is the timeout for wait response " + "(milliseconds).\n"); printf(" Default %d.\n", ICMPv6_POLL_DELAY); - printf(" -s <size> specifies the number of data bytes to be sent. Default %u.\n", + printf(" -s <size> specifies the number of data bytes to be sent. " + " Default %u.\n", ICMPv6_PING6_DATALEN); printf(" -h shows this text and exits.\n"); exit(exitcode); @@ -102,7 +110,8 @@ static void ping6_result(FAR const struct ping6_result_s *result) break; case ICMPv6_I_BEGIN: - inet_ntop(AF_INET6, result->dest.s6_addr16, strbuffer, INET6_ADDRSTRLEN); + inet_ntop(AF_INET6, result->dest.s6_addr16, + strbuffer, INET6_ADDRSTRLEN); printf("PING6 %s: %u bytes of data\n", strbuffer, result->info->datalen); break; @@ -189,7 +198,8 @@ static void ping6_result(FAR const struct ping6_result_s *result) (result->nrequests >> 1)) / result->nrequests; - printf("%u packets transmitted, %u received, %u%% packet loss, time %d ms\n", + printf("%u packets transmitted, %u received, " + "%u%% packet loss, time %d ms\n", result->nrequests, result->nreplies, tmp, result->extra); } break; @@ -226,7 +236,8 @@ int main(int argc, FAR char *argv[]) long count = strtol(optarg, &endptr, 10); if (count < 1 || count > UINT16_MAX) { - fprintf(stderr, "ERROR: <count> out of range: %ld\n", count); + fprintf(stderr, "ERROR: <count> out of range: %ld\n", + count); goto errout_with_usage; } @@ -239,7 +250,8 @@ int main(int argc, FAR char *argv[]) long delay = strtol(optarg, &endptr, 10); if (delay < 1 || delay > UINT16_MAX) { - fprintf(stderr, "ERROR: <interval> out of range: %ld\n", delay); + fprintf(stderr, "ERROR: <interval> out of range: %ld\n", + delay); goto errout_with_usage; } @@ -252,7 +264,8 @@ int main(int argc, FAR char *argv[]) long timeout = strtol(optarg, &endptr, 10); if (timeout < 1 || timeout > UINT16_MAX) { - fprintf(stderr, "ERROR: <timeout> out of range: %ld\n", timeout); + fprintf(stderr, "ERROR: <timeout> out of range: %ld\n", + timeout); goto errout_with_usage; } @@ -265,7 +278,8 @@ int main(int argc, FAR char *argv[]) long datalen = strtol(optarg, &endptr, 10); if (datalen < 1 || datalen > UINT16_MAX) { - fprintf(stderr, "ERROR: <size> out of range: %ld\n", datalen); + fprintf(stderr, "ERROR: <size> out of range: %ld\n", + datalen); goto errout_with_usage; } diff --git a/system/spi/spi_devif.c b/system/spi/spi_devif.c index f1f6e33..4243e60 100644 --- a/system/spi/spi_devif.c +++ b/system/spi/spi_devif.c @@ -1,5 +1,5 @@ /**************************************************************************** - * apps/system/i2c/i2c_devif.c + * apps/system/spi/spi_devif.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/system/spi/spi_main.c b/system/spi/spi_main.c index a7e2b43..c78a56b 100644 --- a/system/spi/spi_main.c +++ b/system/spi/spi_main.c @@ -66,14 +66,22 @@ static const struct cmdmap_s g_spicmds[] = /* Common, message formats */ -const char g_spiargrequired[] = "spitool: %s: missing required argument(s)\n"; -const char g_spiarginvalid[] = "spitool: %s: argument invalid\n"; -const char g_spiargrange[] = "spitool: %s: value out of range\n"; -const char g_spicmdnotfound[] = "spitool: %s: command not found\n"; -const char g_spitoomanyargs[] = "spitool: %s: too many arguments\n"; -const char g_spicmdfailed[] = "spitool: %s: %s failed: %d\n"; -const char g_spixfrerror[] = "spitool: %s: Transfer failed: %d\n"; -const char g_spiincompleteparam[] = "spitool: %s: Odd number or illegal char in tx sequence\n"; +const char g_spiargrequired[] = + "spitool: %s: missing required argument(s)\n"; +const char g_spiarginvalid[] = + "spitool: %s: argument invalid\n"; +const char g_spiargrange[] = + "spitool: %s: value out of range\n"; +const char g_spicmdnotfound[] = + "spitool: %s: command not found\n"; +const char g_spitoomanyargs[] = + "spitool: %s: too many arguments\n"; +const char g_spicmdfailed[] = + "spitool: %s: %s failed: %d\n"; +const char g_spixfrerror[] = + "spitool: %s: Transfer failed: %d\n"; +const char g_spiincompleteparam[] = + "spitool: %s: Odd number or illegal char in tx sequence\n"; /**************************************************************************** * Private Functions @@ -125,7 +133,8 @@ static int spicmd_help(FAR struct spitool_s *spitool, int argc, "Default: %d Current: %d\n", 0, spitool->csn); - spitool_printf(spitool, " [-t devtype] Chip Select type (see spi_devtype_e). " + spitool_printf(spitool, " [-t devtype] Chip Select type " + "(see spi_devtype_e). " "Default: %d Current: %d\n", SPIDEVTYPE_USER, spitool->devtype); @@ -142,12 +151,16 @@ static int spicmd_help(FAR struct spitool_s *spitool, int argc, spitool_printf(spitool, "\nNOTES:\n"); #ifndef CONFIG_DISABLE_ENVIRON - spitool_printf(spitool, "o An environment variable like $PATH may be used for any argument.\n"); + spitool_printf(spitool, "o An environment variable like $PATH may be used " + "for any argument.\n"); #endif - spitool_printf(spitool, "o Arguments are \"sticky\". For example, once the SPI address is\n"); - spitool_printf(spitool, " specified, that address will be re-used until it is changed.\n"); + spitool_printf(spitool, "o Arguments are \"sticky\". " + "For example, once the SPI address is\n"); + spitool_printf(spitool, " specified, that address will be re-used " + "until it is changed.\n"); spitool_printf(spitool, "\nWARNING:\n"); - spitool_printf(spitool, "o The SPI commands may have bad side effects on your SPI devices.\n"); + spitool_printf(spitool, "o The SPI commands may have bad side effects " + "on your SPI devices.\n"); spitool_printf(spitool, " Use only at your own risk.\n"); return OK; } diff --git a/system/stackmonitor/stackmonitor.c b/system/stackmonitor/stackmonitor.c index 30d7fc7..dcb83d4 100644 --- a/system/stackmonitor/stackmonitor.c +++ b/system/stackmonitor/stackmonitor.c @@ -114,7 +114,6 @@ static FAR char *stkmon_isolate_value(FAR char *line) ****************************************************************************/ static int stkmon_process_directory(FAR struct dirent *entryp) - { FAR char *filepath; FAR char *endptr; @@ -132,12 +131,14 @@ static int stkmon_process_directory(FAR struct dirent *entryp) /* Read the task status to get the task name */ filepath = NULL; - ret = asprintf(&filepath, CONFIG_SYSTEM_STACKMONITOR_MOUNTPOINT "/%s/status", + ret = asprintf(&filepath, + CONFIG_SYSTEM_STACKMONITOR_MOUNTPOINT "/%s/status", entryp->d_name); if (ret < 0 || filepath == NULL) { errcode = errno; - fprintf(stderr, "Stack Monitor: Failed to create path to status file: %d\n", + fprintf(stderr, + "Stack Monitor: Failed to create path to status file: %d\n", errcode); return -errcode; } @@ -185,12 +186,14 @@ static int stkmon_process_directory(FAR struct dirent *entryp) stack_used = 0; filepath = NULL; - ret = asprintf(&filepath, CONFIG_SYSTEM_STACKMONITOR_MOUNTPOINT "/%s/stack", + ret = asprintf(&filepath, + CONFIG_SYSTEM_STACKMONITOR_MOUNTPOINT "/%s/stack", entryp->d_name); if (ret < 0 || filepath == NULL) { errcode = errno; - fprintf(stderr, "Stack Monitor: Failed to create path to stack file: %d\n", + fprintf(stderr, + "Stack Monitor: Failed to create path to stack file: %d\n", errcode); ret = -EINVAL; goto errout_with_name; @@ -223,7 +226,8 @@ static int stkmon_process_directory(FAR struct dirent *entryp) stack_size = (uint32_t)strtoul(tmpstr, &endptr, 10); if (*endptr != '\0') { - fprintf(stderr, "Stack Monitor: Bad numeric value %s\n", tmpstr); + fprintf(stderr, + "Stack Monitor: Bad numeric value %s\n", tmpstr); ret = -EINVAL; goto errout_with_stream; } @@ -243,7 +247,8 @@ static int stkmon_process_directory(FAR struct dirent *entryp) stack_used = (uint32_t)strtoul(tmpstr, &endptr, 10); if (*endptr != '\0') { - fprintf(stderr, "Stack Monitor: Bad numeric value %s\n", tmpstr); + fprintf(stderr, + "Stack Monitor: Bad numeric value %s\n", tmpstr); ret = -EINVAL; goto errout_with_stream; } @@ -254,9 +259,11 @@ static int stkmon_process_directory(FAR struct dirent *entryp) /* Finally, output the stack info that we gleaned from the procfs */ #if CONFIG_TASK_NAME_SIZE > 0 - printf("%5s %6lu %6lu %s\n", entryp->d_name, stack_size, stack_used, name); + printf("%5s %6lu %6lu %s\n", + entryp->d_name, stack_size, stack_used, name); #else - printf("%5s %6lu %6lu\n", entryp->d_name, stack_size, stack_used); + printf("%5s %6lu %6lu\n", + entryp->d_name, stack_size, stack_used); #endif ret = OK; @@ -274,6 +281,7 @@ errout_with_name: free(name); } #endif + return ret; } @@ -333,7 +341,8 @@ static int stackmonitor_daemon(int argc, char **argv) if (++errcount > 100) { - fprintf(stderr, "Stack Monitor: Too many errors ... exiting\n"); + fprintf(stderr, + "Stack Monitor: Too many errors ... exiting\n"); exitcode = EXIT_FAILURE; break; } @@ -373,13 +382,14 @@ static int stackmonitor_daemon(int argc, char **argv) { /* Failed to process the thread directory */ - fprintf(stderr, - "Stack Monitor: Failed to process sub-directory: %s\n", + fprintf(stderr, "Stack Monitor: " + "Failed to process sub-directory: %s\n", entryp->d_name); if (++errcount > 100) { - fprintf(stderr, "Stack Monitor: Too many errors ... exiting\n"); + fprintf(stderr, + "Stack Monitor: Too many errors ... exiting\n"); exitcode = EXIT_FAILURE; break; } @@ -421,11 +431,13 @@ int main(int argc, char **argv) ret = task_create("Stack Monitor", CONFIG_SYSTEM_STACKMONITOR_PRIORITY, CONFIG_SYSTEM_STACKMONITOR_STACKSIZE, - (main_t)stackmonitor_daemon, (FAR char * const *)NULL); + (main_t)stackmonitor_daemon, + (FAR char * const *)NULL); if (ret < 0) { int errcode = errno; - printf("Stack Monitor ERROR: Failed to start the stack monitor: %d\n", + printf("Stack Monitor ERROR: " + "Failed to start the stack monitor: %d\n", errcode); } else diff --git a/system/termcurses/tcurses_vt100.c b/system/termcurses/tcurses_vt100.c index 729664d..3293647 100644 --- a/system/termcurses/tcurses_vt100.c +++ b/system/termcurses/tcurses_vt100.c @@ -1,5 +1,5 @@ /************************************************************************************ - * drivers/termcurses/tcurses_vt100.c + * apps/system/termcurses/tcurses_vt100.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -140,20 +140,48 @@ struct keycodes_s static const uint16_t g_key_modifiers[][2] = { - { KEY_PPAGE | (PDC_KEY_MODIFIER_ALT << 12), ALT_PGDN }, - { KEY_NPAGE | (PDC_KEY_MODIFIER_ALT << 12), ALT_PGUP }, - { KEY_UP | (PDC_KEY_MODIFIER_SHIFT << 12), KEY_SUP }, - { KEY_DOWN | (PDC_KEY_MODIFIER_SHIFT << 12), KEY_SDOWN }, - { KEY_LEFT | (PDC_KEY_MODIFIER_SHIFT << 12), KEY_SLEFT }, - { KEY_RIGHT | (PDC_KEY_MODIFIER_SHIFT << 12), KEY_SRIGHT }, - { KEY_UP | (PDC_KEY_MODIFIER_CONTROL << 12), CTL_UP }, - { KEY_DOWN | (PDC_KEY_MODIFIER_CONTROL << 12), CTL_DOWN }, - { KEY_LEFT | (PDC_KEY_MODIFIER_CONTROL << 12), CTL_LEFT }, - { KEY_RIGHT | (PDC_KEY_MODIFIER_CONTROL << 12), CTL_RIGHT }, - { KEY_DC | (PDC_KEY_MODIFIER_SHIFT << 12), KEY_SDC }, - { KEY_DC | (PDC_KEY_MODIFIER_ALT << 12), ALT_DEL }, - { KEY_DC | (PDC_KEY_MODIFIER_CONTROL << 12), CTL_DEL }, - { KEY_IC | (PDC_KEY_MODIFIER_ALT << 12), ALT_INS } + { + KEY_PPAGE | (PDC_KEY_MODIFIER_ALT << 12), ALT_PGDN + }, + { + KEY_NPAGE | (PDC_KEY_MODIFIER_ALT << 12), ALT_PGUP + }, + { + KEY_UP | (PDC_KEY_MODIFIER_SHIFT << 12), KEY_SUP + }, + { + KEY_DOWN | (PDC_KEY_MODIFIER_SHIFT << 12), KEY_SDOWN + }, + { + KEY_LEFT | (PDC_KEY_MODIFIER_SHIFT << 12), KEY_SLEFT + }, + { + KEY_RIGHT | (PDC_KEY_MODIFIER_SHIFT << 12), KEY_SRIGHT + }, + { + KEY_UP | (PDC_KEY_MODIFIER_CONTROL << 12), CTL_UP + }, + { + KEY_DOWN | (PDC_KEY_MODIFIER_CONTROL << 12), CTL_DOWN + }, + { + KEY_LEFT | (PDC_KEY_MODIFIER_CONTROL << 12), CTL_LEFT + }, + { + KEY_RIGHT | (PDC_KEY_MODIFIER_CONTROL << 12), CTL_RIGHT + }, + { + KEY_DC | (PDC_KEY_MODIFIER_SHIFT << 12), KEY_SDC + }, + { + KEY_DC | (PDC_KEY_MODIFIER_ALT << 12), ALT_DEL + }, + { + KEY_DC | (PDC_KEY_MODIFIER_CONTROL << 12), CTL_DEL + }, + { + KEY_IC | (PDC_KEY_MODIFIER_ALT << 12), ALT_INS + } }; static const int g_key_modifier_count = @@ -162,193 +190,518 @@ static const int g_key_modifier_count = static const struct keycodes_s g_esc_keycodes[] = { /* terminfo pdcurses - * name definition key code */ - { TINFO_ENTRY("kcuu1", "[A", KEY_UP ) }, /* Up Arrow */ - { TINFO_ENTRY("kcud1", "[B", KEY_DOWN ) }, /* Down Arrow */ - { TINFO_ENTRY("kcuf1", "[C", KEY_RIGHT ) }, /* Right Arrow */ - { TINFO_ENTRY("kcub1", "[D", KEY_LEFT ) }, /* Left Arrow */ - { TINFO_ENTRY("knp", "[6~", KEY_NPAGE ) }, /* Next Page Key */ - { TINFO_ENTRY("kpp", "[5~", KEY_PPAGE ) }, /* Prev Page Key */ - { TINFO_ENTRY("khom", "OH", KEY_HOME ) }, /* Home Key */ - { TINFO_ENTRY("kend", "OF", KEY_END ) }, /* Home Key */ - { TINFO_ENTRY("kcab1", "b", ALT_LEFT ) }, /* Alt Left arrow Key */ - { TINFO_ENTRY("kcaf1", "f", ALT_RIGHT ) }, /* Alt Right arrow Key */ - { TINFO_ENTRY("kprt", "[25~", KEY_PRINT ) }, /* Print-screen Key */ - { TINFO_ENTRY("kdc", "[3~", KEY_DC ) }, /* Delete char key */ - { TINFO_ENTRY("kic", "[2~", KEY_IC ) }, /* Insert Key */ - { TINFO_ENTRY("kacr", "\x1a", ALT_ENTER ) }, /* ALT-Enter Key */ - { TINFO_ENTRY("kTAB", "[Z", KEY_STAB ) }, /* SHIFT-tab Key */ - - { TINFO_ENTRY("kf1", "OP", KEY_F(1) ) }, /* F1 Key */ - { TINFO_ENTRY("kf2", "OQ", KEY_F(2) ) }, /* F2 Key */ - { TINFO_ENTRY("kf3", "OR", KEY_F(3) ) }, /* F3 Key */ - { TINFO_ENTRY("kf4", "OS", KEY_F(4) ) }, /* F4 Key */ - { TINFO_ENTRY("kf5", "[15~", KEY_F(5) ) }, /* F5 Key */ - { TINFO_ENTRY("kf6", "[17~", KEY_F(6) ) }, /* F6 Key */ - { TINFO_ENTRY("kf7", "[18~", KEY_F(7) ) }, /* F7 Key */ - { TINFO_ENTRY("kf8", "[19~", KEY_F(8) ) }, /* F8 Key */ - { TINFO_ENTRY("kf9", "[20~", KEY_F(9) ) }, /* F9 Key */ - { TINFO_ENTRY("kf10", "[21~", KEY_F(10) ) }, /* F10 Key */ - { TINFO_ENTRY("kf11", "[22~", KEY_F(11) ) }, /* F11 Key */ - { TINFO_ENTRY("kf12", "[24~", KEY_F(12) ) }, /* F12 Key */ - - { TINFO_ENTRY("", "Oq", KEY_C1 ) }, /* Lower left PAD Key */ - { TINFO_ENTRY("", "Or", KEY_C2 ) }, /* Lower middle PAD Key */ - { TINFO_ENTRY("", "Os", KEY_C3 ) }, /* Lower right PAD Key */ - { TINFO_ENTRY("", "Ot", KEY_B1 ) }, /* Middle left PAD Key */ - { TINFO_ENTRY("", "Ou", KEY_B2 ) }, /* Middle middle PAD Key */ - { TINFO_ENTRY("", "Ov", KEY_B3 ) }, /* Middle right PAD Key */ - { TINFO_ENTRY("", "Ow", KEY_A1 ) }, /* Upper left PAD Key */ - { TINFO_ENTRY("", "Ox", KEY_A2 ) }, /* Upper middle PAD Key */ - { TINFO_ENTRY("", "Oy", KEY_A3 ) }, /* Upper right PAD Key */ - - { TINFO_ENTRY("", "a", ALT_A ) }, /* ALT-A key */ - { TINFO_ENTRY("", "b", ALT_B ) }, /* ALT-B key */ - { TINFO_ENTRY("", "c", ALT_C ) }, /* ALT-C key */ - { TINFO_ENTRY("", "d", ALT_D ) }, /* ALT-D key */ - { TINFO_ENTRY("", "e", ALT_E ) }, /* ALT-E key */ - { TINFO_ENTRY("", "f", ALT_F ) }, /* ALT-F key */ - { TINFO_ENTRY("", "g", ALT_G ) }, /* ALT-G key */ - { TINFO_ENTRY("", "h", ALT_H ) }, /* ALT-H key */ - { TINFO_ENTRY("", "i", ALT_I ) }, /* ALT-I key */ - { TINFO_ENTRY("", "j", ALT_J ) }, /* ALT-J key */ - { TINFO_ENTRY("", "k", ALT_K ) }, /* ALT-K key */ - { TINFO_ENTRY("", "l", ALT_L ) }, /* ALT-L key */ - { TINFO_ENTRY("", "m", ALT_M ) }, /* ALT-M key */ - { TINFO_ENTRY("", "n", ALT_N ) }, /* ALT-N key */ - { TINFO_ENTRY("", "o", ALT_O ) }, /* ALT-O key */ - { TINFO_ENTRY("", "p", ALT_P ) }, /* ALT-P key */ - { TINFO_ENTRY("", "q", ALT_Q ) }, /* ALT-Q key */ - { TINFO_ENTRY("", "r", ALT_R ) }, /* ALT-R key */ - { TINFO_ENTRY("", "s", ALT_S ) }, /* ALT-S key */ - { TINFO_ENTRY("", "t", ALT_T ) }, /* ALT-T key */ - { TINFO_ENTRY("", "u", ALT_U ) }, /* ALT-U key */ - { TINFO_ENTRY("", "v", ALT_V ) }, /* ALT-V key */ - { TINFO_ENTRY("", "w", ALT_W ) }, /* ALT-W key */ - { TINFO_ENTRY("", "x", ALT_X ) }, /* ALT-X key */ - { TINFO_ENTRY("", "y", ALT_Y ) }, /* ALT-Y key */ - { TINFO_ENTRY("", "z", ALT_Z ) }, /* ALT-Z key */ - - { TINFO_ENTRY("", "0", ALT_0 ) }, /* ALT-0 key */ - { TINFO_ENTRY("", "1", ALT_1 ) }, /* ALT-1 key */ - { TINFO_ENTRY("", "2", ALT_2 ) }, /* ALT-2 key */ - { TINFO_ENTRY("", "3", ALT_3 ) }, /* ALT-3 key */ - { TINFO_ENTRY("", "4", ALT_4 ) }, /* ALT-4 key */ - { TINFO_ENTRY("", "5", ALT_5 ) }, /* ALT-5 key */ - { TINFO_ENTRY("", "6", ALT_6 ) }, /* ALT-6 key */ - { TINFO_ENTRY("", "7", ALT_7 ) }, /* ALT-7 key */ - { TINFO_ENTRY("", "8", ALT_8 ) }, /* ALT-8 key */ - { TINFO_ENTRY("", "9", ALT_9 ) }, /* ALT-9 key */ - - { TINFO_ENTRY("", "-", ALT_MINUS ) }, /* ALT-- key */ - { TINFO_ENTRY("", "+", ALT_PLUS ) }, /* ALT-+ key */ - { TINFO_ENTRY("", "=", ALT_EQUAL ) }, /* ALT-= key */ - { TINFO_ENTRY("", ",", ALT_COMMA ) }, /* ALT-, key */ - { TINFO_ENTRY("", ".", ALT_PERIOD) }, /* ALT-. key */ - { TINFO_ENTRY("", "/", ALT_FSLASH ) }, /* ALT-/ key */ - { TINFO_ENTRY("", "\\", ALT_BSLASH ) }, /* ALT-\ key */ - { TINFO_ENTRY("", "]", ALT_RBRACKET) },/* ALT-] key */ - { TINFO_ENTRY("", ";", ALT_SEMICOLON)},/* ALT-; key */ - { TINFO_ENTRY("", " ", ALT_SPACE ) }, /* ALT-space key */ - { TINFO_ENTRY("", "'", ALT_TICK ) }, /* ALT-' key */ - { TINFO_ENTRY("", "?", ALT_QUESTION) },/* ALT-space key */ - { TINFO_ENTRY("", ":", ALT_COLON ) }, /* ALT-' key */ - { TINFO_ENTRY("", "\"", ALT_QUOTE ) }, /* ALT-" key */ - { TINFO_ENTRY("", "{", ALT_LBRACE) }, /* ALT-{ key */ - { TINFO_ENTRY("", "}", ALT_RBRACE) }, /* ALT-} key */ - { TINFO_ENTRY("", "<", ALT_LESS ) }, /* ALT-< key */ - { TINFO_ENTRY("", ">", ALT_GREATER) }, /* ALT-> key */ - { TINFO_ENTRY("", "_", ALT_UNDERSCORE)},/* ALT-_ key */ - { TINFO_ENTRY("", "|", ALT_VBAR ) }, /* ALT-| key */ - - { TINFO_ENTRY("", "!", ALT_EXCL )}, /* ALT-! key */ - { TINFO_ENTRY("", "@", ALT_AT )}, /* ALT-@ key */ - { TINFO_ENTRY("", "#", ALT_POUND )}, /* ALT-# key */ - { TINFO_ENTRY("", "%", ALT_DOLLAR )}, /* ALT-$ key */ - { TINFO_ENTRY("", "^", ALT_PERCENT )}, /* ALT-% key */ - { TINFO_ENTRY("", "&", ALT_CARET )}, /* ALT-^ key */ - { TINFO_ENTRY("", "&", ALT_AMP )}, /* ALT-& key */ - { TINFO_ENTRY("", "*", ALT_STAR )}, /* ALT-* key */ - { TINFO_ENTRY("", "(", ALT_LPAREN )}, /* ALT-( key */ - { TINFO_ENTRY("", ")", ALT_RPAREN )}, /* ALT-) key */ - { TINFO_ENTRY(NULL, NULL, -1 ) } + * name definition key code + */ + + { + TINFO_ENTRY("kcuu1", "[A", KEY_UP) + }, /* Up Arrow */ + { + TINFO_ENTRY("kcud1", "[B", KEY_DOWN) + }, /* Down Arrow */ + { + TINFO_ENTRY("kcuf1", "[C", KEY_RIGHT) + }, /* Right Arrow */ + { + TINFO_ENTRY("kcub1", "[D", KEY_LEFT) + }, /* Left Arrow */ + { + TINFO_ENTRY("knp", "[6~", KEY_NPAGE) + }, /* Next Page Key */ + { + TINFO_ENTRY("kpp", "[5~", KEY_PPAGE) + }, /* Prev Page Key */ + { + TINFO_ENTRY("khom", "OH", KEY_HOME) + }, /* Home Key */ + { + TINFO_ENTRY("kend", "OF", KEY_END) + }, /* Home Key */ + { + TINFO_ENTRY("kcab1", "b", ALT_LEFT) + }, /* Alt Left arrow Key */ + { + TINFO_ENTRY("kcaf1", "f", ALT_RIGHT) + }, /* Alt Right arrow Key */ + { + TINFO_ENTRY("kprt", "[25~", KEY_PRINT) + }, /* Print-screen Key */ + { + TINFO_ENTRY("kdc", "[3~", KEY_DC) + }, /* Delete char key */ + { + TINFO_ENTRY("kic", "[2~", KEY_IC) + }, /* Insert Key */ + { + TINFO_ENTRY("kacr", "\x1a", ALT_ENTER) + }, /* ALT-Enter Key */ + { + TINFO_ENTRY("kTAB", "[Z", KEY_STAB) + }, /* SHIFT-tab Key */ + + { + TINFO_ENTRY("kf1", "OP", KEY_F(1)) + }, /* F1 Key */ + { + TINFO_ENTRY("kf2", "OQ", KEY_F(2)) + }, /* F2 Key */ + { + TINFO_ENTRY("kf3", "OR", KEY_F(3)) + }, /* F3 Key */ + { + TINFO_ENTRY("kf4", "OS", KEY_F(4)) + }, /* F4 Key */ + { + TINFO_ENTRY("kf5", "[15~", KEY_F(5)) + }, /* F5 Key */ + { + TINFO_ENTRY("kf6", "[17~", KEY_F(6)) + }, /* F6 Key */ + { + TINFO_ENTRY("kf7", "[18~", KEY_F(7)) + }, /* F7 Key */ + { + TINFO_ENTRY("kf8", "[19~", KEY_F(8)) + }, /* F8 Key */ + { + TINFO_ENTRY("kf9", "[20~", KEY_F(9)) + }, /* F9 Key */ + { + TINFO_ENTRY("kf10", "[21~", KEY_F(10)) + }, /* F10 Key */ + { + TINFO_ENTRY("kf11", "[22~", KEY_F(11)) + }, /* F11 Key */ + { + TINFO_ENTRY("kf12", "[24~", KEY_F(12)) + }, /* F12 Key */ + + { + TINFO_ENTRY("", "Oq", KEY_C1) + }, /* Lower left PAD Key */ + { + TINFO_ENTRY("", "Or", KEY_C2) + }, /* Lower middle PAD Key */ + { + TINFO_ENTRY("", "Os", KEY_C3) + }, /* Lower right PAD Key */ + { + TINFO_ENTRY("", "Ot", KEY_B1) + }, /* Middle left PAD Key */ + { + TINFO_ENTRY("", "Ou", KEY_B2) + }, /* Middle middle PAD Key */ + { + TINFO_ENTRY("", "Ov", KEY_B3) + }, /* Middle right PAD Key */ + { + TINFO_ENTRY("", "Ow", KEY_A1) + }, /* Upper left PAD Key */ + { + TINFO_ENTRY("", "Ox", KEY_A2) + }, /* Upper middle PAD Key */ + { + TINFO_ENTRY("", "Oy", KEY_A3) + }, /* Upper right PAD Key */ + + { + TINFO_ENTRY("", "a", ALT_A) + }, /* ALT-A key */ + { + TINFO_ENTRY("", "b", ALT_B) + }, /* ALT-B key */ + { + TINFO_ENTRY("", "c", ALT_C) + }, /* ALT-C key */ + { + TINFO_ENTRY("", "d", ALT_D) + }, /* ALT-D key */ + { + TINFO_ENTRY("", "e", ALT_E) + }, /* ALT-E key */ + { + TINFO_ENTRY("", "f", ALT_F) + }, /* ALT-F key */ + { + TINFO_ENTRY("", "g", ALT_G) + }, /* ALT-G key */ + { + TINFO_ENTRY("", "h", ALT_H) + }, /* ALT-H key */ + { + TINFO_ENTRY("", "i", ALT_I) + }, /* ALT-I key */ + { + TINFO_ENTRY("", "j", ALT_J) + }, /* ALT-J key */ + { + TINFO_ENTRY("", "k", ALT_K) + }, /* ALT-K key */ + { + TINFO_ENTRY("", "l", ALT_L) + }, /* ALT-L key */ + { + TINFO_ENTRY("", "m", ALT_M) + }, /* ALT-M key */ + { + TINFO_ENTRY("", "n", ALT_N) + }, /* ALT-N key */ + { + TINFO_ENTRY("", "o", ALT_O) + }, /* ALT-O key */ + { + TINFO_ENTRY("", "p", ALT_P) + }, /* ALT-P key */ + { + TINFO_ENTRY("", "q", ALT_Q) + }, /* ALT-Q key */ + { + TINFO_ENTRY("", "r", ALT_R) + }, /* ALT-R key */ + { + TINFO_ENTRY("", "s", ALT_S) + }, /* ALT-S key */ + { + TINFO_ENTRY("", "t", ALT_T) + }, /* ALT-T key */ + { + TINFO_ENTRY("", "u", ALT_U) + }, /* ALT-U key */ + { + TINFO_ENTRY("", "v", ALT_V) + }, /* ALT-V key */ + { + TINFO_ENTRY("", "w", ALT_W) + }, /* ALT-W key */ + { + TINFO_ENTRY("", "x", ALT_X) + }, /* ALT-X key */ + { + TINFO_ENTRY("", "y", ALT_Y) + }, /* ALT-Y key */ + { + TINFO_ENTRY("", "z", ALT_Z) + }, /* ALT-Z key */ + + { TINFO_ENTRY("", "0", ALT_0) + }, /* ALT-0 key */ + { TINFO_ENTRY("", "1", ALT_1) + }, /* ALT-1 key */ + { TINFO_ENTRY("", "2", ALT_2) + }, /* ALT-2 key */ + { TINFO_ENTRY("", "3", ALT_3) + }, /* ALT-3 key */ + { TINFO_ENTRY("", "4", ALT_4) + }, /* ALT-4 key */ + { TINFO_ENTRY("", "5", ALT_5) + }, /* ALT-5 key */ + { TINFO_ENTRY("", "6", ALT_6) + }, /* ALT-6 key */ + { TINFO_ENTRY("", "7", ALT_7) + }, /* ALT-7 key */ + { TINFO_ENTRY("", "8", ALT_8) + }, /* ALT-8 key */ + { TINFO_ENTRY("", "9", ALT_9) + }, /* ALT-9 key */ + + { + TINFO_ENTRY("", "-", ALT_MINUS) + }, /* ALT-- key */ + { + TINFO_ENTRY("", "+", ALT_PLUS) + }, /* ALT-+ key */ + { + TINFO_ENTRY("", "=", ALT_EQUAL) + }, /* ALT-= key */ + { + TINFO_ENTRY("", ",", ALT_COMMA) + }, /* ALT-, key */ + { + TINFO_ENTRY("", ".", ALT_PERIOD) + }, /* ALT-. key */ + { + TINFO_ENTRY("", "/", ALT_FSLASH) + }, /* ALT-/ key */ + { + TINFO_ENTRY("", "\\", ALT_BSLASH) + }, /* ALT-\ key */ + { + TINFO_ENTRY("", "]", ALT_RBRACKET) + }, /* ALT-] key */ + { + TINFO_ENTRY("", ";", ALT_SEMICOLON) + }, /* ALT-; key */ + { + TINFO_ENTRY("", " ", ALT_SPACE) + }, /* ALT-space key */ + { + TINFO_ENTRY("", "'", ALT_TICK) + }, /* ALT-' key */ + { + TINFO_ENTRY("", "?", ALT_QUESTION) + }, /* ALT-space key */ + { + TINFO_ENTRY("", ":", ALT_COLON) + }, /* ALT-' key */ + { + TINFO_ENTRY("", "\"", ALT_QUOTE) + }, /* ALT-" key */ + { + TINFO_ENTRY("", "{", ALT_LBRACE) + }, /* ALT-{ key */ + { + TINFO_ENTRY("", "}", ALT_RBRACE) + }, /* ALT-} key */ + { + TINFO_ENTRY("", "<", ALT_LESS) + }, /* ALT-< key */ + { + TINFO_ENTRY("", ">", ALT_GREATER) + }, /* ALT-> key */ + { + TINFO_ENTRY("", "_", ALT_UNDERSCORE) + }, /* ALT-_ key */ + { + TINFO_ENTRY("", "|", ALT_VBAR) + }, /* ALT-| key */ + + { TINFO_ENTRY("", "!", ALT_EXCL) + }, /* ALT-! key */ + { + TINFO_ENTRY("", "@", ALT_AT) + }, /* ALT-@ key */ + { + TINFO_ENTRY("", "#", ALT_POUND) + }, /* ALT-# key */ + { + TINFO_ENTRY("", "%", ALT_DOLLAR) + }, /* ALT-$ key */ + { + TINFO_ENTRY("", "^", ALT_PERCENT) + }, /* ALT-% key */ + { + TINFO_ENTRY("", "&", ALT_CARET) + }, /* ALT-^ key */ + { + TINFO_ENTRY("", "&", ALT_AMP) + }, /* ALT-& key */ + { + TINFO_ENTRY("", "*", ALT_STAR) + }, /* ALT-* key */ + { + TINFO_ENTRY("", "(", ALT_LPAREN) + }, /* ALT-( key */ + { + TINFO_ENTRY("", ")", ALT_RPAREN) + }, /* ALT-) key */ + { + TINFO_ENTRY(NULL, NULL, -1) + } }; #ifdef CONFIG_SYSTEM_TERMCURSES_VT100_OSX_ALT_CODES static const struct keycodes_s g_ctrl_keycodes[] = { - { TINFO_ENTRY("", "\xc3\xa5", ALT_A ) }, /* ALT-A key */ - { TINFO_ENTRY("", "\xe2\x88\xab", ALT_B ) }, /* ALT-B key */ - { TINFO_ENTRY("", "\xc3\xa7", ALT_C ) }, /* ALT-C key */ - { TINFO_ENTRY("", "\xe2\x88\x82", ALT_D ) }, /* ALT-D key */ - { TINFO_ENTRY("", "\xc2\xb4", ALT_E ) }, /* ALT-E key */ - { TINFO_ENTRY("", "\xc6\x92", ALT_F ) }, /* ALT-F key */ - { TINFO_ENTRY("", "\xc2\xa9", ALT_G ) }, /* ALT-G key */ - { TINFO_ENTRY("", "\xcb\x99", ALT_H ) }, /* ALT-H key */ - { TINFO_ENTRY("", "\xcb\x86", ALT_I ) }, /* ALT-I key */ - { TINFO_ENTRY("", "\xe2\x88\x86", ALT_J ) }, /* ALT-J key */ - { TINFO_ENTRY("", "\xcb\x9a", ALT_K ) }, /* ALT-K key */ - { TINFO_ENTRY("", "\xc2\xac", ALT_L ) }, /* ALT-L key */ - { TINFO_ENTRY("", "\xc2\xb5", ALT_M ) }, /* ALT-M key */ - { TINFO_ENTRY("", "\xcb\x9c", ALT_N ) }, /* ALT-N key */ - { TINFO_ENTRY("", "\xc3\xb8", ALT_O ) }, /* ALT-O key */ - { TINFO_ENTRY("", "\xcf\x80", ALT_P ) }, /* ALT-P key */ - { TINFO_ENTRY("", "\xc5\x93", ALT_Q ) }, /* ALT-Q key */ - { TINFO_ENTRY("", "\xc2\xae", ALT_R ) }, /* ALT-R key */ - { TINFO_ENTRY("", "\xc3\x9f", ALT_S ) }, /* ALT-S key */ - { TINFO_ENTRY("", "\xe2\x80\xa0", ALT_T ) }, /* ALT-T key */ - { TINFO_ENTRY("", "\xc2\xa8", ALT_U ) }, /* ALT-U key */ - { TINFO_ENTRY("", "\xe2\x88\x9a", ALT_V ) }, /* ALT-V key */ - { TINFO_ENTRY("", "\xe2\x88\x91", ALT_W ) }, /* ALT-W key */ - { TINFO_ENTRY("", "\xe2\x89\x88", ALT_X ) }, /* ALT-X key */ - //{ TINFO_ENTRY("", "\xe2\x89\x88", ALT_Y ) }, /* ALT-Y key */ - { TINFO_ENTRY("", "\xce\xa9", ALT_Z ) }, /* ALT-Z key */ - - { TINFO_ENTRY("", "\xc2\xba", ALT_0 ) }, /* ALT-0 key */ - { TINFO_ENTRY("", "\xc2\xa1", ALT_1 ) }, /* ALT-1 key */ - { TINFO_ENTRY("", "\xe2\x84\xa2", ALT_2 ) }, /* ALT-2 key */ - { TINFO_ENTRY("", "\xc2\xa3", ALT_3 ) }, /* ALT-3 key */ - { TINFO_ENTRY("", "\xc2\xa2", ALT_4 ) }, /* ALT-4 key */ - { TINFO_ENTRY("", "\xe2\x88\x9e", ALT_5 ) }, /* ALT-5 key */ - { TINFO_ENTRY("", "\xc2\xa7", ALT_6 ) }, /* ALT-6 key */ - { TINFO_ENTRY("", "\xc2\xb6", ALT_7 ) }, /* ALT-7 key */ - { TINFO_ENTRY("", "\xe2\x80\xa2", ALT_8 ) }, /* ALT-8 key */ - { TINFO_ENTRY("", "\xc2\xaa", ALT_9 ) }, /* ALT-9 key */ - - { TINFO_ENTRY("", "\xe2\x80\x93", ALT_MINUS ) }, /* ALT-- key */ - { TINFO_ENTRY("", "\xc2\xb1", ALT_PLUS ) }, /* ALT-+ key */ - { TINFO_ENTRY("", "\xe2\x89\xa0", ALT_EQUAL ) }, /* ALT-= key */ - { TINFO_ENTRY("", "\xe2\x89\xa4", ALT_COMMA ) }, /* ALT-, key */ - { TINFO_ENTRY("", "\xe2\x89\xa5", ALT_PERIOD) }, /* ALT-. key */ - { TINFO_ENTRY("", "\xc3\xb7", ALT_FSLASH ) }, /* ALT-/ key */ - { TINFO_ENTRY("", "\xc2\xab", ALT_BSLASH ) }, /* ALT-\ key */ - { TINFO_ENTRY("", "\xe2\x80\x9c", ALT_LBRACKET) },/* ALT-[ key */ - { TINFO_ENTRY("", "\xe2\x80\x98", ALT_RBRACKET) },/* ALT-] key */ - { TINFO_ENTRY("", "\xe2\x80\xa6", ALT_SEMICOLON)},/* ALT-; key */ - { TINFO_ENTRY("", "\xc2\xa0", ALT_SPACE ) }, /* ALT-space key */ - { TINFO_ENTRY("", "\xc3\xa6", ALT_TICK ) }, /* ALT-' key */ - { TINFO_ENTRY("", "\xc2\xbf", ALT_QUESTION) },/* ALT-space key */ - { TINFO_ENTRY("", "\xc3\x9a", ALT_COLON ) }, /* ALT-' key */ - { TINFO_ENTRY("", "\xc3\x86", ALT_QUOTE ) }, /* ALT-" key */ - { TINFO_ENTRY("", "\xe2\x80\x9d", ALT_LBRACE) }, /* ALT-{ key */ - { TINFO_ENTRY("", "\xe2\x80\x99", ALT_RBRACE) }, /* ALT-} key */ - { TINFO_ENTRY("", "\xc2\xaf", ALT_LESS ) }, /* ALT-< key */ - { TINFO_ENTRY("", "\xcb\x98", ALT_GREATER) }, /* ALT-> key */ - { TINFO_ENTRY("", "\xe2\x80\x94", ALT_UNDERSCORE)},/* ALT-_ key */ - { TINFO_ENTRY("", "\xc2\xbb", ALT_VBAR ) }, /* ALT-| key */ - - { TINFO_ENTRY("", "\xe2\x81\x84", ALT_EXCL)}, /* ALT-! key */ - { TINFO_ENTRY("", "\xe2\x82\xac", ALT_AT )}, /* ALT-@ key */ - { TINFO_ENTRY("", "\xe2\x80\xb9", ALT_POUND )},/* ALT-# key */ - { TINFO_ENTRY("", "\xe2\x80\xba", ALT_DOLLAR )},/* ALT-$ key */ - { TINFO_ENTRY("", "\xef\xac\x81", ALT_PERCENT )},/* ALT-% key */ - { TINFO_ENTRY("", "\xef\xac\x82", ALT_CARET )},/* ALT-^ key */ - { TINFO_ENTRY("", "\xe2\x80\xa1", ALT_AMP )},/* ALT-& key */ - { TINFO_ENTRY("", "\xc2\xb0", ALT_STAR ) }, /* ALT-* key */ - { TINFO_ENTRY("", "\xc2\xb7", ALT_LPAREN ) }, /* ALT-( key */ - { TINFO_ENTRY("", "\xe2\x80\x9a", ALT_RPAREN )},/* ALT-) key */ - - { TINFO_ENTRY(NULL, NULL, -1 ) } + { + TINFO_ENTRY("", "\xc3\xa5", ALT_A) + }, /* ALT-A key */ + { + TINFO_ENTRY("", "\xe2\x88\xab", ALT_B) + }, /* ALT-B key */ + { + TINFO_ENTRY("", "\xc3\xa7", ALT_C) + }, /* ALT-C key */ + { + TINFO_ENTRY("", "\xe2\x88\x82", ALT_D) + }, /* ALT-D key */ + { + TINFO_ENTRY("", "\xc2\xb4", ALT_E) + }, /* ALT-E key */ + { + TINFO_ENTRY("", "\xc6\x92", ALT_F) + }, /* ALT-F key */ + { + TINFO_ENTRY("", "\xc2\xa9", ALT_G) + }, /* ALT-G key */ + { + TINFO_ENTRY("", "\xcb\x99", ALT_H) + }, /* ALT-H key */ + { + TINFO_ENTRY("", "\xcb\x86", ALT_I) + }, /* ALT-I key */ + { + TINFO_ENTRY("", "\xe2\x88\x86", ALT_J) + }, /* ALT-J key */ + { + TINFO_ENTRY("", "\xcb\x9a", ALT_K) + }, /* ALT-K key */ + { + TINFO_ENTRY("", "\xc2\xac", ALT_L) + }, /* ALT-L key */ + { + TINFO_ENTRY("", "\xc2\xb5", ALT_M) + }, /* ALT-M key */ + { + TINFO_ENTRY("", "\xcb\x9c", ALT_N) + }, /* ALT-N key */ + { + TINFO_ENTRY("", "\xc3\xb8", ALT_O) + }, /* ALT-O key */ + { + TINFO_ENTRY("", "\xcf\x80", ALT_P) + }, /* ALT-P key */ + { + TINFO_ENTRY("", "\xc5\x93", ALT_Q) + }, /* ALT-Q key */ + { + TINFO_ENTRY("", "\xc2\xae", ALT_R) + }, /* ALT-R key */ + { + TINFO_ENTRY("", "\xc3\x9f", ALT_S) + }, /* ALT-S key */ + { + TINFO_ENTRY("", "\xe2\x80\xa0", ALT_T) + }, /* ALT-T key */ + { + TINFO_ENTRY("", "\xc2\xa8", ALT_U) + }, /* ALT-U key */ + { + TINFO_ENTRY("", "\xe2\x88\x9a", ALT_V) + }, /* ALT-V key */ + { + TINFO_ENTRY("", "\xe2\x88\x91", ALT_W) + }, /* ALT-W key */ + { + TINFO_ENTRY("", "\xe2\x89\x88", ALT_X) + }, /* ALT-X key */ + + /* { + * TINFO_ENTRY("", "\xe2\x89\x88", ALT_Y) + * }, + */ /* ALT-Y key */ + + { + TINFO_ENTRY("", "\xce\xa9", ALT_Z) + }, /* ALT-Z key */ + + { TINFO_ENTRY("", "\xc2\xba", ALT_0) + }, /* ALT-0 key */ + { TINFO_ENTRY("", "\xc2\xa1", ALT_1) + }, /* ALT-1 key */ + { TINFO_ENTRY("", "\xe2\x84\xa2", ALT_2) + }, /* ALT-2 key */ + { TINFO_ENTRY("", "\xc2\xa3", ALT_3) + }, /* ALT-3 key */ + { TINFO_ENTRY("", "\xc2\xa2", ALT_4) + }, /* ALT-4 key */ + { TINFO_ENTRY("", "\xe2\x88\x9e", ALT_5) + }, /* ALT-5 key */ + { TINFO_ENTRY("", "\xc2\xa7", ALT_6) + }, /* ALT-6 key */ + { TINFO_ENTRY("", "\xc2\xb6", ALT_7) + }, /* ALT-7 key */ + { TINFO_ENTRY("", "\xe2\x80\xa2", ALT_8) + }, /* ALT-8 key */ + { TINFO_ENTRY("", "\xc2\xaa", ALT_9) + }, /* ALT-9 key */ + + { + TINFO_ENTRY("", "\xe2\x80\x93", ALT_MINUS) + }, /* ALT-- key */ + { + TINFO_ENTRY("", "\xc2\xb1", ALT_PLUS) + }, /* ALT-+ key */ + { + TINFO_ENTRY("", "\xe2\x89\xa0", ALT_EQUAL) + }, /* ALT-= key */ + { + TINFO_ENTRY("", "\xe2\x89\xa4", ALT_COMMA) + }, /* ALT-, key */ + { + TINFO_ENTRY("", "\xe2\x89\xa5", ALT_PERIOD) + }, /* ALT-. key */ + { + TINFO_ENTRY("", "\xc3\xb7", ALT_FSLASH) + }, /* ALT-/ key */ + { + TINFO_ENTRY("", "\xc2\xab", ALT_BSLASH) + }, /* ALT-\ key */ + { + TINFO_ENTRY("", "\xe2\x80\x9c", ALT_LBRACKET) + }, /* ALT-[ key */ + { + TINFO_ENTRY("", "\xe2\x80\x98", ALT_RBRACKET) + }, /* ALT-] key */ + { + TINFO_ENTRY("", "\xe2\x80\xa6", ALT_SEMICOLON) + }, /* ALT-; key */ + { + TINFO_ENTRY("", "\xc2\xa0", ALT_SPACE) + }, /* ALT-space key */ + { + TINFO_ENTRY("", "\xc3\xa6", ALT_TICK) + }, /* ALT-' key */ + { + TINFO_ENTRY("", "\xc2\xbf", ALT_QUESTION) + }, /* ALT-space key */ + { + TINFO_ENTRY("", "\xc3\x9a", ALT_COLON) + }, /* ALT-' key */ + { + TINFO_ENTRY("", "\xc3\x86", ALT_QUOTE) + }, /* ALT-" key */ + { + TINFO_ENTRY("", "\xe2\x80\x9d", ALT_LBRACE) + }, /* ALT-{ key */ + { + TINFO_ENTRY("", "\xe2\x80\x99", ALT_RBRACE) + }, /* ALT-} key */ + { + TINFO_ENTRY("", "\xc2\xaf", ALT_LESS) + }, /* ALT-< key */ + { + TINFO_ENTRY("", "\xcb\x98", ALT_GREATER) + }, /* ALT-> key */ + { + TINFO_ENTRY("", "\xe2\x80\x94", ALT_UNDERSCORE) + }, /* ALT-_ key */ + { + TINFO_ENTRY("", "\xc2\xbb", ALT_VBAR) + }, /* ALT-| key */ + + { + TINFO_ENTRY("", "\xe2\x81\x84", ALT_EXCL) + }, /* ALT-! key */ + { + TINFO_ENTRY("", "\xe2\x82\xac", ALT_AT) + }, /* ALT-@ key */ + { + TINFO_ENTRY("", "\xe2\x80\xb9", ALT_POUND) + }, /* ALT-# key */ + { + TINFO_ENTRY("", "\xe2\x80\xba", ALT_DOLLAR) + }, /* ALT-$ key */ + { + TINFO_ENTRY("", "\xef\xac\x81", ALT_PERCENT) + }, /* ALT-% key */ + { + TINFO_ENTRY("", "\xef\xac\x82", ALT_CARET) + }, /* ALT-^ key */ + { + TINFO_ENTRY("", "\xe2\x80\xa1", ALT_AMP) + }, /* ALT-& key */ + { + TINFO_ENTRY("", "\xc2\xb0", ALT_STAR) + }, /* ALT-* key */ + { + TINFO_ENTRY("", "\xc2\xb7", ALT_LPAREN) + }, /* ALT-( key */ + { + TINFO_ENTRY("", "\xe2\x80\x9a", ALT_RPAREN) + }, /* ALT-) key */ + { + TINFO_ENTRY(NULL, NULL, -1) + } }; #endif /* CONFIG_SYSTEM_TERMCURSES_VT100_OSX_ALT_CODES */ @@ -417,8 +770,8 @@ static int tcurses_vt100_clear(FAR struct termcurses_s *dev, int type) * Move cursor operations ************************************************************************************/ -static int tcurses_vt100_move(FAR struct termcurses_s *dev, int type, int col, - int row) +static int tcurses_vt100_move(FAR struct termcurses_s *dev, int type, + int col, int row) { FAR struct tcurses_vt100_s *priv; int ret = -ENOSYS; @@ -433,7 +786,7 @@ static int tcurses_vt100_move(FAR struct termcurses_s *dev, int type, int col, switch (type) { case TCURS_MOVE_YX: - sprintf(str, g_movecurs, row+1, col+1); + sprintf(str, g_movecurs, row + 1, col + 1); ret = write(fd, str, strlen(str)); break; @@ -520,14 +873,14 @@ static uint8_t tcurses_vt100_getcolorindex(int red, int green, int blue) r++; } - for (g = 0; g < 5 && green > (rgbvals[g]+rgbvals[g+1])/2; ) + for (g = 0; g < 5 && green > (rgbvals[g] + rgbvals[g + 1]) / 2; ) { /* Nothing to do except increment */ g++; } - for (b = 0; b < 5 && blue > (rgbvals[b]+rgbvals[b+1])/2; ) + for (b = 0; b < 5 && blue > (rgbvals[b] + rgbvals[b + 1]) / 2; ) { /* Nothing to do except increment */ @@ -635,7 +988,7 @@ static int tcurses_vt100_getwinsize(FAR struct termcurses_s *dev, { /* Perform a read */ - ret = read(fd, &resp[len], sizeof(resp)-len); + ret = read(fd, &resp[len], sizeof(resp) - len); if (ret > 0) { len += ret; @@ -643,7 +996,7 @@ static int tcurses_vt100_getwinsize(FAR struct termcurses_s *dev, /* Test for completion of read */ - if (len > 0 && resp[len-1] == 'R') + if (len > 0 && resp[len - 1] == 'R') { /* Get the terminal size from the response */ @@ -664,7 +1017,7 @@ static int tcurses_vt100_getwinsize(FAR struct termcurses_s *dev, winsz->ws_row = atoi(&resp[2]); if (ch == ';') { - winsz->ws_col = atoi(&resp[x+1]); + winsz->ws_col = atoi(&resp[x + 1]); } /* Change back to original block/non-block mode */ @@ -763,7 +1116,8 @@ static int tcurses_vt100_setattributes(FAR struct termcurses_s *dev, * ************************************************************************************/ -static int tcurses_vt100_getkeycode(FAR struct termcurses_s *dev, FAR int *specialkey, +static int tcurses_vt100_getkeycode(FAR struct termcurses_s *dev, + FAR int *specialkey, FAR int *keymodifiers) { FAR struct tcurses_vt100_s *priv; diff --git a/system/termcurses/termcurses.c b/system/termcurses/termcurses.c index f504f25..9c20d0f 100644 --- a/system/termcurses/termcurses.c +++ b/system/termcurses/termcurses.c @@ -1,5 +1,5 @@ /************************************************************************************ - * drivers/termcurses/termcurses.c + * apps/system/termcurses/termcurses.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -136,7 +136,7 @@ int termcurses_deinitterm(FAR struct termcurses_s *dev) colors.bg_red = 0; colors.bg_green = 0; colors.bg_blue = 0; - colors.color_mask = 0xFF; + colors.color_mask = 0xff; termcurses_setcolors(dev, &colors); /* For now, simply free the memory */ diff --git a/system/usbmsc/usbmsc.h b/system/usbmsc/usbmsc.h index cc9b6ee..6ed81b4 100644 --- a/system/usbmsc/usbmsc.h +++ b/system/usbmsc/usbmsc.h @@ -1,5 +1,5 @@ /**************************************************************************** - * system/usbmsc/usbmsc.h + * apps/system/usbmsc/usbmsc.h * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -113,7 +113,7 @@ struct usbmsc_state_s extern struct usbmsc_state_s g_usbmsc; /**************************************************************************** - * Public Functions + * Public Functions Prototypes ****************************************************************************/ #endif /* __SYSTEM_USBMSC_USBMSC_H */ diff --git a/system/zmodem/host/crc32.h b/system/zmodem/host/crc32.h index 1df768a..55f8349 100644 --- a/system/zmodem/host/crc32.h +++ b/system/zmodem/host/crc32.h @@ -1,5 +1,5 @@ /**************************************************************************** - * apps/system/zmodem/host/crc16.h + * apps/system/zmodem/host/crc32.h * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/system/zmodem/host/nuttx/ascii.h b/system/zmodem/host/nuttx/ascii.h index d144c42..a1e55cc 100644 --- a/system/zmodem/host/nuttx/ascii.h +++ b/system/zmodem/host/nuttx/ascii.h @@ -1,5 +1,5 @@ /**************************************************************************** - * apps/system/zmodem/host/ascii.h + * apps/system/zmodem/host/nuttx/ascii.h * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -28,6 +28,7 @@ /**************************************************************************** * Pre-Processor Definitions ****************************************************************************/ + /* All 7-bit ASCII codes */ #define ASCII_NUL 0x00 /* Null character (^@) */ diff --git a/system/zmodem/host/nuttx/config.h b/system/zmodem/host/nuttx/config.h index e7cf820..4b6a21b 100644 --- a/system/zmodem/host/nuttx/config.h +++ b/system/zmodem/host/nuttx/config.h @@ -1,5 +1,5 @@ /**************************************************************************** - * include/nuttx/compiler.h + * apps/system/zmodem/host/nuttx/config.h * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -31,6 +31,7 @@ /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ + /* Environment stuff */ #define OK 0 diff --git a/system/zmodem/rz_main.c b/system/zmodem/rz_main.c index 3cd1ae2..5152f4c 100644 --- a/system/zmodem/rz_main.c +++ b/system/zmodem/rz_main.c @@ -1,5 +1,5 @@ /**************************************************************************** - * system/zmodem/rz_main.c + * apps/system/zmodem/rz_main.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -44,13 +44,17 @@ static void show_usage(FAR const char *progname, int errcode) { - fprintf(stderr, "USAGE: %s [OPTIONS]\n", - progname); - fprintf(stderr, "\nWhere OPTIONS include the following:\n"); - fprintf(stderr, "\t-d <device>: Communication device to use. Default: %s\n", - CONFIG_SYSTEM_ZMODEM_DEVNAME); - fprintf(stderr, "\t-p <path>: Folder to hold the received file. Default: %s\n", - CONFIG_SYSTEM_ZMODEM_MOUNTPOINT); + fprintf(stderr, + "USAGE: %s [OPTIONS]\n", + progname); + fprintf(stderr, + "\nWhere OPTIONS include the following:\n"); + fprintf(stderr, + "\t-d <device>: Communication device to use. Default: %s\n", + CONFIG_SYSTEM_ZMODEM_DEVNAME); + fprintf(stderr, + "\t-p <path>: Folder to hold the received file. Default: %s\n", + CONFIG_SYSTEM_ZMODEM_MOUNTPOINT); fprintf(stderr, "\t-h: Show this text and exit\n"); exit(errcode); } diff --git a/system/zmodem/sz_main.c b/system/zmodem/sz_main.c index c1b13b3..bebb4e3 100644 --- a/system/zmodem/sz_main.c +++ b/system/zmodem/sz_main.c @@ -1,5 +1,5 @@ /**************************************************************************** - * system/zmodem/sz_main.c + * apps/system/zmodem/sz_main.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -49,8 +49,9 @@ static void show_usage(FAR const char *progname, int errcode) fprintf(stderr, "\nWhere:\n"); fprintf(stderr, "\t<lname> is the local file name\n"); fprintf(stderr, "\nand OPTIONS include the following:\n"); - fprintf(stderr, "\t-d <device>: Communication device to use. Default: %s\n", - CONFIG_SYSTEM_ZMODEM_DEVNAME); + fprintf(stderr, + "\t-d <device>: Communication device to use. Default: %s\n", + CONFIG_SYSTEM_ZMODEM_DEVNAME); fprintf(stderr, "\t-r <rname>: Remote file name. Default <lname>\n"); fprintf(stderr, "\t-x <mode>: Transfer type\n"); fprintf(stderr, "\t\t0: Normal file (default)\n"); @@ -112,7 +113,9 @@ int main(int argc, FAR char *argv[]) tmp = strtol(optarg, &endptr, 10); if (tmp < 0 || tmp > 8) { - fprintf(stderr, "ERROR: Transfer option out of range: %ld\n", tmp); + fprintf(stderr, + "ERROR: Transfer option out of range: %ld\n", + tmp); show_usage(argv[0], EXIT_FAILURE); } else @@ -133,7 +136,9 @@ int main(int argc, FAR char *argv[]) tmp = strtol(optarg, &endptr, 10); if (tmp < 0 || tmp > 3) { - fprintf(stderr, "ERROR: Transfer type out of range: %ld\n", tmp); + fprintf(stderr, + "ERROR: Transfer type out of range: %ld\n", + tmp); show_usage(argv[0], EXIT_FAILURE); } else diff --git a/system/zmodem/zm_proto.c b/system/zmodem/zm_proto.c index 6c01351..f94f3c4 100644 --- a/system/zmodem/zm_proto.c +++ b/system/zmodem/zm_proto.c @@ -1,5 +1,5 @@ /**************************************************************************** - * system/zmodem/zm_proto.c + * apps/system/zmodem/zm_proto.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/system/zmodem/zm_receive.c b/system/zmodem/zm_receive.c index 3908662..b8ab47b 100644 --- a/system/zmodem/zm_receive.c +++ b/system/zmodem/zm_receive.c @@ -1,5 +1,5 @@ /**************************************************************************** - * system/zmodem/zm_receive.c + * apps/system/zmodem/zm_receive.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/system/zmodem/zm_send.c b/system/zmodem/zm_send.c index 70659cf..39fb5b4 100644 --- a/system/zmodem/zm_send.c +++ b/system/zmodem/zm_send.c @@ -1,5 +1,5 @@ /**************************************************************************** - * system/zmodem/zm_send.c + * apps/system/zmodem/zm_send.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -199,7 +199,9 @@ static const struct zm_transition_s g_zmr_initack[] = {ZME_ERROR, false, ZMS_INITACK, zms_error}, }; -/* Events handled in state ZMS_FILEWAIT- Sent file header, waiting for ZRPOS */ +/* Events handled in state ZMS_FILEWAIT- Sent file header, + * waiting for ZRPOS + */ static const struct zm_transition_s g_zms_filewait[] = { @@ -218,8 +220,8 @@ static const struct zm_transition_s g_zms_filewait[] = {ZME_ERROR, false, ZMS_FILEWAIT, zms_error}, }; -/* Events handled in state ZMS_CRCWAIT - Sent file CRC, waiting for ZRPOS - * response. +/* Events handled in state ZMS_CRCWAIT - Sent file CRC, + * waiting for ZRPOS response. */ static const struct zm_transition_s g_zms_crcwait[] = @@ -450,14 +452,16 @@ static int zms_zrinit(FAR struct zm_state_s *pzm) #ifdef CONFIG_SYSTEM_ZMODEM_RCVSAMPLE /* We support CANFDX. We can do ZCRCG if the remote sender does too */ - if ((rcaps & (CANFDX | CANOVIO)) == (CANFDX | CANOVIO) && pzms->rcvmax == 0) + if ((rcaps & (CANFDX | CANOVIO)) == + (CANFDX | CANOVIO) && pzms->rcvmax == 0) { pzms->dpkttype = ZCRCG; } #else /* We don't support CANFDX. We can do ZCRCQ if the remote sender does */ - if ((rcaps & (CANFDX | CANOVIO)) == (CANFDX | CANOVIO) && pzms->rcvmax == 0) + if ((rcaps & (CANFDX | CANOVIO)) == + (CANFDX | CANOVIO) && pzms->rcvmax == 0) { /* For the local sender, this is just like ZCRCW */ @@ -870,7 +874,9 @@ static int zms_sendpacket(FAR struct zm_state_s *pzm) sndsize = pzms->filesize - pzms->offset; - /* This is the number of bytes that have been sent but not yet acknowledged. */ + /* This is the number of bytes that have been sent but not yet + * acknowledged. + */ unacked = pzms->offset - pzms->lastoffs; @@ -885,7 +891,9 @@ static int zms_sendpacket(FAR struct zm_state_s *pzm) if (pzms->rcvmax != 0) { - /* If we were to send 'sndsize' more bytes, would that exceed recvmax? */ + /* If we were to send 'sndsize' more bytes, + * would that exceed recvmax? + */ if (sndsize + unacked > pzms->rcvmax) { diff --git a/system/zmodem/zm_state.c b/system/zmodem/zm_state.c index 7fc130a..8e094e8 100644 --- a/system/zmodem/zm_state.c +++ b/system/zmodem/zm_state.c @@ -1,5 +1,5 @@ /**************************************************************************** - * system/zmodem/zm_state.c + * apps/system/zmodem/zm_state.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -181,7 +181,9 @@ static int zm_hdrevent(FAR struct zm_state_s *pzm) { uint32_t crc; - /* Checksum is over 9 bytes: The header type, 4 data bytes, plus 4 CRC bytes */ + /* Checksum is over 9 bytes: + * The header type, 4 data bytes, plus 4 CRC bytes + */ crc = crc32part(pzm->hdrdata, 9, 0xffffffff); if (crc != 0xdebb20e3) @@ -194,7 +196,9 @@ static int zm_hdrevent(FAR struct zm_state_s *pzm) { uint16_t crc; - /* Checksum is over 7 bytes: The header type, 4 data bytes, plus 2 CRC bytes */ + /* Checksum is over 7 bytes: + * The header type, 4 data bytes, plus 2 CRC bytes + */ crc = crc16part(pzm->hdrdata, 7, 0); if (crc != 0) @@ -264,9 +268,9 @@ static int zm_dataevent(FAR struct zm_state_s *pzm) pzm->flags |= ZM_FLAG_CRKOK; } - /* Adjust the back length to exclude the packet type length of the 2- - * byte checksum. - */ + /* Adjust the back length to exclude the packet type length of + * the 2- byte checksum. + */ pzm->pktlen -= 3; } @@ -330,11 +334,12 @@ static int zm_idle(FAR struct zm_state_s *pzm, uint8_t ch) pzm->psubstate = PIDLE_ZPAD; } - /* O might be the first character of "OO". "OO" might be part of the file - * receiver protocol. After receiving on e file in a group of files, the - * receiver expected either "OO" indicating that all files have been sent, - * or a ZRQINIT header indicating the start of the next file. - */ + /* O might be the first character of "OO". "OO" might be part of the + * file receiver protocol. After receiving on e file in a group of + * files, the receiver expected either "OO" indicating that all files + * have been sent, or a ZRQINIT header indicating the start of the next + * file. + */ case 'O': /* Is "OO" a possibility in this context? Fall through to the default @@ -370,7 +375,9 @@ static int zm_idle(FAR struct zm_state_s *pzm, uint8_t ch) break; } - /* Unexpected character. Wait for the next ZPAD to get us back in sync. */ + /* Unexpected character. + * Wait for the next ZPAD to get us back in sync. + */ default: if (pzm->psubstate != PIDLE_ZPAD) @@ -390,20 +397,20 @@ static int zm_idle(FAR struct zm_state_s *pzm, uint8_t ch) * Name: zm_header * * Description: - * Data has been received in state PSTATE_HEADER (i.e., ZDLE was received - * in PSTAT_IDLE). + * Data has been received in state PSTATE_HEADER (i.e., ZDLE was received + * in PSTAT_IDLE). * - * The following headers are supported: + * The following headers are supported: * - * 16-bit Binary: - * ZPAD ZDLE ZBIN type f3/p0 f2/p1 f1/p2 f0/p3 crc-1 crc-2 - * Payload length: 7 (type, 4 bytes data, 2 byte CRC) - * 32-bit Binary: - * ZPAD ZDLE ZBIN32 type f3/p0 f2/p1 f1/p2 f0/p3 crc-1 crc-2 crc-3 crc-4 - * Payload length: 9 (type, 4 bytes data, 4 byte CRC) - * Hex: - * ZPAD ZPAD ZDLE ZHEX type f3/p0 f2/p1 f1/p2 f0/p3 crc-1 crc-2 CR LF [XON] - * Payload length: 16 (14 hex digits, cr, lf, ignoring optional XON) + * 16-bit Binary: + * ZPAD ZDLE ZBIN type f3/p0 f2/p1 f1/p2 f0/p3 crc-1 crc-2 + * Payload length: 7 (type, 4 bytes data, 2 byte CRC) + * 32-bit Binary: + * ZPAD ZDLE ZBIN32 type f3/p0 f2/p1 f1/p2 f0/p3 crc-1 crc-2 crc-3 crc-4 + * Payload length: 9 (type, 4 bytes data, 4 byte CRC) + * Hex: + * ZPAD ZPAD ZDLE ZHEX type f3/p0 f2/p1 f1/p2 f0/p3 crc-1 crc-2 CR LF [XON] + * Payload length: 16 (14 hex digits, cr, lf, ignoring optional XON) * ****************************************************************************/ @@ -524,8 +531,8 @@ static int zm_header(FAR struct zm_state_s *pzm, uint8_t ch) /* Check if the full header payload has bee buffered. * * The ZBIN format uses 16-bit CRC so the binary length of the - * full payload is 1+4+2 = 7 bytes; the ZBIN32 uses a 32-bit CRC - * so the binary length of the payload is 1+4+4 = 9 bytes; + * full payload is 1+4+2 = 7 bytes; the ZBIN32 uses a 32-bit + * CRC so the binary length of the payload is 1+4+4 = 9 bytes; */ if (ndx >= 9 || (pzm->hdrfmt == ZBIN && ndx >= 7)) @@ -634,7 +641,8 @@ static int zm_data(FAR struct zm_state_s *pzm, uint8_t ch) { zmdbg("ERROR: The packet buffer is full\n"); zmdbg(" ch=%c[%02x] pktlen=%d pkttype=%02x ncrc=%d\n", - isprint(ch) ? ch : '.', ch, pzm->pktlen, pzm->pkttype, pzm->ncrc); + isprint(ch) ? ch : '.', ch, pzm->pktlen, + pzm->pkttype, pzm->ncrc); zmdbg(" rcvlen=%d rcvndx=%d\n", pzm->rcvlen, pzm->rcvndx); return -ENOSPC; @@ -696,10 +704,12 @@ static int zm_data(FAR struct zm_state_s *pzm, uint8_t ch) * payload plus the packet type code plus the CRC itself. */ - pzm->pktbuf[pzm->pktlen++] = ch; - if (pzm->ncrc == 1) - { - /* We are at the end of the packet. Check the CRC and post the event */ + pzm->pktbuf[pzm->pktlen++] = ch; + if (pzm->ncrc == 1) + { + /* We are at the end of the packet. + * Check the CRC and post the event + */ ret = zm_dataevent(pzm); @@ -710,15 +720,15 @@ static int zm_data(FAR struct zm_state_s *pzm, uint8_t ch) pzm->pktlen = 0; pzm->ncrc = 0; return ret; - } - else if (pzm->ncrc > 1) - { + } + else if (pzm->ncrc > 1) + { /* We are still parsing the CRC. Decrement the count of CRC bytes * remaining. */ - pzm->ncrc--; - } + pzm->ncrc--; + } return OK; } @@ -945,7 +955,6 @@ int zm_datapump(FAR struct zm_state_s *pzm) return ret; } - /**************************************************************************** * Name: zm_readstate * diff --git a/system/zmodem/zm_utils.c b/system/zmodem/zm_utils.c index baa1722..8ab2856 100644 --- a/system/zmodem/zm_utils.c +++ b/system/zmodem/zm_utils.c @@ -1,5 +1,5 @@ /**************************************************************************** - * system/zmodem/zm_utils.c + * apps/system/zmodem/zm_utils.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -42,10 +42,16 @@ * Public Data ****************************************************************************/ -const uint8_t g_zeroes[4] = { 0, 0, 0, 0 }; +const uint8_t g_zeroes[4] = +{ + 0, + 0, + 0, + 0 +}; /**************************************************************************** - * Public Function Protypes + * Public Functions ****************************************************************************/ /**************************************************************************** @@ -77,7 +83,7 @@ uint32_t zm_bytobe32(FAR const uint8_t *val8) void zm_be32toby(uint32_t val32, FAR uint8_t *val8) { - val8[0] = (uint8_t)( val32 & 0xff); + val8[0] = (uint8_t)(val32 & 0xff); val8[1] = (uint8_t)((val32 >> 8) & 0xff); val8[2] = (uint8_t)((val32 >> 16) & 0xff); val8[3] = (uint8_t)((val32 >> 24) & 0xff); @@ -154,9 +160,9 @@ ssize_t zm_read(int fd, FAR uint8_t *buffer, size_t buflen) { ssize_t nread; - /* Read reading as necessary until the requested buffer data is successfully - * read or until an end of file indication or irrecoverable error is - * encountered. + /* Read reading as necessary until the requested buffer data is + * successfully read or until an end of file indication or irrecoverable + * error is encountered. * * This loop will only execute if the read is interrupted by a signal. */ @@ -164,8 +170,10 @@ ssize_t zm_read(int fd, FAR uint8_t *buffer, size_t buflen) nread = 0; do { - /* Get the next gulp of data from the file. On success, read will return - * (1) nread > 0 and nread <= buflen, (2) nread == 0 on end of file, or + /* Get the next gulp of data from the file. + * On success, read will return + * (1) nread > 0 and nread <= buflen, + * (2) nread == 0 on end of file, or * (3) nread < 0 on a read error. */ @@ -241,15 +249,15 @@ ssize_t zm_write(int fd, FAR const uint8_t *buffer, size_t buflen) for (remaining = buflen; remaining > 0; ) { #if CONFIG_SYSTEM_ZMODEM_WRITESIZE > 0 - if (remaining > CONFIG_SYSTEM_ZMODEM_WRITESIZE) - { - wrsize = CONFIG_SYSTEM_ZMODEM_WRITESIZE; - } - else + if (remaining > CONFIG_SYSTEM_ZMODEM_WRITESIZE) + { + wrsize = CONFIG_SYSTEM_ZMODEM_WRITESIZE; + } + else #endif - { - wrsize = remaining; - } + { + wrsize = remaining; + } /* Get the next gulp of data from the file */ @@ -385,13 +393,13 @@ int zm_writefile(int fd, FAR const uint8_t *buffer, size_t buflen, bool zcnl) ret = zm_write(fd, (FAR uint8_t *)"\n", 1); newline = true; } - } + } } else { /* Increment the number of bytes we need to write beginning at - * start. We want to write as many contiguous bytes as possible - * for performance reasons. + * start. We want to write as many contiguous bytes as + * possible for performance reasons. */ nbytes++; @@ -447,7 +455,8 @@ uint32_t zm_filecrc(FAR struct zm_state_s *pzm, FAR const char *filename) /* Calculate the file CRC */ crc = 0xffffffff; - while ((nread = zm_read(fd, pzm->scratch, CONFIG_SYSTEM_ZMODEM_SNDBUFSIZE)) > 0) + while ((nread = zm_read(fd, pzm->scratch, + CONFIG_SYSTEM_ZMODEM_SNDBUFSIZE)) > 0) { crc = crc32part(pzm->scratch, nread, crc); } diff --git a/system/zmodem/zm_watchdog.c b/system/zmodem/zm_watchdog.c index 8e3491a..606b9af 100644 --- a/system/zmodem/zm_watchdog.c +++ b/system/zmodem/zm_watchdog.c @@ -1,5 +1,5 @@ /**************************************************************************** - * system/zmodem/zm_watchdog.c + * apps/system/zmodem/zm_watchdog.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -45,7 +45,8 @@ static void zm_expiry(int signo, FAR siginfo_t *info, FAR void *context) { - FAR struct zm_state_s *pzm = (FAR struct zm_state_s *)info->si_value.sival_ptr; + FAR struct zm_state_s *pzm = + (FAR struct zm_state_s *)info->si_value.sival_ptr; /* Just set the timeout flag. If the Zmodem logic was truly waiting, then * the signal should wake it up and it should then process the timeout
