From: richardbarry Date: Mon, 1 Aug 2011 10:58:22 +0000 (+0000) Subject: Move the MSVC/lwIP code into the main line - not yet tested since moved. X-Git-Tag: V7.0.2~79 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c729ae276fe65acbb696be01307330b11ac77158;p=freertos Move the MSVC/lwIP code into the main line - not yet tested since moved. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1531 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/Demo/WIN32-MSVC-lwIP/WIN32.vcxproj b/Demo/WIN32-MSVC-lwIP/WIN32.vcxproj index 886b0cf4a..a4a21d36c 100644 --- a/Demo/WIN32-MSVC-lwIP/WIN32.vcxproj +++ b/Demo/WIN32-MSVC-lwIP/WIN32.vcxproj @@ -54,7 +54,7 @@ Disabled - ..\Common\ethernet\lwip-1.4.0\ports\win32\WinPCap;..\Common\ethernet\lwip-1.4.0\src\include\ipv4;..\Common\ethernet\lwip-1.4.0\src\include;..\..\Source\include;..\..\Source\portable\MSVC-MingW;..\Common\ethernet\lwip-1.4.0\ports\win32\include;..\Common\Include;.\lwIP_Apps;.;%(AdditionalIncludeDirectories) + ..\Common\Utils;..\Common\ethernet\lwip-1.4.0\ports\win32\WinPCap;..\Common\ethernet\lwip-1.4.0\src\include\ipv4;..\Common\ethernet\lwip-1.4.0\src\include;..\..\Source\include;..\..\Source\portable\MSVC-MingW;..\Common\ethernet\lwip-1.4.0\ports\win32\include;..\Common\Include;.\lwIP_Apps;.;%(AdditionalIncludeDirectories) _WINSOCKAPI_;WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;WINVER=0x400;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true EnableFastChecks @@ -168,21 +168,11 @@ - - - - - - - - - - - - - + + + %(AdditionalIncludeDirectories) diff --git a/Demo/WIN32-MSVC-lwIP/WIN32.vcxproj.filters b/Demo/WIN32-MSVC-lwIP/WIN32.vcxproj.filters index b02587849..6914b1003 100644 --- a/Demo/WIN32-MSVC-lwIP/WIN32.vcxproj.filters +++ b/Demo/WIN32-MSVC-lwIP/WIN32.vcxproj.filters @@ -25,9 +25,6 @@ {88f409e6-d396-4ac5-94bd-7a99c914be46} - - {143cf5a3-f134-4439-9f71-a201ae23b44b} - {19ff1a34-36de-4c48-9d10-3fb1fa0d1fa4} h;hpp;hxx;hm;inl @@ -74,7 +71,10 @@ {c3366d35-95df-4c03-a752-3ae631ec6bba} - + + {92b32a46-5658-4c53-b5de-3b174955a777} + + {6c4a261d-ca37-4528-ad50-8f04032898cb} @@ -97,42 +97,12 @@ FreeRTOS Source\Source\Portable - - Demo App Source\Common Demo Tasks - Demo App Source\Common Demo Tasks - - Demo App Source\Common Demo Tasks - - - Demo App Source\Common Demo Tasks - - - Demo App Source\Common Demo Tasks - - - Demo App Source\Common Demo Tasks - - - Demo App Source\Common Demo Tasks - - - Demo App Source\Common Demo Tasks - - - Demo App Source\Common Demo Tasks\ModifiedForLowTickRate - FreeRTOS Source\Source - - Demo App Source\Common Demo Tasks - - - Demo App Source\Common Demo Tasks - lwIP\Source\API @@ -256,21 +226,21 @@ lwIP\Source\Core\SNMP - - lwIP_Apps\httpd_raw - - - lwIP_Apps\httpd_raw - lwIP_Apps - - lwIP_Apps - Demo App Source + + lwIP_Apps\BasicSocketCommandServer + + + lwIP_Apps\httpd_raw_from_lwIP_download + + + lwIP_Apps\httpd_raw_from_lwIP_download + diff --git a/Demo/WIN32-MSVC-lwIP/lwIP_Apps/apps/BasicSocketCommandServer/BasicSocketCommandServer.c b/Demo/WIN32-MSVC-lwIP/lwIP_Apps/apps/BasicSocketCommandServer/BasicSocketCommandServer.c index 4b6678971..85a722a36 100644 --- a/Demo/WIN32-MSVC-lwIP/lwIP_Apps/apps/BasicSocketCommandServer/BasicSocketCommandServer.c +++ b/Demo/WIN32-MSVC-lwIP/lwIP_Apps/apps/BasicSocketCommandServer/BasicSocketCommandServer.c @@ -66,6 +66,7 @@ #include "CommandInterpreter.h" #define cmdMAX_INPUT_SIZE 20 + /*-----------------------------------------------------------*/ void vBasicTelnetServer( void *pvParameters ) @@ -133,7 +134,7 @@ signed char cInputString[ cmdMAX_INPUT_SIZE ]; { /* The input string was not a quit command. Pass the string to the command interpreter. */ - while( ( pcString = pcProcessCommand( cInputString ) ) != NULL ) + while( ( pcString = pcCmdIntProcessCommand( cInputString ) ) != NULL ) { /* A string has been generated by the command interpreter. Send it. */ diff --git a/Demo/WIN32-MSVC-lwIP/lwIP_Apps/lwIP_Apps.c b/Demo/WIN32-MSVC-lwIP/lwIP_Apps/lwIP_Apps.c index 1adc74d1e..aa186b34d 100644 --- a/Demo/WIN32-MSVC-lwIP/lwIP_Apps/lwIP_Apps.c +++ b/Demo/WIN32-MSVC-lwIP/lwIP_Apps/lwIP_Apps.c @@ -74,19 +74,7 @@ #include "netif/etharp.h" /* applications includes */ -#include "apps/httpserver_raw/httpd.h" -#include "apps/httpserver/httpserver-netconn.h" -#include "apps/netio/netio.h" -#include "apps/netbios/netbios.h" -#include "apps/ping/ping.h" -#include "apps/rtp/rtp.h" -#include "apps/sntp/sntp.h" -#include "apps/chargen/chargen.h" -#include "apps/shell/shell.h" -#include "apps/tcpecho/tcpecho.h" -#include "apps/udpecho/udpecho.h" -#include "apps/tcpecho_raw/echo.h" -#include "apps/socket_examples/socket_examples.h" +#include "apps/httpserver_raw_from_lwIP_download/httpd.h" /* include the port-dependent configuration */ #include "lwipcfg_msvc.h" @@ -149,67 +137,12 @@ extern err_t ethernetif_init( struct netif *netif ); /* This function initializes applications */ static void apps_init( void ) { - /* Taken from the lwIP example code. */ - - #if LWIP_DNS_APP && LWIP_DNS - /* wait until the netif is up (for dhcp, autoip or ppp) */ - sys_timeout(5000, dns_dorequest, NULL); - #endif /* LWIP_DNS_APP && LWIP_DNS */ - - #if LWIP_CHARGEN_APP && LWIP_SOCKET - chargen_init(); - #endif /* LWIP_CHARGEN_APP && LWIP_SOCKET */ - - #if LWIP_PING_APP && LWIP_RAW && LWIP_ICMP - ping_init(); - #endif /* LWIP_PING_APP && LWIP_RAW && LWIP_ICMP */ - - #if LWIP_NETBIOS_APP && LWIP_UDP - netbios_init(); - #endif /* LWIP_NETBIOS_APP && LWIP_UDP */ - - #if LWIP_HTTPD_APP && LWIP_TCP - { - #ifdef LWIP_HTTPD_APP_NETCONN - http_server_netconn_init(); - #else /* LWIP_HTTPD_APP_NETCONN */ - httpd_init(); - #endif /* LWIP_HTTPD_APP_NETCONN */ - } - #endif /* LWIP_HTTPD_APP && LWIP_TCP */ - - #if LWIP_NETIO_APP && LWIP_TCP - netio_init(); - #endif /* LWIP_NETIO_APP && LWIP_TCP */ - - #if LWIP_RTP_APP && LWIP_SOCKET && LWIP_IGMP - rtp_init(); - #endif /* LWIP_RTP_APP && LWIP_SOCKET && LWIP_IGMP */ - - #if LWIP_SNTP_APP && LWIP_SOCKET - sntp_init(); - #endif /* LWIP_SNTP_APP && LWIP_SOCKET */ - - #if LWIP_SHELL_APP && LWIP_NETCONN - shell_init(); - #endif /* LWIP_SHELL_APP && LWIP_NETCONN */ - - #if LWIP_TCPECHO_APP - #if LWIP_NETCONN && defined(LWIP_TCPECHO_APP_NETCONN) - tcpecho_init(); - #else /* LWIP_NETCONN && defined(LWIP_TCPECHO_APP_NETCONN) */ - echo_init(); - #endif - #endif /* LWIP_TCPECHO_APP && LWIP_NETCONN */ - - #if LWIP_UDPECHO_APP && LWIP_NETCONN - udpecho_init(); - #endif /* LWIP_UDPECHO_APP && LWIP_NETCONN */ - - #if LWIP_SOCKET_EXAMPLES_APP && LWIP_SOCKET - socket_examples_init(); - #endif /* LWIP_SOCKET_EXAMPLES_APP && LWIP_SOCKET */ + /* Create the httpd server from the standard lwIP code. This demonstrates + use of the lwIP raw API. */ + httpd_init(); + /* Create the FreeRTOS defined basic command server. This demonstrates use + of the lwIP sockets API. */ xTaskCreate( vBasicTelnetServer, ( signed char * ) "Telnet", configMINIMAL_STACK_SIZE * 10, NULL, configMAX_PRIORITIES - 2, NULL ); } /*-----------------------------------------------------------*/ diff --git a/Demo/WIN32-MSVC-lwIP/main.c b/Demo/WIN32-MSVC-lwIP/main.c index 2cfa1e96f..85a658a98 100644 --- a/Demo/WIN32-MSVC-lwIP/main.c +++ b/Demo/WIN32-MSVC-lwIP/main.c @@ -60,44 +60,31 @@ * * - READ THE WEB DOCUMENTATION FOR THIS PORT FOR MORE INFORMATION ON USING IT - * - http://www.freertos.org/FreeRTOS-Windows-Simulator-Emulator-for-Visual-Studio-and-Eclipse-MingW.html + * - Note that the above linked page describes the simulator environment. It + * - is not the correct page to view for information on using this lwIP demo. ******************************************************************************* * - * main() creates all the demo application tasks, then starts the scheduler. - * The web documentation provides more details of the standard demo application - * tasks, which provide no particular functionality but do provide a good - * example of how to use the FreeRTOS API. + * This project demonstrates use of the lwIP stack. The lwIP raw API is + * demonstrated by a simple http server that comes as part of the lwIP + * distribution - and executes in the tcpip task. The lwIP sockets API + * is demonstrated by a simple command line interpreter interface, which + * executes in its own task. * - * In addition to the standard demo tasks, the following tasks and tests are - * defined and/or created within this file: + * Both the http and command line server can be used to view task stats, and + * run time stats. Task stats give a snapshot of the state of each task in + * the system. Run time stats show how much processing time has been allocated + * to each task. A few of the standard demo tasks are created, just to ensure + * there is some data to be viewed. * - * "Check" task - This only executes every five seconds but has a high priority - * to ensure it gets processor time. Its main function is to check that all the - * standard demo tasks are still operational. While no errors have been - * discovered the check task will print out "OK" and the current simulated tick - * time. If an error is discovered in the execution of a task then the check - * task will print out an appropriate error message. + * Finally, a check timer is created. The check timer is a software timer that + * inspects the few standard demo tasks that are created to ensure they are + * executing as expected. It maintains a status string that can be viewed on + * the "task stats" page served by the web server. * - * lwIP - This project also includes a simple lwIP example. The implements a - * web server that includes Server Side Include (SSI) functionality. The web - * server serves a page that shows task statistics, and another page that shows - * run time statistics (how much CPU time each task is consuming). Following - * are some notes on the web server functionality: - * - Configuration parameters (IP address, etc.) are set at the bottom of - * FreeRTOSConfig.h. In particular, the number of the WinPCap interface to - * open is set by the configNETWORK_INTERFACE_TO_USE parameter. - * - A WinPCap driver is provided in - * FreeRTOS\Demo\Common\ethernet\lwip-1.4.0\ports\win32\ethernetif.c. - * - Currently, the files served by the web server are converted into C structs, - * and built into the executable image. The html and image files are converted - * to C structs using the makefsdata.exe binary found in - * FreeRTOS\Demo\WIN32-MSVC\lwIP_Apps\apps\httpserver_raw\makefsdata. A - * Microsoft Visual Studio Express 10 project file that builds the .exe is - * located in the same directory. - * - Makefsdata.exe outputs a file called fsdata.c. fsdata.c must be copied - * into FreeRTOS\Demo\WIN32-MSVC\lwIP_Apps\apps\httpserver_raw prior to the - * project being built. - * - The SSI generator functions are located in - * FreeRTOS\Demo\WIN32-MSVC\lwIP_Apps\lwIP_Apps.c + * More information about this demo, including details of how to set up the + * network interface, and the command line commands that are available, is + * available on the documentation page for this demo on the + * http://www.FreeRTOS.org web site. * */ @@ -108,19 +95,10 @@ /* Kernel includes. */ #include #include "task.h" -#include "queue.h" +#include "timers.h" /* Standard demo includes. */ -#include "BlockQ.h" -#include "integer.h" -#include "semtest.h" -#include "PollQ.h" #include "GenQTest.h" -#include "QPeek.h" -#include "recmutex.h" -#include "flop.h" -#include "TimerDemo.h" -#include "countsem.h" /* lwIP includes. */ #include "lwip/tcpip.h" @@ -129,21 +107,15 @@ #include "CommandInterpreter.h" /* Priorities at which the tasks are created. */ -#define mainCHECK_TASK_PRIORITY ( configMAX_PRIORITIES - 1 ) -#define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 1 ) -#define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 ) -#define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 ) -#define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 ) -#define mainFLASH_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 ) -#define mainuIP_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 ) -#define mainINTEGER_TASK_PRIORITY ( tskIDLE_PRIORITY ) #define mainGEN_QUEUE_TASK_PRIORITY ( tskIDLE_PRIORITY ) -#define mainFLOP_TASK_PRIORITY ( tskIDLE_PRIORITY ) -#define mainTIMER_TEST_PERIOD ( 50 ) +/* The period at which the check timer will expire, in ms, provided no errors +have been reported by any of the standard demo tasks. ms are converted to the +equivalent in ticks using the portTICK_RATE_MS constant. */ +#define mainCHECK_TIMER_PERIOD_MS ( 3000UL / portTICK_RATE_MS ) -/* Task function prototypes. */ -static void prvCheckTask( void *pvParameters ); +/* Check timer callback function. */ +static void prvCheckTimerCallback( xTimerHandle xTimer ); /* Defined in lwIPApps.c. */ extern void lwIPAppsInit( void *pvArguments ); @@ -162,13 +134,16 @@ static char *pcStatusMessage = "All tasks running without error"; stats record how much time each task spends in the Running state. */ long long llInitialRunTimeCounterValue = 0LL, llRunTimeStatsDivisor = 0LL; +/* The check timer. This uses prvCheckTimerCallback() as its callback +function. */ +static xTimerHandle xCheckTimer = NULL; + /* Structure that defines the "run-time-stats" command line command. */ static const xCommandLineInput xRunTimeStats = { "run-time-stats", "run-time-stats: Displays a table showing how much processing time each FreeRTOS task has used\r\n", prvRunTimeStatsCommand, - NULL }; /* Structure that defines the "task-stats" command line command. */ @@ -177,110 +152,67 @@ static const xCommandLineInput xTaskStats = "task-stats", "task-stats: Displays a table showing the state of each FreeRTOS task\r\n", prvTaskStatsCommand, - &xRunTimeStats }; /*-----------------------------------------------------------*/ int main( void ) { +const unsigned long ulLongTime_ms = 1000UL; + /* This call creates the TCP/IP thread. */ tcpip_init( lwIPAppsInit, NULL ); - #if configINCLUDE_STANDARD_DEMO_TASKS == 1 - { - /* Start the check task as described at the top of this file. */ - xTaskCreate( prvCheckTask, ( signed char * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL ); - - /* Create the standard demo tasks. */ - vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY ); - vStartSemaphoreTasks( mainSEM_TEST_PRIORITY ); - vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY ); - vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY ); - vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY ); - vStartQueuePeekTasks(); - vStartMathTasks( mainFLOP_TASK_PRIORITY ); - vStartRecursiveMutexTasks(); - vStartTimerDemoTask( mainTIMER_TEST_PERIOD ); - vStartCountingSemaphoreTasks(); - } - #endif + /* Create and start the check timer, as described at the top of this file. */ + xCheckTimer = xTimerCreate( ( const signed char * ) "CheckTimer",/* A text name, purely to help debugging. */ + ( mainCHECK_TIMER_PERIOD_MS ), /* The timer period, in this case 3000ms (3s). */ + pdTRUE, /* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */ + ( void * ) 0, /* The ID is not used, so can be set to anything. */ + prvCheckTimerCallback /* The callback function that inspects the status of all the other tasks. */ + ); + + /* Sanity check that the timer was created. */ + configASSERT( xCheckTimer ); + + /* Start the check timer. */ + xTimerStart( xCheckTimer, 0UL ); + + /* Create a few standard demo tasks, just so there are tasks running to + view on the web server and via the command line command interpreter. */ + vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY ); /* Register two command line commands to show task stats and run time stats respectively. */ - vCmdIntRegisterCommand( &xTaskStats ); - vCmdIntRegisterCommand( &xRunTimeStats ); + xCmdIntRegisterCommand( &xTaskStats ); + xCmdIntRegisterCommand( &xRunTimeStats ); /* Start the scheduler itself. */ vTaskStartScheduler(); - /* Should never get here unless there was not enough heap space to create - the idle and other system tasks. */ - return 0; + /* This line should never be reached. If it does execute then there was + insufficient FreeRTOS heap memory available for the idle and/or timer + tasks to be created. */ + for( ;; ) + { + Sleep( ulLongTime_ms ); + } } /*-----------------------------------------------------------*/ -static void prvCheckTask( void *pvParameters ) +static void prvCheckTimerCallback( xTimerHandle xTimer ) { -portTickType xNextWakeTime; -const portTickType xCycleFrequency = 1000 / portTICK_RATE_MS; - - /* Just to remove compiler warning. */ - ( void ) pvParameters; - - /* Initialise xNextWakeTime - this only needs to be done once. */ - xNextWakeTime = xTaskGetTickCount(); - - for( ;; ) + /* The parameter is not used in this case. */ + ( void ) xTimer; + + /* Check the standard demo tasks are running without error. Latch the + latest reported error in the pcStatusMessage character pointer. The latched + string can be viewed using the embedded web server and the command line + interpreter. This project is really to demonstrate the lwIP stack - so very + few tasks are created - and those that are created are created purely so + there is something to view. */ + if( xAreGenericQueueTasksStillRunning() != pdTRUE ) { - /* Place this task in the blocked state until it is time to run again. */ - vTaskDelayUntil( &xNextWakeTime, xCycleFrequency ); - - /* Check the standard demo tasks are running without error. */ - if( xAreTimerDemoTasksStillRunning( xCycleFrequency ) != pdTRUE ) - { - pcStatusMessage = "Error: TimerDemo"; - } - else if( xAreIntegerMathsTaskStillRunning() != pdTRUE ) - { - pcStatusMessage = "Error: IntMath"; - } - else if( xAreGenericQueueTasksStillRunning() != pdTRUE ) - { - pcStatusMessage = "Error: GenQueue"; - } - else if( xAreQueuePeekTasksStillRunning() != pdTRUE ) - { - pcStatusMessage = "Error: QueuePeek"; - } - else if( xAreBlockingQueuesStillRunning() != pdTRUE ) - { - pcStatusMessage = "Error: BlockQueue"; - } - else if( xAreSemaphoreTasksStillRunning() != pdTRUE ) - { - pcStatusMessage = "Error: SemTest"; - } - else if( xArePollingQueuesStillRunning() != pdTRUE ) - { - pcStatusMessage = "Error: PollQueue"; - } - else if( xAreMathsTaskStillRunning() != pdPASS ) - { - pcStatusMessage = "Error: Flop"; - } - else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE ) - { - pcStatusMessage = "Error: RecMutex"; - } - else if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE ) - { - pcStatusMessage = "Error: CountSem"; - } - - /* This is the only task that uses stdout so its ok to call printf() - directly. */ - printf( "%s - %d\r\n", pcStatusMessage, xTaskGetTickCount() ); + pcStatusMessage = "Error: The GenQueue test reported an error."; } } /*-----------------------------------------------------------*/ @@ -323,18 +255,6 @@ const unsigned long ulLongSleep = 1000UL; } /*-----------------------------------------------------------*/ -void vApplicationTickHook( void ) -{ - #if configINCLUDE_STANDARD_DEMO_TASKS == 1 - { - /* Call the periodic timer test, which tests the timer API functions that - can be called from an ISR. */ - vTimerPeriodicISRTests(); - } - #endif -} -/*-----------------------------------------------------------*/ - void vAssertCalled( void ) { const unsigned long ulLongSleep = 1000UL; @@ -398,6 +318,7 @@ unsigned long ulReturn; static const signed char *prvTaskStatsCommand( void ) { static signed char *pcReturn = NULL; +static char cTxBuffer[ 1024 ]; /*_RB_ Remove this. */ /* This is the callback function that is executed when the command line command defined by the xTaskStats structure is entered. This function @@ -425,6 +346,8 @@ static signed char *pcReturn = NULL; static const signed char *prvRunTimeStatsCommand( void ) { static signed char *pcReturn = NULL; +static char cTxBuffer[ 1024 ]; /*_RB_ Remove this. */ + /* This is the callback function that is executed when the command line command defined by the xRunTimeStats structure is entered. This function