apps/examples/cc3000 updated by David Sidrane

This commit is contained in:
Gregory Nutt 2013-10-25 15:48:11 -06:00
parent eb39b81b69
commit ea93f20f39
7 changed files with 108 additions and 25 deletions

View File

@ -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).

View File

@ -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

View File

@ -169,7 +169,7 @@ void CC3000_Init(void)
once = true;
}
CC3000_wlan_init( CC3000_AsyncCallback,
cc3000_wlan_init( CC3000_AsyncCallback,
SendFirmwarePatch,
SendDriverPatch,
SendBootloaderPatch);

View File

@ -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();

View File

@ -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 */

View File

@ -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> "

View File

@ -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: