summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2013-10-25 15:48:11 -0600
committerGregory Nutt <gnutt@nuttx.org>2013-10-25 15:48:11 -0600
commit9830c45105339840b3fb1b67687567d5a97b03d4 (patch)
treefa9f1253634ccfd3d13ae3e3a5eef2b17e9b5cb8
parent9dc1c932eb08d1909fdfd56bf55be7ec9c1b3498 (diff)
downloadpx4-nuttx-9830c45105339840b3fb1b67687567d5a97b03d4.tar.gz
px4-nuttx-9830c45105339840b3fb1b67687567d5a97b03d4.tar.bz2
px4-nuttx-9830c45105339840b3fb1b67687567d5a97b03d4.zip
apps/examples/cc3000 updated by David Sidrane
-rw-r--r--apps/ChangeLog.txt1
-rw-r--r--apps/examples/cc3000/Makefile4
-rw-r--r--apps/examples/cc3000/board.c2
-rw-r--r--apps/examples/cc3000/cc3000basic.c96
-rw-r--r--apps/examples/cc3000/shell.c9
-rw-r--r--apps/examples/cc3000/shell.h4
-rw-r--r--apps/examples/cc3000/telnetd_daemon.c17
7 files changed, 108 insertions, 25 deletions
diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt
index d553b7842..aff570b5b 100644
--- a/apps/ChangeLog.txt
+++ b/apps/ChangeLog.txt
@@ -699,4 +699,5 @@
statement. From Martin Lederhilger (2013-10-24).
* apps/examples/adc: Add support so that a ADC driven by
software triggering can be tested (2013-10-25).
+ * apps/examples/cc3000: Updates from David Sidrane (2013-10-25).
diff --git a/apps/examples/cc3000/Makefile b/apps/examples/cc3000/Makefile
index bf6bcc43f..37910b841 100644
--- a/apps/examples/cc3000/Makefile
+++ b/apps/examples/cc3000/Makefile
@@ -41,11 +41,11 @@ include $(APPDIR)/Make.defs
APPNAME = c3b
PRIORITY = SCHED_PRIORITY_DEFAULT
-STACKSIZE = 2048
+STACKSIZE = 660
APPNAME1 = shell
PRIORITY1 = SCHED_PRIORITY_DEFAULT
-STACKSIZE1 = 2048
+STACKSIZE1 = 980
# Hello, World! Example
diff --git a/apps/examples/cc3000/board.c b/apps/examples/cc3000/board.c
index 009b56663..ff2a3c729 100644
--- a/apps/examples/cc3000/board.c
+++ b/apps/examples/cc3000/board.c
@@ -169,7 +169,7 @@ void CC3000_Init(void)
once = true;
}
- CC3000_wlan_init( CC3000_AsyncCallback,
+ cc3000_wlan_init( CC3000_AsyncCallback,
SendFirmwarePatch,
SendDriverPatch,
SendBootloaderPatch);
diff --git a/apps/examples/cc3000/cc3000basic.c b/apps/examples/cc3000/cc3000basic.c
index 73d8a4272..e72dbecb6 100644
--- a/apps/examples/cc3000/cc3000basic.c
+++ b/apps/examples/cc3000/cc3000basic.c
@@ -87,14 +87,17 @@
****************************************************************************/
#include <nuttx/config.h>
+
#include "board.h"
#include <stdio.h>
#include <string.h>
+#include <syslog.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include <sys/time.h>
#include <arpa/inet.h>
+#include <nuttx/arch.h>
#include <nuttx/wireless/cc3000/nvmem.h>
#include <nuttx/wireless/cc3000/include/sys/socket.h>
#include <nuttx/wireless/cc3000/wlan.h>
@@ -127,16 +130,60 @@ void ShowInformation(void);
#define US_PER_SEC 1000000
/****************************************************************************
- * Public Variables
+ * Private Data
****************************************************************************/
-uint8_t isInitialized = false;
+static uint8_t isInitialized = false;
+
+#ifdef CONFIG_EXAMPLE_CC3000_MEM_CHECK
+static struct mallinfo mmstart;
+static struct mallinfo mmprevious;
+#endif
/****************************************************************************
- * Public Functions
+ * Private Functions
****************************************************************************/
-bool wait(long timeoutMs, volatile unsigned long *what, volatile unsigned long is)
+#ifndef CONFIG_EXAMPLE_CC3000_MEM_CHECK
+# define stkmon_disp()
+#else
+static void show_memory_usage(struct mallinfo *mmbefore,
+ struct mallinfo *mmafter)
+{
+ int diff;
+
+ printf(" total used free largest\n");
+ printf("Before:%11d%11d%11d%11d\n",
+ mmbefore->arena, mmbefore->uordblks, mmbefore->fordblks, mmbefore->mxordblk);
+ printf("After: %11d%11d%11d%11d\n",
+ mmafter->arena, mmafter->uordblks, mmafter->fordblks, mmafter->mxordblk);
+
+ diff = mmbefore->uordblks - mmafter->uordblks;
+ if (diff < 0)
+ {
+ printf("Change:%11d allocated\n", -diff);
+ }
+ else if (diff > 0)
+ {
+ printf("Change:%11d freed\n", diff);
+ }
+
+ stkmon_disp();
+}
+
+static void _stkmon_disp(FAR struct tcb_s *tcb, FAR void *arg)
+{
+#if CONFIG_TASK_NAME_SIZE > 0
+ syslog("%5d %6d %6d %s\n",
+ tcb->pid, tcb->adj_stack_size, up_check_tcbstack(tcb), tcb->name);
+#else
+ syslog("%5d %6d %6d\n",
+ tcb->pid, tcb->adj_stack_size, up_check_tcbstack(tcb));
+#endif
+}
+
+static bool wait(long timeoutMs, volatile unsigned long *what,
+ volatile unsigned long is)
{
long t_ms;
struct timeval end, start;
@@ -157,7 +204,8 @@ bool wait(long timeoutMs, volatile unsigned long *what, volatile unsigned long i
return true;
}
-bool wait_on(long timeoutMs, volatile unsigned long *what, volatile unsigned long is,char * msg)
+static bool wait_on(long timeoutMs, volatile unsigned long *what,
+ volatile unsigned long is, char * msg)
{
printf(msg);
printf("...");
@@ -176,6 +224,21 @@ bool wait_on(long timeoutMs, volatile unsigned long *what, volatile unsigned lon
return ret;
}
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+void stkmon_disp(void)
+{
+#if CONFIG_TASK_NAME_SIZE > 0
+ syslog("%-5s %-6s %-6s %s\n", "PID", "SIZE", "USED", "THREAD NAME");
+#else
+ syslog("%-5s %-6s %-6s\n", "PID", "SIZE", "USED");
+#endif
+ sched_foreach(_stkmon_disp, NULL);
+}
+#endif
+
void AsyncEventPrint(void)
{
printf("\n");
@@ -283,7 +346,16 @@ int execute(int cmd)
{
Initialize();
}
+
+#ifdef CONFIG_EXAMPLE_CC3000_MEM_CHECK
+ mmprevious= mallinfo();
+ show_memory_usage(&mmstart,&mmprevious);
+#endif
shell_main(0, 0);
+#ifdef CONFIG_EXAMPLE_CC3000_MEM_CHECK
+ mmprevious= mallinfo();
+ show_memory_usage(&mmstart,&mmprevious);
+#endif
break;
case 'q':
@@ -301,6 +373,12 @@ int execute(int cmd)
void Initialize(void)
{
+#ifdef CONFIG_EXAMPLE_CC3000_MEM_CHECK
+ mmstart = mallinfo();
+ memcpy(&mmprevious, &mmstart, sizeof(struct mallinfo));
+ show_memory_usage(&mmstart,&mmprevious);
+#endif
+
uint8_t fancyBuffer[MAC_ADDR_LEN];
if (isInitialized)
@@ -350,6 +428,11 @@ void Initialize(void)
#else
isInitialized = true;
#endif
+
+#ifdef CONFIG_EXAMPLE_CC3000_MEM_CHECK
+ mmprevious = mallinfo();
+ show_memory_usage(&mmstart,&mmprevious);
+#endif
}
/* This just shows the compiled size of the transmit & recieve buffers */
@@ -486,7 +569,7 @@ void StartSmartConfig(void)
* returns is the socket number it used. So we ignore it.
*/
- mdnsAdvertiser(1,device_name,strlen(device_name));
+ mdnsadvertiser(1, device_name, strlen(device_name));
printf(" Smart Config finished Successfully!\n");
ShowInformation();
@@ -853,6 +936,7 @@ int c3b_main(int argc, char *argv[])
do
{
helpme();
+ stkmon_disp();
ch = getchar();
diff --git a/apps/examples/cc3000/shell.c b/apps/examples/cc3000/shell.c
index 590c8b12c..2e8f3d08d 100644
--- a/apps/examples/cc3000/shell.c
+++ b/apps/examples/cc3000/shell.c
@@ -51,6 +51,7 @@
#include <apps/netutils/uiplib.h>
#include "shell.h"
+#include <apps/nsh.h>
/****************************************************************************
* Definitions
@@ -121,6 +122,9 @@ static void shell_unknown(int argc, char **argv)
static void shell_quit(int argc, char **argv)
{
printf("Bye!\n");
+#ifdef CONFIG_EXAMPLE_CC3000_MEM_CHECK
+ stkmon_disp();
+#endif
exit(0);
}
@@ -163,6 +167,9 @@ int shell_session(int argc, char *argv[])
printf("CC3000 command shell -- NuttX style\n");
printf("Type '?' and return for help\n");
+#ifdef CONFIG_EXAMPLE_CC3000_MEM_CHECK
+ stkmon_disp();
+#endif
for(;;)
{
@@ -210,7 +217,7 @@ int shell_main(int argc, char *argv[])
config.d_stacksize = CONFIG_EXAMPLES_TELNETD_DAEMONSTACKSIZE;
config.t_priority = CONFIG_EXAMPLES_TELNETD_CLIENTPRIO;
config.t_stacksize = CONFIG_EXAMPLES_TELNETD_CLIENTSTACKSIZE;
- config.t_entry = shell_session;
+ config.t_entry = nsh_consolemain;
/* Start the telnet daemon */
diff --git a/apps/examples/cc3000/shell.h b/apps/examples/cc3000/shell.h
index aa8152a70..c25da9c0e 100644
--- a/apps/examples/cc3000/shell.h
+++ b/apps/examples/cc3000/shell.h
@@ -59,7 +59,7 @@
#endif
#ifndef CONFIG_EXAMPLES_TELNETD_DAEMONSTACKSIZE
-# define CONFIG_EXAMPLES_TELNETD_DAEMONSTACKSIZE 768
+# define CONFIG_EXAMPLES_TELNETD_DAEMONSTACKSIZE 580
#endif
#ifndef CONFIG_EXAMPLES_TELNETD_CLIENTPRIO
@@ -70,6 +70,8 @@
# define CONFIG_EXAMPLES_TELNETD_CLIENTSTACKSIZE 990
#endif
+#undef CONFIG_EXAMPLE_CC3000_MEM_CHECK
+
/* Other definitions ********************************************************/
#define SHELL_PROMPT "CC3000 1.0> "
diff --git a/apps/examples/cc3000/telnetd_daemon.c b/apps/examples/cc3000/telnetd_daemon.c
index 353a63404..a149f7abe 100644
--- a/apps/examples/cc3000/telnetd_daemon.c
+++ b/apps/examples/cc3000/telnetd_daemon.c
@@ -70,7 +70,7 @@
* Public Data
****************************************************************************/
-/* This structure is used to passed information to telnet daemon when it
+/* This structure is used to passed information to telnet daemon when it
* started.
*/
@@ -159,15 +159,8 @@ static int telnetd_daemon(int argc, char *argv[])
ndbg("listen failure %d\n", errno);
goto errout_with_socket;
}
-#if defined(CC3000_SOCKETS)
- short nonBlocking=SOCK_OFF;
- if (setsockopt(listensd, SOL_SOCKET, SOCKOPT_ACCEPT_NONBLOCK, &nonBlocking, sizeof(nonBlocking)) < 0)
- {
- ndbg("setsockopt failure %d\n", errno);
- goto errout_with_socket;
- }
-#endif
- /* Now go silent. Only the lldbg family of debug functions should
+
+ /* Now go silent. Only the lldbg family of debug functions should
* be used after this point because these do not depend on stdout
* being available.
*/
@@ -259,10 +252,6 @@ static int telnetd_daemon(int argc, char *argv[])
close(0);
close(1);
close(2);
-#if defined(CC3000_SOCKETS_ST)
- /* We can not do more then one accept in Single treaded version */
- break;
-#endif
}
errout_with_acceptsd: