Move the MSVC/lwIP code into the main line.
parent
1aa52c2a7a
commit
d53ed61cab
@ -0,0 +1,152 @@
|
|||||||
|
/*
|
||||||
|
FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd.
|
||||||
|
|
||||||
|
|
||||||
|
***************************************************************************
|
||||||
|
* *
|
||||||
|
* FreeRTOS tutorial books are available in pdf and paperback. *
|
||||||
|
* Complete, revised, and edited pdf reference manuals are also *
|
||||||
|
* available. *
|
||||||
|
* *
|
||||||
|
* Purchasing FreeRTOS documentation will not only help you, by *
|
||||||
|
* ensuring you get running as quickly as possible and with an *
|
||||||
|
* in-depth knowledge of how to use FreeRTOS, it will also help *
|
||||||
|
* the FreeRTOS project to continue with its mission of providing *
|
||||||
|
* professional grade, cross platform, de facto standard solutions *
|
||||||
|
* for microcontrollers - completely free of charge! *
|
||||||
|
* *
|
||||||
|
* >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
|
||||||
|
* *
|
||||||
|
* Thank you for using FreeRTOS, and thank you for your support! *
|
||||||
|
* *
|
||||||
|
***************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
This file is part of the FreeRTOS distribution.
|
||||||
|
|
||||||
|
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License (version 2) as published by the
|
||||||
|
Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
|
||||||
|
>>>NOTE<<< The modification to the GPL is included to allow you to
|
||||||
|
distribute a combined work that includes FreeRTOS without being obliged to
|
||||||
|
provide the source code for proprietary components outside of the FreeRTOS
|
||||||
|
kernel. FreeRTOS is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
more details. You should have received a copy of the GNU General Public
|
||||||
|
License and the FreeRTOS license exception along with FreeRTOS; if not it
|
||||||
|
can be viewed here: http://www.freertos.org/a00114.html and also obtained
|
||||||
|
by writing to Richard Barry, contact details for whom are available on the
|
||||||
|
FreeRTOS WEB site.
|
||||||
|
|
||||||
|
1 tab == 4 spaces!
|
||||||
|
|
||||||
|
http://www.FreeRTOS.org - Documentation, latest information, license and
|
||||||
|
contact details.
|
||||||
|
|
||||||
|
http://www.SafeRTOS.com - A version that is certified for use in safety
|
||||||
|
critical systems.
|
||||||
|
|
||||||
|
http://www.OpenRTOS.com - Commercial support, development, porting,
|
||||||
|
licensing and training services.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef FREERTOS_CONFIG_H
|
||||||
|
#define FREERTOS_CONFIG_H
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------
|
||||||
|
* Application specific definitions.
|
||||||
|
*
|
||||||
|
* These definitions should be adjusted for your particular hardware and
|
||||||
|
* application requirements.
|
||||||
|
*
|
||||||
|
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
|
||||||
|
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
|
||||||
|
*----------------------------------------------------------*/
|
||||||
|
|
||||||
|
#define configINCLUDE_STANDARD_DEMO_TASKS 1
|
||||||
|
|
||||||
|
#define configUSE_PREEMPTION 1
|
||||||
|
#define configUSE_IDLE_HOOK 1
|
||||||
|
#define configUSE_TICK_HOOK 0
|
||||||
|
#define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */
|
||||||
|
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 60 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the win32 thread. */
|
||||||
|
#define configTOTAL_HEAP_SIZE ( ( size_t ) 0 ) /* This parameter has no effect when heap_3.c is included in the project. */
|
||||||
|
#define configMAX_TASK_NAME_LEN ( 6 )
|
||||||
|
#define configUSE_TRACE_FACILITY 1
|
||||||
|
#define configUSE_16_BIT_TICKS 0
|
||||||
|
#define configIDLE_SHOULD_YIELD 1
|
||||||
|
#define configUSE_CO_ROUTINES 0
|
||||||
|
#define configUSE_MUTEXES 1
|
||||||
|
#define configCHECK_FOR_STACK_OVERFLOW 0
|
||||||
|
#define configUSE_RECURSIVE_MUTEXES 1
|
||||||
|
#define configQUEUE_REGISTRY_SIZE 0
|
||||||
|
#define configUSE_MALLOC_FAILED_HOOK 1
|
||||||
|
#define configUSE_APPLICATION_TASK_TAG 0
|
||||||
|
#define configUSE_COUNTING_SEMAPHORES 1
|
||||||
|
#define configUSE_ALTERNATIVE_API 1
|
||||||
|
|
||||||
|
#define configUSE_TIMERS 1
|
||||||
|
#define configTIMER_TASK_PRIORITY 2
|
||||||
|
#define configTIMER_QUEUE_LENGTH 20
|
||||||
|
#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 )
|
||||||
|
|
||||||
|
#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 7 )
|
||||||
|
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
|
||||||
|
|
||||||
|
|
||||||
|
/* Co-routine definitions. */
|
||||||
|
#define configUSE_CO_ROUTINES 0
|
||||||
|
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
|
||||||
|
|
||||||
|
/* Set the following definitions to 1 to include the API function, or zero
|
||||||
|
to exclude the API function. */
|
||||||
|
|
||||||
|
#define INCLUDE_vTaskPrioritySet 1
|
||||||
|
#define INCLUDE_uxTaskPriorityGet 1
|
||||||
|
#define INCLUDE_vTaskDelete 1
|
||||||
|
#define INCLUDE_vTaskCleanUpResources 0
|
||||||
|
#define INCLUDE_vTaskSuspend 1
|
||||||
|
#define INCLUDE_vTaskDelayUntil 1
|
||||||
|
#define INCLUDE_vTaskDelay 1
|
||||||
|
#define INCLUDE_uxTaskGetStackHighWaterMark 1
|
||||||
|
#define INCLUDE_xTaskGetSchedulerState 1
|
||||||
|
|
||||||
|
/* Run time stats gathering definitions. */
|
||||||
|
unsigned long ulMainGetRunTimeCounterValue( void );
|
||||||
|
void vMainConfigureTimerForRunTimeStats( void );
|
||||||
|
#define configGENERATE_RUN_TIME_STATS 1
|
||||||
|
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vMainConfigureTimerForRunTimeStats()
|
||||||
|
#define portGET_RUN_TIME_COUNTER_VALUE() ulMainGetRunTimeCounterValue()
|
||||||
|
|
||||||
|
|
||||||
|
/*extern void vAssertCalled( void );
|
||||||
|
#define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled()*/
|
||||||
|
|
||||||
|
#define configNETWORK_INTERFACE_TO_USE 1L
|
||||||
|
|
||||||
|
#define configMAC_ISR_SIMULATOR_PRIORITY ( 6 )
|
||||||
|
#define configLWIP_TASK_PRIORITY ( 5 )
|
||||||
|
|
||||||
|
/* MAC address configuration. */
|
||||||
|
#define configMAC_ADDR0 0x00
|
||||||
|
#define configMAC_ADDR1 0x13
|
||||||
|
#define configMAC_ADDR2 0x14
|
||||||
|
#define configMAC_ADDR3 0x15
|
||||||
|
#define configMAC_ADDR4 0x15
|
||||||
|
#define configMAC_ADDR5 0x16
|
||||||
|
|
||||||
|
/* IP address configuration. */
|
||||||
|
#define configIP_ADDR0 192
|
||||||
|
#define configIP_ADDR1 168
|
||||||
|
#define configIP_ADDR2 0
|
||||||
|
#define configIP_ADDR3 200
|
||||||
|
|
||||||
|
/* Netmask configuration. */
|
||||||
|
#define configNET_MASK0 255
|
||||||
|
#define configNET_MASK1 255
|
||||||
|
#define configNET_MASK2 255
|
||||||
|
#define configNET_MASK3 0
|
||||||
|
|
||||||
|
#endif /* FREERTOS_CONFIG_H */
|
Binary file not shown.
@ -0,0 +1,466 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="Resource Files">
|
||||||
|
<UniqueIdentifier>{38712199-cebf-4124-bf15-398f7c3419ea}</UniqueIdentifier>
|
||||||
|
<Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="FreeRTOS Source">
|
||||||
|
<UniqueIdentifier>{af3445a1-4908-4170-89ed-39345d90d30c}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="FreeRTOS Source\Source">
|
||||||
|
<UniqueIdentifier>{f32be356-4763-4cae-9020-974a2638cb08}</UniqueIdentifier>
|
||||||
|
<Extensions>*.c</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="FreeRTOS Source\Include">
|
||||||
|
<UniqueIdentifier>{a60060e3-3949-4f60-b025-cb84164ae9ed}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Demo App Source">
|
||||||
|
<UniqueIdentifier>{34567deb-d5ab-4a56-8640-0aaec609521a}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Demo App Source\Common Demo Tasks">
|
||||||
|
<UniqueIdentifier>{2d4a700c-06e3-4dd2-afbe-ab1be71ebe2a}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="FreeRTOS Source\Source\Portable">
|
||||||
|
<UniqueIdentifier>{88f409e6-d396-4ac5-94bd-7a99c914be46}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Demo App Source\Common Demo Tasks\ModifiedForLowTickRate">
|
||||||
|
<UniqueIdentifier>{143cf5a3-f134-4439-9f71-a201ae23b44b}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Configuration Files">
|
||||||
|
<UniqueIdentifier>{19ff1a34-36de-4c48-9d10-3fb1fa0d1fa4}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hpp;hxx;hm;inl</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="lwIP">
|
||||||
|
<UniqueIdentifier>{f1895f21-b338-4923-bec6-c20eba7b48af}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="lwIP\Arch">
|
||||||
|
<UniqueIdentifier>{2d5e204f-7bfe-467c-b8fc-daf0120b3380}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="lwIP\Source">
|
||||||
|
<UniqueIdentifier>{ac8f3f6f-979d-4405-9b5d-d22ddab77efe}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="lwIP\Source\API">
|
||||||
|
<UniqueIdentifier>{d0f66056-3a9d-4160-986b-6c770c5c05b6}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="lwIP\Source\Include">
|
||||||
|
<UniqueIdentifier>{2c08d348-4005-406d-9941-735524db4bef}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="lwIP\Source\Core">
|
||||||
|
<UniqueIdentifier>{c791a789-07eb-46aa-9934-23684669793b}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="lwIP\Source\NetIf">
|
||||||
|
<UniqueIdentifier>{d7b51b46-8083-4d4e-ba8b-03e7c96a79ae}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="lwIP\Source\Core\IPv4">
|
||||||
|
<UniqueIdentifier>{268723e7-d189-420d-ba66-26c24054b16b}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="lwIP\Source\Include\IPv4">
|
||||||
|
<UniqueIdentifier>{ae3a6e4d-2101-4d1d-be3a-c19a72fe0ed0}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="lwIP\Source\Include\netif">
|
||||||
|
<UniqueIdentifier>{aef10a28-c761-43f8-aad6-adc6e4963cef}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="lwIP\Source\Include\lwIP">
|
||||||
|
<UniqueIdentifier>{2a415654-7006-4079-b071-86fe1b73e811}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="lwIP\Source\Include\IPv4\lwIP">
|
||||||
|
<UniqueIdentifier>{cc0c5b7c-cd80-4573-bdc1-122b1c9f685a}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="lwIP\Source\Core\SNMP">
|
||||||
|
<UniqueIdentifier>{a8022720-9bfe-4681-b4ef-4785c87a815e}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="lwIP_Apps">
|
||||||
|
<UniqueIdentifier>{c3366d35-95df-4c03-a752-3ae631ec6bba}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="lwIP_Apps\httpd_raw">
|
||||||
|
<UniqueIdentifier>{6c4a261d-ca37-4528-ad50-8f04032898cb}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="main.c">
|
||||||
|
<Filter>Demo App Source</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\Source\list.c">
|
||||||
|
<Filter>FreeRTOS Source\Source</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\Source\queue.c">
|
||||||
|
<Filter>FreeRTOS Source\Source</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\Source\tasks.c">
|
||||||
|
<Filter>FreeRTOS Source\Source</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\Source\portable\MemMang\heap_3.c">
|
||||||
|
<Filter>FreeRTOS Source\Source</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\Source\portable\MSVC-MingW\port.c">
|
||||||
|
<Filter>FreeRTOS Source\Source\Portable</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\Minimal\flop.c">
|
||||||
|
<Filter>Demo App Source\Common Demo Tasks</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\Minimal\GenQTest.c">
|
||||||
|
<Filter>Demo App Source\Common Demo Tasks</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\Minimal\integer.c">
|
||||||
|
<Filter>Demo App Source\Common Demo Tasks</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\Minimal\PollQ.c">
|
||||||
|
<Filter>Demo App Source\Common Demo Tasks</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\Minimal\QPeek.c">
|
||||||
|
<Filter>Demo App Source\Common Demo Tasks</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\Minimal\semtest.c">
|
||||||
|
<Filter>Demo App Source\Common Demo Tasks</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\Minimal\BlockQ.c">
|
||||||
|
<Filter>Demo App Source\Common Demo Tasks</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\Minimal\blocktim.c">
|
||||||
|
<Filter>Demo App Source\Common Demo Tasks</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DemosModifiedForLowTickRate\recmutex.c">
|
||||||
|
<Filter>Demo App Source\Common Demo Tasks\ModifiedForLowTickRate</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\Source\timers.c">
|
||||||
|
<Filter>FreeRTOS Source\Source</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\Minimal\timerdemo.c">
|
||||||
|
<Filter>Demo App Source\Common Demo Tasks</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\Minimal\countsem.c">
|
||||||
|
<Filter>Demo App Source\Common Demo Tasks</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\api\tcpip.c">
|
||||||
|
<Filter>lwIP\Source\API</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\api\api_lib.c">
|
||||||
|
<Filter>lwIP\Source\API</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\api\api_msg.c">
|
||||||
|
<Filter>lwIP\Source\API</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\api\err.c">
|
||||||
|
<Filter>lwIP\Source\API</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\api\netbuf.c">
|
||||||
|
<Filter>lwIP\Source\API</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\api\netdb.c">
|
||||||
|
<Filter>lwIP\Source\API</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\api\netifapi.c">
|
||||||
|
<Filter>lwIP\Source\API</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\api\sockets.c">
|
||||||
|
<Filter>lwIP\Source\API</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\core\ipv4\ip_frag.c">
|
||||||
|
<Filter>lwIP\Source\Core\IPv4</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\core\ipv4\autoip.c">
|
||||||
|
<Filter>lwIP\Source\Core\IPv4</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\core\ipv4\icmp.c">
|
||||||
|
<Filter>lwIP\Source\Core\IPv4</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\core\ipv4\igmp.c">
|
||||||
|
<Filter>lwIP\Source\Core\IPv4</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\core\ipv4\inet.c">
|
||||||
|
<Filter>lwIP\Source\Core\IPv4</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\core\ipv4\inet_chksum.c">
|
||||||
|
<Filter>lwIP\Source\Core\IPv4</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\core\ipv4\ip.c">
|
||||||
|
<Filter>lwIP\Source\Core\IPv4</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\core\ipv4\ip_addr.c">
|
||||||
|
<Filter>lwIP\Source\Core\IPv4</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\core\udp.c">
|
||||||
|
<Filter>lwIP\Source\Core</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\core\def.c">
|
||||||
|
<Filter>lwIP\Source\Core</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\core\dhcp.c">
|
||||||
|
<Filter>lwIP\Source\Core</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\core\dns.c">
|
||||||
|
<Filter>lwIP\Source\Core</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\core\init.c">
|
||||||
|
<Filter>lwIP\Source\Core</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\core\mem.c">
|
||||||
|
<Filter>lwIP\Source\Core</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\core\memp.c">
|
||||||
|
<Filter>lwIP\Source\Core</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\core\netif.c">
|
||||||
|
<Filter>lwIP\Source\Core</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\core\pbuf.c">
|
||||||
|
<Filter>lwIP\Source\Core</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\core\raw.c">
|
||||||
|
<Filter>lwIP\Source\Core</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\core\stats.c">
|
||||||
|
<Filter>lwIP\Source\Core</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\core\sys.c">
|
||||||
|
<Filter>lwIP\Source\Core</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\core\tcp.c">
|
||||||
|
<Filter>lwIP\Source\Core</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\core\tcp_in.c">
|
||||||
|
<Filter>lwIP\Source\Core</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\core\tcp_out.c">
|
||||||
|
<Filter>lwIP\Source\Core</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\ports\win32\sys_arch.c">
|
||||||
|
<Filter>lwIP\Arch</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\core\lwip_timers.c">
|
||||||
|
<Filter>lwIP\Source\Core</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\netif\etharp.c">
|
||||||
|
<Filter>lwIP\Source\NetIf</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\ports\win32\ethernetif.c">
|
||||||
|
<Filter>lwIP\Source\NetIf</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\core\snmp\msg_out.c">
|
||||||
|
<Filter>lwIP\Source\Core\SNMP</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\core\snmp\asn1_dec.c">
|
||||||
|
<Filter>lwIP\Source\Core\SNMP</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\core\snmp\asn1_enc.c">
|
||||||
|
<Filter>lwIP\Source\Core\SNMP</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\core\snmp\mib2.c">
|
||||||
|
<Filter>lwIP\Source\Core\SNMP</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\core\snmp\mib_structs.c">
|
||||||
|
<Filter>lwIP\Source\Core\SNMP</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\ethernet\lwip-1.4.0\src\core\snmp\msg_in.c">
|
||||||
|
<Filter>lwIP\Source\Core\SNMP</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="lwIP_Apps\apps\httpserver_raw\httpd.c">
|
||||||
|
<Filter>lwIP_Apps\httpd_raw</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="lwIP_Apps\apps\httpserver_raw\fs.c">
|
||||||
|
<Filter>lwIP_Apps\httpd_raw</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="lwIP_Apps\lwIP_Apps.c">
|
||||||
|
<Filter>lwIP_Apps</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="lwIP_Apps\BasicSocketCommandServer.c">
|
||||||
|
<Filter>lwIP_Apps</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Common\Utils\CommandInterpreter.c">
|
||||||
|
<Filter>Demo App Source</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="FreeRTOSConfig.h">
|
||||||
|
<Filter>Configuration Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\Source\include\croutine.h">
|
||||||
|
<Filter>FreeRTOS Source\Include</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\Source\include\FreeRTOS.h">
|
||||||
|
<Filter>FreeRTOS Source\Include</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\Source\include\list.h">
|
||||||
|
<Filter>FreeRTOS Source\Include</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\Source\include\portable.h">
|
||||||
|
<Filter>FreeRTOS Source\Include</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\Source\include\projdefs.h">
|
||||||
|
<Filter>FreeRTOS Source\Include</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\Source\include\queue.h">
|
||||||
|
<Filter>FreeRTOS Source\Include</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\Source\include\semphr.h">
|
||||||
|
<Filter>FreeRTOS Source\Include</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\Source\include\task.h">
|
||||||
|
<Filter>FreeRTOS Source\Include</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\Source\portable\MSVC-MingW\portmacro.h">
|
||||||
|
<Filter>FreeRTOS Source\Include</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\Source\include\timers.h">
|
||||||
|
<Filter>FreeRTOS Source\Include</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\Source\include\timer_test.h">
|
||||||
|
<Filter>FreeRTOS Source\Include</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\ipv4\lwip\ip_frag.h">
|
||||||
|
<Filter>lwIP\Source\Include\IPv4\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\ipv4\lwip\autoip.h">
|
||||||
|
<Filter>lwIP\Source\Include\IPv4\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\ipv4\lwip\icmp.h">
|
||||||
|
<Filter>lwIP\Source\Include\IPv4\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\ipv4\lwip\igmp.h">
|
||||||
|
<Filter>lwIP\Source\Include\IPv4\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\ipv4\lwip\inet.h">
|
||||||
|
<Filter>lwIP\Source\Include\IPv4\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\ipv4\lwip\inet_chksum.h">
|
||||||
|
<Filter>lwIP\Source\Include\IPv4\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\ipv4\lwip\ip.h">
|
||||||
|
<Filter>lwIP\Source\Include\IPv4\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\ipv4\lwip\ip_addr.h">
|
||||||
|
<Filter>lwIP\Source\Include\IPv4\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\netif\etharp.h">
|
||||||
|
<Filter>lwIP\Source\Include\netif</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\lwip\udp.h">
|
||||||
|
<Filter>lwIP\Source\Include\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\lwip\api.h">
|
||||||
|
<Filter>lwIP\Source\Include\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\lwip\api_msg.h">
|
||||||
|
<Filter>lwIP\Source\Include\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\lwip\arch.h">
|
||||||
|
<Filter>lwIP\Source\Include\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\lwip\debug.h">
|
||||||
|
<Filter>lwIP\Source\Include\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\lwip\def.h">
|
||||||
|
<Filter>lwIP\Source\Include\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\lwip\dhcp.h">
|
||||||
|
<Filter>lwIP\Source\Include\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\lwip\dns.h">
|
||||||
|
<Filter>lwIP\Source\Include\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\lwip\err.h">
|
||||||
|
<Filter>lwIP\Source\Include\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\lwip\init.h">
|
||||||
|
<Filter>lwIP\Source\Include\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\lwip\mem.h">
|
||||||
|
<Filter>lwIP\Source\Include\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\lwip\memp.h">
|
||||||
|
<Filter>lwIP\Source\Include\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\lwip\memp_std.h">
|
||||||
|
<Filter>lwIP\Source\Include\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\lwip\netbuf.h">
|
||||||
|
<Filter>lwIP\Source\Include\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\lwip\netdb.h">
|
||||||
|
<Filter>lwIP\Source\Include\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\lwip\netif.h">
|
||||||
|
<Filter>lwIP\Source\Include\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\lwip\netifapi.h">
|
||||||
|
<Filter>lwIP\Source\Include\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\lwip\opt.h">
|
||||||
|
<Filter>lwIP\Source\Include\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\lwip\pbuf.h">
|
||||||
|
<Filter>lwIP\Source\Include\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\lwip\raw.h">
|
||||||
|
<Filter>lwIP\Source\Include\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\lwip\sio.h">
|
||||||
|
<Filter>lwIP\Source\Include\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\lwip\snmp.h">
|
||||||
|
<Filter>lwIP\Source\Include\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\lwip\snmp_asn1.h">
|
||||||
|
<Filter>lwIP\Source\Include\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\lwip\snmp_msg.h">
|
||||||
|
<Filter>lwIP\Source\Include\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\lwip\snmp_structs.h">
|
||||||
|
<Filter>lwIP\Source\Include\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\lwip\sockets.h">
|
||||||
|
<Filter>lwIP\Source\Include\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\lwip\stats.h">
|
||||||
|
<Filter>lwIP\Source\Include\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\lwip\sys.h">
|
||||||
|
<Filter>lwIP\Source\Include\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\lwip\tcp.h">
|
||||||
|
<Filter>lwIP\Source\Include\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\lwip\tcp_impl.h">
|
||||||
|
<Filter>lwIP\Source\Include\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\lwip\tcpip.h">
|
||||||
|
<Filter>lwIP\Source\Include\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\src\include\lwip\timers.h">
|
||||||
|
<Filter>lwIP\Source\Include\lwIP</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\ports\win32\include\arch\sys_arch.h">
|
||||||
|
<Filter>lwIP\Arch</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\ports\win32\include\arch\bpstruct.h">
|
||||||
|
<Filter>lwIP\Arch</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\ports\win32\include\arch\cc.h">
|
||||||
|
<Filter>lwIP\Arch</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\ports\win32\include\arch\epstruct.h">
|
||||||
|
<Filter>lwIP\Arch</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\ports\win32\include\arch\perf.h">
|
||||||
|
<Filter>lwIP\Arch</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\ports\win32\include\lwipopts.h">
|
||||||
|
<Filter>lwIP\Arch</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\ports\win32\lwippools.h">
|
||||||
|
<Filter>lwIP\Arch</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Common\ethernet\lwip-1.4.0\ports\win32\lwipcfg_msvc.h">
|
||||||
|
<Filter>lwIP\Arch</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="lwIP_Apps\lwipcfg_msvc.h">
|
||||||
|
<Filter>Configuration Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="lwIP_Apps\lwipopts.h">
|
||||||
|
<Filter>Configuration Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
@ -0,0 +1,188 @@
|
|||||||
|
/*
|
||||||
|
FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd.
|
||||||
|
|
||||||
|
|
||||||
|
***************************************************************************
|
||||||
|
* *
|
||||||
|
* FreeRTOS tutorial books are available in pdf and paperback. *
|
||||||
|
* Complete, revised, and edited pdf reference manuals are also *
|
||||||
|
* available. *
|
||||||
|
* *
|
||||||
|
* Purchasing FreeRTOS documentation will not only help you, by *
|
||||||
|
* ensuring you get running as quickly as possible and with an *
|
||||||
|
* in-depth knowledge of how to use FreeRTOS, it will also help *
|
||||||
|
* the FreeRTOS project to continue with its mission of providing *
|
||||||
|
* professional grade, cross platform, de facto standard solutions *
|
||||||
|
* for microcontrollers - completely free of charge! *
|
||||||
|
* *
|
||||||
|
* >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
|
||||||
|
* *
|
||||||
|
* Thank you for using FreeRTOS, and thank you for your support! *
|
||||||
|
* *
|
||||||
|
***************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
This file is part of the FreeRTOS distribution.
|
||||||
|
|
||||||
|
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License (version 2) as published by the
|
||||||
|
Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
|
||||||
|
>>>NOTE<<< The modification to the GPL is included to allow you to
|
||||||
|
distribute a combined work that includes FreeRTOS without being obliged to
|
||||||
|
provide the source code for proprietary components outside of the FreeRTOS
|
||||||
|
kernel. FreeRTOS is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
more details. You should have received a copy of the GNU General Public
|
||||||
|
License and the FreeRTOS license exception along with FreeRTOS; if not it
|
||||||
|
can be viewed here: http://www.freertos.org/a00114.html and also obtained
|
||||||
|
by writing to Richard Barry, contact details for whom are available on the
|
||||||
|
FreeRTOS WEB site.
|
||||||
|
|
||||||
|
1 tab == 4 spaces!
|
||||||
|
|
||||||
|
http://www.FreeRTOS.org - Documentation, latest information, license and
|
||||||
|
contact details.
|
||||||
|
|
||||||
|
http://www.SafeRTOS.com - A version that is certified for use in safety
|
||||||
|
critical systems.
|
||||||
|
|
||||||
|
http://www.OpenRTOS.com - Commercial support, development, porting,
|
||||||
|
licensing and training services.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Standard includes. */
|
||||||
|
#include "stdlib.h"
|
||||||
|
|
||||||
|
/* lwIP core includes */
|
||||||
|
#include "lwip/opt.h"
|
||||||
|
#include "lwip/sockets.h"
|
||||||
|
|
||||||
|
/* FreeRTOS includes. */
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
|
|
||||||
|
/* Utils includes. */
|
||||||
|
#include "CommandInterpreter.h"
|
||||||
|
|
||||||
|
#define cmdMAX_INPUT_SIZE 20
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
void vBasicTelnetServer( void *pvParameters )
|
||||||
|
{
|
||||||
|
long lSocket, lClientFd, lBytes, lAddrLen = sizeof( struct sockaddr_in );
|
||||||
|
struct sockaddr_in sLocalAddr;
|
||||||
|
struct sockaddr_in client_addr;
|
||||||
|
const signed char *pcWelcomeMessage = "FreeRTOS command server - connection accepted.\r\nType Help to view a list of registered commands.\r\n\r\n>";
|
||||||
|
const signed char *pcString;
|
||||||
|
signed char cInChar, cInputIndex;
|
||||||
|
signed char cInputString[ cmdMAX_INPUT_SIZE ];
|
||||||
|
|
||||||
|
( void ) pvParameters;
|
||||||
|
|
||||||
|
lSocket = lwip_socket(AF_INET, SOCK_STREAM, 0);
|
||||||
|
|
||||||
|
if( lSocket >= 0 )
|
||||||
|
{
|
||||||
|
memset((char *)&sLocalAddr, 0, sizeof(sLocalAddr));
|
||||||
|
sLocalAddr.sin_family = AF_INET;
|
||||||
|
sLocalAddr.sin_len = sizeof(sLocalAddr);
|
||||||
|
sLocalAddr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||||
|
sLocalAddr.sin_port = ntohs( ( ( unsigned short ) 23 ) );
|
||||||
|
|
||||||
|
if( lwip_bind( lSocket, ( struct sockaddr *) &sLocalAddr, sizeof( sLocalAddr ) ) < 0 )
|
||||||
|
{
|
||||||
|
lwip_close( lSocket );
|
||||||
|
vTaskDelete( NULL );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( lwip_listen( lSocket, 20 ) != 0 )
|
||||||
|
{
|
||||||
|
lwip_close( lSocket );
|
||||||
|
vTaskDelete( NULL );
|
||||||
|
}
|
||||||
|
|
||||||
|
for( ;; )
|
||||||
|
{
|
||||||
|
|
||||||
|
lClientFd = lwip_accept(lSocket, ( struct sockaddr * ) &client_addr, ( u32_t * ) &lAddrLen );
|
||||||
|
|
||||||
|
if( lClientFd > 0L )
|
||||||
|
{
|
||||||
|
lwip_send( lClientFd, pcWelcomeMessage, strlen( ( const char * ) pcWelcomeMessage ), 0 );
|
||||||
|
|
||||||
|
cInputIndex = 0;
|
||||||
|
memset( cInputString, 0x00, cmdMAX_INPUT_SIZE );
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
lBytes = lwip_recv( lClientFd, &cInChar, sizeof( cInChar ), 0 );
|
||||||
|
|
||||||
|
if( lBytes > 0L )
|
||||||
|
{
|
||||||
|
if( cInChar == '\n' )
|
||||||
|
{
|
||||||
|
/* The input string has been terminated. Was the
|
||||||
|
input a quit command? */
|
||||||
|
if( strcmp( "quit", ( const char * ) cInputString ) == 0 )
|
||||||
|
{
|
||||||
|
/* Set lBytes to 0 to close the connection. */
|
||||||
|
lBytes = 0L;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* The input string was not a quit command.
|
||||||
|
Pass the string to the command interpreter. */
|
||||||
|
while( ( pcString = pcProcessCommand( cInputString ) ) != NULL )
|
||||||
|
{
|
||||||
|
/* A string has been generated by the
|
||||||
|
command interpreter. Send it. */
|
||||||
|
lwip_send( lClientFd, pcString, strlen( ( const char * ) pcString ), 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* All the strings generated by the input
|
||||||
|
command have been sent. Clear the input
|
||||||
|
string ready to receive the next command. */
|
||||||
|
cInputIndex = 0;
|
||||||
|
memset( cInputString, 0x00, cmdMAX_INPUT_SIZE );
|
||||||
|
lwip_send( lClientFd, "\r\n>", strlen( "\r\n>" ), 0 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( cInChar == '\r' )
|
||||||
|
{
|
||||||
|
/* Ignore the character. */
|
||||||
|
}
|
||||||
|
else if( cInChar == '\b' )
|
||||||
|
{
|
||||||
|
/* Backspace was pressed. Erase the last
|
||||||
|
character in the string - if any. */
|
||||||
|
if( cInputIndex > 0 )
|
||||||
|
{
|
||||||
|
cInputIndex--;
|
||||||
|
cInputString[ cInputIndex ] = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* A character was entered. Add it to the string
|
||||||
|
entered so far. When a \n is entered the complete
|
||||||
|
string will be passed to the command interpreter. */
|
||||||
|
if( cInputIndex < cmdMAX_INPUT_SIZE )
|
||||||
|
{
|
||||||
|
cInputString[ cInputIndex ] = cInChar;
|
||||||
|
cInputIndex++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} while( lBytes > 0L );
|
||||||
|
|
||||||
|
lwip_close( lClientFd );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,177 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||||
|
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||||
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||||
|
* OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* This file is part of the lwIP TCP/IP stack.
|
||||||
|
*
|
||||||
|
* Author: Adam Dunkels <adam@sics.se>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#include "lwip/opt.h"
|
||||||
|
#include "lwip/def.h"
|
||||||
|
#include "fs.h"
|
||||||
|
#include "fsdata.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/** Set this to 1 to include "fsdata_custom.c" instead of "fsdata.c" for the
|
||||||
|
* file system (to prevent changing the file included in CVS) */
|
||||||
|
#ifndef HTTPD_USE_CUSTUM_FSDATA
|
||||||
|
#define HTTPD_USE_CUSTUM_FSDATA 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HTTPD_USE_CUSTUM_FSDATA
|
||||||
|
#include "fsdata_custom.c"
|
||||||
|
#else /* HTTPD_USE_CUSTUM_FSDATA */
|
||||||
|
#include "fsdata.c"
|
||||||
|
#endif /* HTTPD_USE_CUSTUM_FSDATA */
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
/* Define the number of open files that we can support. */
|
||||||
|
#ifndef LWIP_MAX_OPEN_FILES
|
||||||
|
#define LWIP_MAX_OPEN_FILES 10
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Define the file system memory allocation structure. */
|
||||||
|
struct fs_table {
|
||||||
|
struct fs_file file;
|
||||||
|
u8_t inuse;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Allocate file system memory */
|
||||||
|
struct fs_table fs_memory[LWIP_MAX_OPEN_FILES];
|
||||||
|
|
||||||
|
#if LWIP_HTTPD_CUSTOM_FILES
|
||||||
|
int fs_open_custom(struct fs_file *file, const char *name);
|
||||||
|
void fs_close_custom(struct fs_file *file);
|
||||||
|
#endif /* LWIP_HTTPD_CUSTOM_FILES */
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
static struct fs_file *
|
||||||
|
fs_malloc(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for(i = 0; i < LWIP_MAX_OPEN_FILES; i++) {
|
||||||
|
if(fs_memory[i].inuse == 0) {
|
||||||
|
fs_memory[i].inuse = 1;
|
||||||
|
return(&fs_memory[i].file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
static void
|
||||||
|
fs_free(struct fs_file *file)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for(i = 0; i < LWIP_MAX_OPEN_FILES; i++) {
|
||||||
|
if(&fs_memory[i].file == file) {
|
||||||
|
fs_memory[i].inuse = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
struct fs_file *
|
||||||
|
fs_open(const char *name)
|
||||||
|
{
|
||||||
|
struct fs_file *file;
|
||||||
|
const struct fsdata_file *f;
|
||||||
|
|
||||||
|
file = fs_malloc();
|
||||||
|
if(file == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if LWIP_HTTPD_CUSTOM_FILES
|
||||||
|
if(fs_open_custom(file, name)) {
|
||||||
|
file->is_custom_file = 1;
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
file->is_custom_file = 0;
|
||||||
|
#endif /* LWIP_HTTPD_CUSTOM_FILES */
|
||||||
|
|
||||||
|
for(f = FS_ROOT; f != NULL; f = f->next) {
|
||||||
|
if (!strcmp(name, (char *)f->name)) {
|
||||||
|
file->data = (const char *)f->data;
|
||||||
|
file->len = f->len;
|
||||||
|
file->index = f->len;
|
||||||
|
file->pextension = NULL;
|
||||||
|
file->http_header_included = f->http_header_included;
|
||||||
|
#if HTTPD_PRECALCULATED_CHECKSUM
|
||||||
|
file->chksum_count = f->chksum_count;
|
||||||
|
file->chksum = f->chksum;
|
||||||
|
#endif /* HTTPD_PRECALCULATED_CHECKSUM */
|
||||||
|
#if LWIP_HTTPD_FILE_STATE
|
||||||
|
file->state = fs_state_init(file, name);
|
||||||
|
#endif /* #if LWIP_HTTPD_FILE_STATE */
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fs_free(file);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
fs_close(struct fs_file *file)
|
||||||
|
{
|
||||||
|
#if LWIP_HTTPD_CUSTOM_FILES
|
||||||
|
if (file->is_custom_file) {
|
||||||
|
fs_close_custom(file);
|
||||||
|
}
|
||||||
|
#endif /* LWIP_HTTPD_CUSTOM_FILES */
|
||||||
|
#if LWIP_HTTPD_FILE_STATE
|
||||||
|
fs_state_free(file, file->state);
|
||||||
|
#endif /* #if LWIP_HTTPD_FILE_STATE */
|
||||||
|
fs_free(file);
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
int
|
||||||
|
fs_read(struct fs_file *file, char *buffer, int count)
|
||||||
|
{
|
||||||
|
int read;
|
||||||
|
|
||||||
|
if(file->index == file->len) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
read = file->len - file->index;
|
||||||
|
if(read > count) {
|
||||||
|
read = count;
|
||||||
|
}
|
||||||
|
|
||||||
|
MEMCPY(buffer, (file->data + file->index), read);
|
||||||
|
file->index += read;
|
||||||
|
|
||||||
|
return(read);
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
int fs_bytes_left(struct fs_file *file)
|
||||||
|
{
|
||||||
|
return file->len - file->index;
|
||||||
|
}
|
@ -0,0 +1,100 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||||
|
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||||
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||||
|
* OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* This file is part of the lwIP TCP/IP stack.
|
||||||
|
*
|
||||||
|
* Author: Adam Dunkels <adam@sics.se>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#ifndef __FS_H__
|
||||||
|
#define __FS_H__
|
||||||
|
|
||||||
|
#include "lwip/opt.h"
|
||||||
|
|
||||||
|
/** Set this to 1 and provide the functions:
|
||||||
|
* - "int fs_open_custom(struct fs_file *file, const char *name)"
|
||||||
|
* Called first for every opened file to allow opening files
|
||||||
|
* that are not included in fsdata(_custom).c
|
||||||
|
* - "void fs_close_custom(struct fs_file *file)"
|
||||||
|
* Called to free resources allocated by fs_open_custom().
|
||||||
|
*/
|
||||||
|
#ifndef LWIP_HTTPD_CUSTOM_FILES
|
||||||
|
#define LWIP_HTTPD_CUSTOM_FILES 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** Set this to 1 to include an application state argument per file
|
||||||
|
* that is opened. This allows to keep a state per connection/file.
|
||||||
|
*/
|
||||||
|
#ifndef LWIP_HTTPD_FILE_STATE
|
||||||
|
#define LWIP_HTTPD_FILE_STATE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** HTTPD_PRECALCULATED_CHECKSUM==1: include precompiled checksums for
|
||||||
|
* predefined (MSS-sized) chunks of the files to prevent having to calculate
|
||||||
|
* the checksums at runtime. */
|
||||||
|
#ifndef HTTPD_PRECALCULATED_CHECKSUM
|
||||||
|
#define HTTPD_PRECALCULATED_CHECKSUM 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HTTPD_PRECALCULATED_CHECKSUM
|
||||||
|
struct fsdata_chksum {
|
||||||
|
u32_t offset;
|
||||||
|
u16_t chksum;
|
||||||
|
u16_t len;
|
||||||
|
};
|
||||||
|
#endif /* HTTPD_PRECALCULATED_CHECKSUM */
|
||||||
|
|
||||||
|
struct fs_file {
|
||||||
|
const char *data;
|
||||||
|
int len;
|
||||||
|
int index;
|
||||||
|
void *pextension;
|
||||||
|
#if HTTPD_PRECALCULATED_CHECKSUM
|
||||||
|
const struct fsdata_chksum *chksum;
|
||||||
|
u16_t chksum_count;
|
||||||
|
#endif /* HTTPD_PRECALCULATED_CHECKSUM */
|
||||||
|
u8_t http_header_included;
|
||||||
|
#if LWIP_HTTPD_CUSTOM_FILES
|
||||||
|
u8_t is_custom_file;
|
||||||
|
#endif /* LWIP_HTTPD_CUSTOM_FILES */
|
||||||
|
#if LWIP_HTTPD_FILE_STATE
|
||||||
|
void *state;
|
||||||
|
#endif /* LWIP_HTTPD_FILE_STATE */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct fs_file *fs_open(const char *name);
|
||||||
|
void fs_close(struct fs_file *file);
|
||||||
|
int fs_read(struct fs_file *file, char *buffer, int count);
|
||||||
|
int fs_bytes_left(struct fs_file *file);
|
||||||
|
|
||||||
|
#if LWIP_HTTPD_FILE_STATE
|
||||||
|
/** This user-defined function is called when a file is opened. */
|
||||||
|
void *fs_state_init(struct fs_file *file, const char *name);
|
||||||
|
/** This user-defined function is called when a file is closed. */
|
||||||
|
void fs_state_free(struct fs_file *file, void *state);
|
||||||
|
#endif /* #if LWIP_HTTPD_FILE_STATE */
|
||||||
|
|
||||||
|
#endif /* __FS_H__ */
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||||
|
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||||
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||||
|
* OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* This file is part of the lwIP TCP/IP stack.
|
||||||
|
*
|
||||||
|
* Author: Adam Dunkels <adam@sics.se>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#ifndef __FSDATA_H__
|
||||||
|
#define __FSDATA_H__
|
||||||
|
|
||||||
|
#include "lwip/opt.h"
|
||||||
|
#include "fs.h"
|
||||||
|
|
||||||
|
struct fsdata_file {
|
||||||
|
const struct fsdata_file *next;
|
||||||
|
const unsigned char *name;
|
||||||
|
const unsigned char *data;
|
||||||
|
int len;
|
||||||
|
u8_t http_header_included;
|
||||||
|
#if HTTPD_PRECALCULATED_CHECKSUM
|
||||||
|
u16_t chksum_count;
|
||||||
|
const struct fsdata_chksum *chksum;
|
||||||
|
#endif /* HTTPD_PRECALCULATED_CHECKSUM */
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* __FSDATA_H__ */
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,236 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||||
|
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||||
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||||
|
* OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* This file is part of the lwIP TCP/IP stack.
|
||||||
|
*
|
||||||
|
* Author: Adam Dunkels <adam@sics.se>
|
||||||
|
*
|
||||||
|
* This version of the file has been modified by Texas Instruments to offer
|
||||||
|
* simple server-side-include (SSI) and Common Gateway Interface (CGI)
|
||||||
|
* capability.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __HTTPD_H__
|
||||||
|
#define __HTTPD_H__
|
||||||
|
|
||||||
|
#include "lwip/opt.h"
|
||||||
|
#include "lwip/err.h"
|
||||||
|
#include "lwip/pbuf.h"
|
||||||
|
|
||||||
|
|
||||||
|
/** Set this to 1 to support CGI */
|
||||||
|
#ifndef LWIP_HTTPD_CGI
|
||||||
|
#define LWIP_HTTPD_CGI 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** Set this to 1 to support SSI (Server-Side-Includes) */
|
||||||
|
#ifndef LWIP_HTTPD_SSI
|
||||||
|
#define LWIP_HTTPD_SSI 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** Set this to 1 to support HTTP POST */
|
||||||
|
#ifndef LWIP_HTTPD_SUPPORT_POST
|
||||||
|
#define LWIP_HTTPD_SUPPORT_POST 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if LWIP_HTTPD_CGI
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function pointer for a CGI script handler.
|
||||||
|
*
|
||||||
|
* This function is called each time the HTTPD server is asked for a file
|
||||||
|
* whose name was previously registered as a CGI function using a call to
|
||||||
|
* http_set_cgi_handler. The iIndex parameter provides the index of the
|
||||||
|
* CGI within the ppcURLs array passed to http_set_cgi_handler. Parameters
|
||||||
|
* pcParam and pcValue provide access to the parameters provided along with
|
||||||
|
* the URI. iNumParams provides a count of the entries in the pcParam and
|
||||||
|
* pcValue arrays. Each entry in the pcParam array contains the name of a
|
||||||
|
* parameter with the corresponding entry in the pcValue array containing the
|
||||||
|
* value for that parameter. Note that pcParam may contain multiple elements
|
||||||
|
* with the same name if, for example, a multi-selection list control is used
|
||||||
|
* in the form generating the data.
|
||||||
|
*
|
||||||
|
* The function should return a pointer to a character string which is the
|
||||||
|
* path and filename of the response that is to be sent to the connected
|
||||||
|
* browser, for example "/thanks.htm" or "/response/error.ssi".
|
||||||
|
*
|
||||||
|
* The maximum number of parameters that will be passed to this function via
|
||||||
|
* iNumParams is defined by LWIP_HTTPD_MAX_CGI_PARAMETERS. Any parameters in the incoming
|
||||||
|
* HTTP request above this number will be discarded.
|
||||||
|
*
|
||||||
|
* Requests intended for use by this CGI mechanism must be sent using the GET
|
||||||
|
* method (which encodes all parameters within the URI rather than in a block
|
||||||
|
* later in the request). Attempts to use the POST method will result in the
|
||||||
|
* request being ignored.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
typedef const char *(*tCGIHandler)(int iIndex, int iNumParams, char *pcParam[],
|
||||||
|
char *pcValue[]);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Structure defining the base filename (URL) of a CGI and the associated
|
||||||
|
* function which is to be called when that URL is requested.
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
const char *pcCGIName;
|
||||||
|
tCGIHandler pfnCGIHandler;
|
||||||
|
} tCGI;
|
||||||
|
|
||||||
|
void http_set_cgi_handlers(const tCGI *pCGIs, int iNumHandlers);
|
||||||
|
|
||||||
|
|
||||||
|
/* The maximum number of parameters that the CGI handler can be sent. */
|
||||||
|
#ifndef LWIP_HTTPD_MAX_CGI_PARAMETERS
|
||||||
|
#define LWIP_HTTPD_MAX_CGI_PARAMETERS 16
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LWIP_HTTPD_CGI */
|
||||||
|
|
||||||
|
#if LWIP_HTTPD_SSI
|
||||||
|
|
||||||
|
/** LWIP_HTTPD_SSI_MULTIPART==1: SSI handler function is called with 2 more
|
||||||
|
* arguments indicating a counter for insert string that are too long to be
|
||||||
|
* inserted at once: the SSI handler function must then set 'next_tag_part'
|
||||||
|
* which will be passed back to it in the next call. */
|
||||||
|
#ifndef LWIP_HTTPD_SSI_MULTIPART
|
||||||
|
#define LWIP_HTTPD_SSI_MULTIPART 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function pointer for the SSI tag handler callback.
|
||||||
|
*
|
||||||
|
* This function will be called each time the HTTPD server detects a tag of the
|
||||||
|
* form <!--#name--> in a .shtml, .ssi or .shtm file where "name" appears as
|
||||||
|
* one of the tags supplied to http_set_ssi_handler in the ppcTags array. The
|
||||||
|
* returned insert string, which will be appended after the the string
|
||||||
|
* "<!--#name-->" in file sent back to the client,should be written to pointer
|
||||||
|
* pcInsert. iInsertLen contains the size of the buffer pointed to by
|
||||||
|
* pcInsert. The iIndex parameter provides the zero-based index of the tag as
|
||||||
|
* found in the ppcTags array and identifies the tag that is to be processed.
|
||||||
|
*
|
||||||
|
* The handler returns the number of characters written to pcInsert excluding
|
||||||
|
* any terminating NULL or a negative number to indicate a failure (tag not
|
||||||
|
* recognized, for example).
|
||||||
|
*
|
||||||
|
* Note that the behavior of this SSI mechanism is somewhat different from the
|
||||||
|
* "normal" SSI processing as found in, for example, the Apache web server. In
|
||||||
|
* this case, the inserted text is appended following the SSI tag rather than
|
||||||
|
* replacing the tag entirely. This allows for an implementation that does not
|
||||||
|
* require significant additional buffering of output data yet which will still
|
||||||
|
* offer usable SSI functionality. One downside to this approach is when
|
||||||
|
* attempting to use SSI within JavaScript. The SSI tag is structured to
|
||||||
|
* resemble an HTML comment but this syntax does not constitute a comment
|
||||||
|
* within JavaScript and, hence, leaving the tag in place will result in
|
||||||
|
* problems in these cases. To work around this, any SSI tag which needs to
|
||||||
|
* output JavaScript code must do so in an encapsulated way, sending the whole
|
||||||
|
* HTML <script>...</script> section as a single include.
|
||||||
|
*/
|
||||||
|
typedef u16_t (*tSSIHandler)(int iIndex, char *pcInsert, int iInsertLen
|
||||||
|
#if LWIP_HTTPD_SSI_MULTIPART
|
||||||
|
, u16_t current_tag_part, u16_t *next_tag_part
|
||||||
|
#endif /* LWIP_HTTPD_SSI_MULTIPART */
|
||||||
|
#if LWIP_HTTPD_FILE_STATE
|
||||||
|
, void *connection_state
|
||||||
|
#endif /* LWIP_HTTPD_FILE_STATE */
|
||||||
|
);
|
||||||
|
|
||||||
|
void http_set_ssi_handler(tSSIHandler pfnSSIHandler,
|
||||||
|
const char **ppcTags, int iNumTags);
|
||||||
|
|
||||||
|
/* The maximum length of the string comprising the tag name */
|
||||||
|
#ifndef LWIP_HTTPD_MAX_TAG_NAME_LEN
|
||||||
|
#define LWIP_HTTPD_MAX_TAG_NAME_LEN 8
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* The maximum length of string that can be returned to replace any given tag */
|
||||||
|
#ifndef LWIP_HTTPD_MAX_TAG_INSERT_LEN
|
||||||
|
#define LWIP_HTTPD_MAX_TAG_INSERT_LEN 192
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LWIP_HTTPD_SSI */
|
||||||
|
|
||||||
|
#if LWIP_HTTPD_SUPPORT_POST
|
||||||
|
|
||||||
|
/* These functions must be implemented by the application */
|
||||||
|
|
||||||
|
/** Called when a POST request has been received. The application can decide
|
||||||
|
* whether to accept it or not.
|
||||||
|
*
|
||||||
|
* @param connection Unique connection identifier, valid until httpd_post_end
|
||||||
|
* is called.
|
||||||
|
* @param uri The HTTP header URI receiving the POST request.
|
||||||
|
* @param http_request The raw HTTP request (the first packet, normally).
|
||||||
|
* @param http_request_len Size of 'http_request'.
|
||||||
|
* @param content_len Content-Length from HTTP header.
|
||||||
|
* @param response_uri Filename of response file, to be filled when denying the
|
||||||
|
* request
|
||||||
|
* @param response_uri_len Size of the 'response_uri' buffer.
|
||||||
|
* @param post_auto_wnd Set this to 0 to let the callback code handle window
|
||||||
|
* updates by calling 'httpd_post_data_recved' (to throttle rx speed)
|
||||||
|
* default is 1 (httpd handles window updates automatically)
|
||||||
|
* @return ERR_OK: Accept the POST request, data may be passed in
|
||||||
|
* another err_t: Deny the POST request, send back 'bad request'.
|
||||||
|
*/
|
||||||
|
err_t httpd_post_begin(void *connection, const char *uri, const char *http_request,
|
||||||
|
u16_t http_request_len, int content_len, char *response_uri,
|
||||||
|
u16_t response_uri_len, u8_t *post_auto_wnd);
|
||||||
|
|
||||||
|
/** Called for each pbuf of data that has been received for a POST.
|
||||||
|
* ATTENTION: The application is responsible for freeing the pbufs passed in!
|
||||||
|
*
|
||||||
|
* @param connection Unique connection identifier.
|
||||||
|
* @param p Received data.
|
||||||
|
* @return ERR_OK: Data accepted.
|
||||||
|
* another err_t: Data denied, http_post_get_response_uri will be called.
|
||||||
|
*/
|
||||||
|
err_t httpd_post_receive_data(void *connection, struct pbuf *p);
|
||||||
|
|
||||||
|
/** Called when all data is received or when the connection is closed.
|
||||||
|
* The application must return the filename/URI of a file to send in response
|
||||||
|
* to this POST request. If the response_uri buffer is untouched, a 404
|
||||||
|
* response is returned.
|
||||||
|
*
|
||||||
|
* @param connection Unique connection identifier.
|
||||||
|
* @param response_uri Filename of response file, to be filled when denying the request
|
||||||
|
* @param response_uri_len Size of the 'response_uri' buffer.
|
||||||
|
*/
|
||||||
|
void httpd_post_finished(void *connection, char *response_uri, u16_t response_uri_len);
|
||||||
|
|
||||||
|
#ifndef LWIP_HTTPD_POST_MANUAL_WND
|
||||||
|
#define LWIP_HTTPD_POST_MANUAL_WND 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LWIP_HTTPD_POST_MANUAL_WND
|
||||||
|
void httpd_post_data_recved(void *connection, u16_t recved_len);
|
||||||
|
#endif /* LWIP_HTTPD_POST_MANUAL_WND */
|
||||||
|
|
||||||
|
#endif /* LWIP_HTTPD_SUPPORT_POST */
|
||||||
|
|
||||||
|
void httpd_init(void);
|
||||||
|
|
||||||
|
#endif /* __HTTPD_H__ */
|
@ -0,0 +1,115 @@
|
|||||||
|
#ifndef __HTTPD_STRUCTS_H__
|
||||||
|
#define __HTTPD_STRUCTS_H__
|
||||||
|
|
||||||
|
#include "httpd.h"
|
||||||
|
|
||||||
|
/** This string is passed in the HTTP header as "Server: " */
|
||||||
|
#ifndef HTTPD_SERVER_AGENT
|
||||||
|
#define HTTPD_SERVER_AGENT "lwIP/1.3.1 (http://savannah.nongnu.org/projects/lwip)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** Set this to 1 if you want to include code that creates HTTP headers
|
||||||
|
* at runtime. Default is off: HTTP headers are then created statically
|
||||||
|
* by the makefsdata tool. Static headers mean smaller code size, but
|
||||||
|
* the (readonly) fsdata will grow a bit as every file includes the HTTP
|
||||||
|
* header. */
|
||||||
|
#ifndef LWIP_HTTPD_DYNAMIC_HEADERS
|
||||||
|
#define LWIP_HTTPD_DYNAMIC_HEADERS 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if LWIP_HTTPD_DYNAMIC_HEADERS
|
||||||
|
/** This struct is used for a list of HTTP header strings for various
|
||||||
|
* filename extensions. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
const char *extension;
|
||||||
|
int headerIndex;
|
||||||
|
} tHTTPHeader;
|
||||||
|
|
||||||
|
/** A list of strings used in HTTP headers */
|
||||||
|
static const char * const g_psHTTPHeaderStrings[] =
|
||||||
|
{
|
||||||
|
"Content-type: text/html\r\n\r\n",
|
||||||
|
"Content-type: text/html\r\nExpires: Fri, 10 Apr 2008 14:00:00 GMT\r\nPragma: no-cache\r\n\r\n",
|
||||||
|
"Content-type: image/gif\r\n\r\n",
|
||||||
|
"Content-type: image/png\r\n\r\n",
|
||||||
|
"Content-type: image/jpeg\r\n\r\n",
|
||||||
|
"Content-type: image/bmp\r\n\r\n",
|
||||||
|
"Content-type: image/x-icon\r\n\r\n",
|
||||||
|
"Content-type: application/octet-stream\r\n\r\n",
|
||||||
|
"Content-type: application/x-javascript\r\n\r\n",
|
||||||
|
"Content-type: application/x-javascript\r\n\r\n",
|
||||||
|
"Content-type: text/css\r\n\r\n",
|
||||||
|
"Content-type: application/x-shockwave-flash\r\n\r\n",
|
||||||
|
"Content-type: text/xml\r\n\r\n",
|
||||||
|
"Content-type: text/plain\r\n\r\n",
|
||||||
|
"HTTP/1.0 200 OK\r\n",
|
||||||
|
"HTTP/1.0 404 File not found\r\n",
|
||||||
|
"HTTP/1.0 400 Bad Request\r\n",
|
||||||
|
"HTTP/1.0 501 Not Implemented\r\n",
|
||||||
|
"HTTP/1.1 200 OK\r\n",
|
||||||
|
"HTTP/1.1 404 File not found\r\n",
|
||||||
|
"HTTP/1.1 400 Bad Request\r\n",
|
||||||
|
"HTTP/1.1 501 Not Implemented\r\n",
|
||||||
|
"Content-Length: ",
|
||||||
|
"Connection: Close\r\n",
|
||||||
|
"Server: "HTTPD_SERVER_AGENT"\r\n",
|
||||||
|
"\r\n<html><body><h2>404: The requested file cannot be found.</h2></body></html>\r\n"
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Indexes into the g_psHTTPHeaderStrings array */
|
||||||
|
#define HTTP_HDR_HTML 0 /* text/html */
|
||||||
|
#define HTTP_HDR_SSI 1 /* text/html Expires... */
|
||||||
|
#define HTTP_HDR_GIF 2 /* image/gif */
|
||||||
|
#define HTTP_HDR_PNG 3 /* image/png */
|
||||||
|
#define HTTP_HDR_JPG 4 /* image/jpeg */
|
||||||
|
#define HTTP_HDR_BMP 5 /* image/bmp */
|
||||||
|
#define HTTP_HDR_ICO 6 /* image/x-icon */
|
||||||
|
#define HTTP_HDR_APP 7 /* application/octet-stream */
|
||||||
|
#define HTTP_HDR_JS 8 /* application/x-javascript */
|
||||||
|
#define HTTP_HDR_RA 9 /* application/x-javascript */
|
||||||
|
#define HTTP_HDR_CSS 10 /* text/css */
|
||||||
|
#define HTTP_HDR_SWF 11 /* application/x-shockwave-flash */
|
||||||
|
#define HTTP_HDR_XML 12 /* text/xml */
|
||||||
|
#define HTTP_HDR_DEFAULT_TYPE 13 /* text/plain */
|
||||||
|
#define HTTP_HDR_OK 14 /* 200 OK */
|
||||||
|
#define HTTP_HDR_NOT_FOUND 15 /* 404 File not found */
|
||||||
|
#define HTTP_HDR_BAD_REQUEST 16 /* 400 Bad request */
|
||||||
|
#define HTTP_HDR_NOT_IMPL 17 /* 501 Not Implemented */
|
||||||
|
#define HTTP_HDR_OK_11 18 /* 200 OK */
|
||||||
|
#define HTTP_HDR_NOT_FOUND_11 19 /* 404 File not found */
|
||||||
|
#define HTTP_HDR_BAD_REQUEST_11 20 /* 400 Bad request */
|
||||||
|
#define HTTP_HDR_NOT_IMPL_11 21 /* 501 Not Implemented */
|
||||||
|
#define HTTP_HDR_CONTENT_LENGTH 22 /* Content-Length: (HTTP 1.1)*/
|
||||||
|
#define HTTP_HDR_CONN_CLOSE 23 /* Connection: Close (HTTP 1.1) */
|
||||||
|
#define HTTP_HDR_SERVER 24 /* Server: HTTPD_SERVER_AGENT */
|
||||||
|
#define DEFAULT_404_HTML 25 /* default 404 body */
|
||||||
|
|
||||||
|
/** A list of extension-to-HTTP header strings */
|
||||||
|
const static tHTTPHeader g_psHTTPHeaders[] =
|
||||||
|
{
|
||||||
|
{ "html", HTTP_HDR_HTML},
|
||||||
|
{ "htm", HTTP_HDR_HTML},
|
||||||
|
{ "shtml",HTTP_HDR_SSI},
|
||||||
|
{ "shtm", HTTP_HDR_SSI},
|
||||||
|
{ "ssi", HTTP_HDR_SSI},
|
||||||
|
{ "gif", HTTP_HDR_GIF},
|
||||||
|
{ "png", HTTP_HDR_PNG},
|
||||||
|
{ "jpg", HTTP_HDR_JPG},
|
||||||
|
{ "bmp", HTTP_HDR_BMP},
|
||||||
|
{ "ico", HTTP_HDR_ICO},
|
||||||
|
{ "class",HTTP_HDR_APP},
|
||||||
|
{ "cls", HTTP_HDR_APP},
|
||||||
|
{ "js", HTTP_HDR_JS},
|
||||||
|
{ "ram", HTTP_HDR_RA},
|
||||||
|
{ "css", HTTP_HDR_CSS},
|
||||||
|
{ "swf", HTTP_HDR_SWF},
|
||||||
|
{ "xml", HTTP_HDR_XML}
|
||||||
|
};
|
||||||
|
|
||||||
|
#define NUM_HTTP_HEADERS (sizeof(g_psHTTPHeaders) / sizeof(tHTTPHeader))
|
||||||
|
|
||||||
|
#endif /* LWIP_HTTPD_DYNAMIC_HEADERS */
|
||||||
|
|
||||||
|
#endif /* __HTTPD_STRUCTS_H__ */
|
Binary file not shown.
@ -0,0 +1,36 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="Source Files">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Resource Files">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="ReadMe.txt" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="stdafx.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="targetver.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="stdafx.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="makefsdata.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
@ -0,0 +1,3 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
</Project>
|
@ -0,0 +1,21 @@
|
|||||||
|
<html>
|
||||||
|
<head><title>lwIP - A Lightweight TCP/IP Stack</title></head>
|
||||||
|
<body bgcolor="white" text="black">
|
||||||
|
|
||||||
|
<table width="100%">
|
||||||
|
<tr valign="top"><td width="80">
|
||||||
|
<a href="http://www.sics.se/"><img src="/img/sics.gif"
|
||||||
|
border="0" alt="SICS logo" title="SICS logo"></a>
|
||||||
|
</td><td width="500">
|
||||||
|
<h1>lwIP - A Lightweight TCP/IP Stack</h1>
|
||||||
|
<h2>404 - Page not found</h2>
|
||||||
|
<p>
|
||||||
|
Sorry, the page you are requesting was not found on this
|
||||||
|
server.
|
||||||
|
</p>
|
||||||
|
</td><td>
|
||||||
|
|
||||||
|
</td></tr>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,20 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>FreeRTOS.org uIP WEB server demo</title>
|
||||||
|
</head>
|
||||||
|
<BODY onLoad="window.setTimeout("location.href='index.shtml'",2000)">
|
||||||
|
<font face="arial">
|
||||||
|
<a href="index.shtml">Task Stats</a> <b>|</b> <a href="runtime.shtml">Run Time Stats</a> <b>|</b> <a href="stats.shtml">TCP Stats</a> <b>|</b> <a href="tcp.shtml">Connections</a> <b>|</b> <a href="http://www.freertos.org/">FreeRTOS Homepage</a> <b>|</b> <a href="io.shtml">IO</a> <b>|</b> <a href="logo.jpg">37K jpg</a>
|
||||||
|
<br><p>
|
||||||
|
<hr>
|
||||||
|
<br><p>
|
||||||
|
<h2>Task statistics</h2>
|
||||||
|
Page will refresh every 2 seconds.<p>
|
||||||
|
<font face="courier"><pre>Task State Priority Stack #<br>************************************************<br>
|
||||||
|
<!--#rtos_stats-->
|
||||||
|
</pre></font>
|
||||||
|
</font>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 28 KiB |
@ -0,0 +1,20 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>FreeRTOS.org uIP WEB server demo</title>
|
||||||
|
</head>
|
||||||
|
<BODY onLoad="window.setTimeout("location.href='runtime.shtml'",2000)">
|
||||||
|
<font face="arial">
|
||||||
|
<a href="index.shtml">Task Stats</a> <b>|</b> <a href="runtime.shtml">Run Time Stats</a> <b>|</b> <a href="stats.shtml">TCP Stats</a> <b>|</b> <a href="tcp.shtml">Connections</a> <b>|</b> <a href="http://www.freertos.org/">FreeRTOS Homepage</a> <b>|</b> <a href="io.shtml">IO</a> <b>|</b> <a href="logo.jpg">37K jpg</a>
|
||||||
|
<br><p>
|
||||||
|
<hr>
|
||||||
|
<br><p>
|
||||||
|
<h2>Run-time statistics</h2>
|
||||||
|
Page will refresh every 2 seconds.<p>
|
||||||
|
<font face="courier"><pre>Task Abs Time % Time<br>****************************************<br>
|
||||||
|
<!--#run_stats-->
|
||||||
|
</pre></font>
|
||||||
|
</font>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,97 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
open(OUTPUT, "> fsdata.c");
|
||||||
|
|
||||||
|
chdir("fs");
|
||||||
|
open(FILES, "find . -type f |");
|
||||||
|
|
||||||
|
while($file = <FILES>) {
|
||||||
|
|
||||||
|
# Do not include files in CVS directories nor backup files.
|
||||||
|
if($file =~ /(CVS|~)/) {
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
chop($file);
|
||||||
|
|
||||||
|
open(HEADER, "> /tmp/header") || die $!;
|
||||||
|
if($file =~ /404/) {
|
||||||
|
print(HEADER "HTTP/1.0 404 File not found\r\n");
|
||||||
|
} else {
|
||||||
|
print(HEADER "HTTP/1.0 200 OK\r\n");
|
||||||
|
}
|
||||||
|
print(HEADER "Server: lwIP/pre-0.6 (http://www.sics.se/~adam/lwip/)\r\n");
|
||||||
|
if($file =~ /\.html$/) {
|
||||||
|
print(HEADER "Content-type: text/html\r\n");
|
||||||
|
} elsif($file =~ /\.gif$/) {
|
||||||
|
print(HEADER "Content-type: image/gif\r\n");
|
||||||
|
} elsif($file =~ /\.png$/) {
|
||||||
|
print(HEADER "Content-type: image/png\r\n");
|
||||||
|
} elsif($file =~ /\.jpg$/) {
|
||||||
|
print(HEADER "Content-type: image/jpeg\r\n");
|
||||||
|
} elsif($file =~ /\.class$/) {
|
||||||
|
print(HEADER "Content-type: application/octet-stream\r\n");
|
||||||
|
} elsif($file =~ /\.ram$/) {
|
||||||
|
print(HEADER "Content-type: audio/x-pn-realaudio\r\n");
|
||||||
|
} else {
|
||||||
|
print(HEADER "Content-type: text/plain\r\n");
|
||||||
|
}
|
||||||
|
print(HEADER "\r\n");
|
||||||
|
close(HEADER);
|
||||||
|
|
||||||
|
unless($file =~ /\.plain$/ || $file =~ /cgi/) {
|
||||||
|
system("cat /tmp/header $file > /tmp/file");
|
||||||
|
} else {
|
||||||
|
system("cp $file /tmp/file");
|
||||||
|
}
|
||||||
|
|
||||||
|
open(FILE, "/tmp/file");
|
||||||
|
unlink("/tmp/file");
|
||||||
|
unlink("/tmp/header");
|
||||||
|
|
||||||
|
$file =~ s/\.//;
|
||||||
|
$fvar = $file;
|
||||||
|
$fvar =~ s-/-_-g;
|
||||||
|
$fvar =~ s-\.-_-g;
|
||||||
|
print(OUTPUT "static const unsigned char data".$fvar."[] = {\n");
|
||||||
|
print(OUTPUT "\t/* $file */\n\t");
|
||||||
|
for($j = 0; $j < length($file); $j++) {
|
||||||
|
printf(OUTPUT "%#02x, ", unpack("C", substr($file, $j, 1)));
|
||||||
|
}
|
||||||
|
printf(OUTPUT "0,\n");
|
||||||
|
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
while(read(FILE, $data, 1)) {
|
||||||
|
if($i == 0) {
|
||||||
|
print(OUTPUT "\t");
|
||||||
|
}
|
||||||
|
printf(OUTPUT "%#02x, ", unpack("C", $data));
|
||||||
|
$i++;
|
||||||
|
if($i == 10) {
|
||||||
|
print(OUTPUT "\n");
|
||||||
|
$i = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print(OUTPUT "};\n\n");
|
||||||
|
close(FILE);
|
||||||
|
push(@fvars, $fvar);
|
||||||
|
push(@files, $file);
|
||||||
|
}
|
||||||
|
|
||||||
|
for($i = 0; $i < @fvars; $i++) {
|
||||||
|
$file = $files[$i];
|
||||||
|
$fvar = $fvars[$i];
|
||||||
|
|
||||||
|
if($i == 0) {
|
||||||
|
$prevfile = "NULL";
|
||||||
|
} else {
|
||||||
|
$prevfile = "file" . $fvars[$i - 1];
|
||||||
|
}
|
||||||
|
print(OUTPUT "const struct fsdata_file file".$fvar."[] = {{$prevfile, data$fvar, ");
|
||||||
|
print(OUTPUT "data$fvar + ". (length($file) + 1) .", ");
|
||||||
|
print(OUTPUT "sizeof(data$fvar) - ". (length($file) + 1) ."}};\n\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
print(OUTPUT "#define FS_ROOT file$fvars[$i - 1]\n\n");
|
||||||
|
print(OUTPUT "#define FS_NUMFILES $i\n");
|
@ -0,0 +1,610 @@
|
|||||||
|
/**
|
||||||
|
* makefsdata: Converts a directory structure for use with the lwIP httpd.
|
||||||
|
*
|
||||||
|
* This file is part of the lwIP TCP/IP stack.
|
||||||
|
*
|
||||||
|
* Author: Jim Pettinato
|
||||||
|
* Simon Goldschmidt
|
||||||
|
*
|
||||||
|
* @todo:
|
||||||
|
* - take TCP_MSS, LWIP_TCP_TIMESTAMPS and
|
||||||
|
* PAYLOAD_ALIGN_TYPE/PAYLOAD_ALIGNMENT as arguments
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#ifdef WIN32
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#include "windows.h"
|
||||||
|
#else
|
||||||
|
#include <dir.h>
|
||||||
|
#endif
|
||||||
|
#include <dos.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/* Compatibility defines Win32 vs. DOS */
|
||||||
|
#ifdef WIN32
|
||||||
|
|
||||||
|
#define FIND_T WIN32_FIND_DATAA
|
||||||
|
#define FIND_T_FILENAME(fInfo) (fInfo.cFileName)
|
||||||
|
#define FIND_T_IS_DIR(fInfo) ((fInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
|
||||||
|
#define FIND_T_IS_FILE(fInfo) ((fInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
|
||||||
|
#define FIND_RET_T HANDLE
|
||||||
|
#define FINDFIRST_FILE(path, result) FindFirstFileA(path, result)
|
||||||
|
#define FINDFIRST_DIR(path, result) FindFirstFileA(path, result)
|
||||||
|
#define FINDNEXT(ff_res, result) FindNextFileA(ff_res, result)
|
||||||
|
#define FINDFIRST_SUCCEEDED(ret) (ret != INVALID_HANDLE_VALUE)
|
||||||
|
#define FINDNEXT_SUCCEEDED(ret) (ret == TRUE)
|
||||||
|
|
||||||
|
#define GETCWD(path, len) GetCurrentDirectoryA(len, path)
|
||||||
|
#define CHDIR(path) SetCurrentDirectoryA(path)
|
||||||
|
|
||||||
|
#define NEWLINE "\r\n"
|
||||||
|
#define NEWLINE_LEN 2
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define FIND_T struct fflbk
|
||||||
|
#define FIND_T_FILENAME(fInfo) (fInfo.ff_name)
|
||||||
|
#define FIND_T_IS_DIR(fInfo) ((fInfo.ff_attrib & FA_DIREC) == FA_DIREC)
|
||||||
|
#define FIND_T_IS_FILE(fInfo) (1)
|
||||||
|
#define FIND_RET_T int
|
||||||
|
#define FINDFIRST_FILE(path, result) findfirst(path, result, FA_ARCH)
|
||||||
|
#define FINDFIRST_DIR(path, result) findfirst(path, result, FA_DIREC)
|
||||||
|
#define FINDNEXT(ff_res, result) FindNextFileA(ff_res, result)
|
||||||
|
#define FINDFIRST_SUCCEEDED(ret) (ret == 0)
|
||||||
|
#define FINDNEXT_SUCCEEDED(ret) (ret == 0)
|
||||||
|
|
||||||
|
#define GETCWD(path, len) getcwd(path, len)
|
||||||
|
#define CHDIR(path) chdir(path)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* define this to get the header variables we use to build HTTP headers */
|
||||||
|
#define LWIP_HTTPD_DYNAMIC_HEADERS 1
|
||||||
|
#include "../httpd_structs.h"
|
||||||
|
|
||||||
|
#include "../../../lwip-1.4.0/src/core/ipv4/inet_chksum.c"
|
||||||
|
#include "../../../lwip-1.4.0/src/core/def.c"
|
||||||
|
|
||||||
|
/** (Your server name here) */
|
||||||
|
const char *serverID = "Server: "HTTPD_SERVER_AGENT"\r\n";
|
||||||
|
|
||||||
|
/* change this to suit your MEM_ALIGNMENT */
|
||||||
|
#define PAYLOAD_ALIGNMENT 4
|
||||||
|
/* set this to 0 to prevent aligning payload */
|
||||||
|
#define ALIGN_PAYLOAD 1
|
||||||
|
/* define this to a type that has the required alignment */
|
||||||
|
#define PAYLOAD_ALIGN_TYPE "unsigned int"
|
||||||
|
static int payload_alingment_dummy_counter = 0;
|
||||||
|
|
||||||
|
#define HEX_BYTES_PER_LINE 16
|
||||||
|
|
||||||
|
#define MAX_PATH_LEN 256
|
||||||
|
|
||||||
|
#define COPY_BUFSIZE 10240
|
||||||
|
|
||||||
|
int process_sub(FILE *data_file, FILE *struct_file);
|
||||||
|
int process_file(FILE *data_file, FILE *struct_file, const char *filename);
|
||||||
|
int file_write_http_header(FILE *data_file, const char *filename, int file_size,
|
||||||
|
u16_t *http_hdr_len, u16_t *http_hdr_chksum);
|
||||||
|
int file_put_ascii(FILE *file, const char *ascii_string, int len, int *i);
|
||||||
|
int s_put_ascii(char *buf, const char *ascii_string, int len, int *i);
|
||||||
|
void concat_files(const char *file1, const char *file2, const char *targetfile);
|
||||||
|
|
||||||
|
static unsigned char file_buffer_raw[COPY_BUFSIZE];
|
||||||
|
/* 5 bytes per char + 3 bytes per line */
|
||||||
|
static char file_buffer_c[COPY_BUFSIZE * 5 + ((COPY_BUFSIZE / HEX_BYTES_PER_LINE) * 3)];
|
||||||
|
|
||||||
|
char curSubdir[MAX_PATH_LEN];
|
||||||
|
char lastFileVar[MAX_PATH_LEN];
|
||||||
|
char hdr_buf[4096];
|
||||||
|
|
||||||
|
unsigned char processSubs = 1;
|
||||||
|
unsigned char includeHttpHeader = 1;
|
||||||
|
unsigned char useHttp11 = 0;
|
||||||
|
unsigned char precalcChksum = 0;
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
FIND_T fInfo;
|
||||||
|
FIND_RET_T fret;
|
||||||
|
char path[MAX_PATH_LEN];
|
||||||
|
char appPath[MAX_PATH_LEN];
|
||||||
|
FILE *data_file;
|
||||||
|
FILE *struct_file;
|
||||||
|
int filesProcessed;
|
||||||
|
int i;
|
||||||
|
char targetfile[MAX_PATH_LEN];
|
||||||
|
strcpy(targetfile, "fsdata.c");
|
||||||
|
|
||||||
|
memset(path, 0, sizeof(path));
|
||||||
|
memset(appPath, 0, sizeof(appPath));
|
||||||
|
|
||||||
|
printf(NEWLINE " makefsdata - HTML to C source converter" NEWLINE);
|
||||||
|
printf(" by Jim Pettinato - circa 2003 " NEWLINE);
|
||||||
|
printf(" extended by Simon Goldschmidt - 2009 " NEWLINE NEWLINE);
|
||||||
|
|
||||||
|
strcpy(path, "fs");
|
||||||
|
for(i = 1; i < argc; i++) {
|
||||||
|
if (argv[i][0] == '-') {
|
||||||
|
if (strstr(argv[i], "-s")) {
|
||||||
|
processSubs = 0;
|
||||||
|
} else if (strstr(argv[i], "-e")) {
|
||||||
|
includeHttpHeader = 0;
|
||||||
|
} else if (strstr(argv[i], "-11")) {
|
||||||
|
useHttp11 = 1;
|
||||||
|
} else if (strstr(argv[i], "-c")) {
|
||||||
|
precalcChksum = 1;
|
||||||
|
} else if((argv[i][1] == 'f') && (argv[i][2] == ':')) {
|
||||||
|
strcpy(targetfile, &argv[i][3]);
|
||||||
|
printf("Writing to file \"%s\"\n", targetfile);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
strcpy(path, argv[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* if command line param or subdir named 'fs' not found spout usage verbiage */
|
||||||
|
fret = FINDFIRST_DIR(path, &fInfo);
|
||||||
|
if (!FINDFIRST_SUCCEEDED(fret)) {
|
||||||
|
/* if no subdir named 'fs' (or the one which was given) exists, spout usage verbiage */
|
||||||
|
printf(" Failed to open directory \"%s\"." NEWLINE NEWLINE, path);
|
||||||
|
printf(" Usage: htmlgen [targetdir] [-s] [-i] [-f:<filename>]" NEWLINE NEWLINE);
|
||||||
|
printf(" targetdir: relative or absolute path to files to convert" NEWLINE);
|
||||||
|
printf(" switch -s: toggle processing of subdirectories (default is on)" NEWLINE);
|
||||||
|
printf(" switch -e: exclude HTTP header from file (header is created at runtime, default is off)" NEWLINE);
|
||||||
|
printf(" switch -11: include HTTP 1.1 header (1.0 is default)" NEWLINE);
|
||||||
|
printf(" switch -c: precalculate checksums for all pages (default is off)" NEWLINE);
|
||||||
|
printf(" switch -f: target filename (default is \"fsdata.c\")" NEWLINE);
|
||||||
|
printf(" if targetdir not specified, htmlgen will attempt to" NEWLINE);
|
||||||
|
printf(" process files in subdirectory 'fs'" NEWLINE);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("HTTP %sheader will %s statically included." NEWLINE,
|
||||||
|
(includeHttpHeader ? (useHttp11 ? "1.1 " : "1.0 ") : ""),
|
||||||
|
(includeHttpHeader ? "be" : "not be"));
|
||||||
|
|
||||||
|
sprintf(curSubdir, ""); /* start off in web page's root directory - relative paths */
|
||||||
|
printf(" Processing all files in directory %s", path);
|
||||||
|
if (processSubs) {
|
||||||
|
printf(" and subdirectories..." NEWLINE NEWLINE);
|
||||||
|
} else {
|
||||||
|
printf("..." NEWLINE NEWLINE);
|
||||||
|
}
|
||||||
|
|
||||||
|
GETCWD(appPath, MAX_PATH_LEN);
|
||||||
|
data_file = fopen("fsdata.tmp", "wb");
|
||||||
|
if (data_file == NULL) {
|
||||||
|
printf("Failed to create file \"fsdata.tmp\"\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
struct_file = fopen("fshdr.tmp", "wb");
|
||||||
|
if (struct_file == NULL) {
|
||||||
|
printf("Failed to create file \"fshdr.tmp\"\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
CHDIR(path);
|
||||||
|
|
||||||
|
fprintf(data_file, "#include \"fs.h\"" NEWLINE);
|
||||||
|
fprintf(data_file, "#include \"lwip/def.h\"" NEWLINE);
|
||||||
|
fprintf(data_file, "#include \"fsdata.h\"" NEWLINE NEWLINE NEWLINE);
|
||||||
|
|
||||||
|
fprintf(data_file, "#define file_NULL (struct fsdata_file *) NULL" NEWLINE NEWLINE NEWLINE);
|
||||||
|
|
||||||
|
sprintf(lastFileVar, "NULL");
|
||||||
|
|
||||||
|
filesProcessed = process_sub(data_file, struct_file);
|
||||||
|
|
||||||
|
/* data_file now contains all of the raw data.. now append linked list of
|
||||||
|
* file header structs to allow embedded app to search for a file name */
|
||||||
|
fprintf(data_file, NEWLINE NEWLINE);
|
||||||
|
fprintf(struct_file, "#define FS_ROOT file_%s" NEWLINE, lastFileVar);
|
||||||
|
fprintf(struct_file, "#define FS_NUMFILES %d" NEWLINE NEWLINE, filesProcessed);
|
||||||
|
|
||||||
|
fclose(data_file);
|
||||||
|
fclose(struct_file);
|
||||||
|
|
||||||
|
CHDIR(appPath);
|
||||||
|
/* append struct_file to data_file */
|
||||||
|
printf(NEWLINE "Creating target file..." NEWLINE NEWLINE);
|
||||||
|
concat_files("fsdata.tmp", "fshdr.tmp", targetfile);
|
||||||
|
|
||||||
|
/* if succeeded, delete the temporary files */
|
||||||
|
remove("fsdata.tmp");
|
||||||
|
remove("fshdr.tmp");
|
||||||
|
|
||||||
|
printf(NEWLINE "Processed %d files - done." NEWLINE NEWLINE, filesProcessed);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void copy_file(const char *filename_in, FILE *fout)
|
||||||
|
{
|
||||||
|
FILE *fin;
|
||||||
|
size_t len;
|
||||||
|
fin = fopen(filename_in, "rb");
|
||||||
|
if (fin == NULL) {
|
||||||
|
printf("Failed to open file \"%s\"\n", filename_in);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
while((len = fread(file_buffer_raw, 1, COPY_BUFSIZE, fin)) > 0)
|
||||||
|
{
|
||||||
|
fwrite(file_buffer_raw, 1, len, fout);
|
||||||
|
}
|
||||||
|
fclose(fin);
|
||||||
|
}
|
||||||
|
|
||||||
|
void concat_files(const char *file1, const char *file2, const char *targetfile)
|
||||||
|
{
|
||||||
|
FILE *fout;
|
||||||
|
fout = fopen(targetfile, "wb");
|
||||||
|
if (fout == NULL) {
|
||||||
|
printf("Failed to open file \"%s\"\n", targetfile);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
copy_file(file1, fout);
|
||||||
|
copy_file(file2, fout);
|
||||||
|
fclose(fout);
|
||||||
|
}
|
||||||
|
|
||||||
|
int process_sub(FILE *data_file, FILE *struct_file)
|
||||||
|
{
|
||||||
|
FIND_T fInfo;
|
||||||
|
FIND_RET_T fret;
|
||||||
|
int filesProcessed = 0;
|
||||||
|
char oldSubdir[MAX_PATH_LEN];
|
||||||
|
|
||||||
|
if (processSubs) {
|
||||||
|
/* process subs recursively */
|
||||||
|
strcpy(oldSubdir, curSubdir);
|
||||||
|
fret = FINDFIRST_DIR("*", &fInfo);
|
||||||
|
if (FINDFIRST_SUCCEEDED(fret)) {
|
||||||
|
do {
|
||||||
|
const char *curName = FIND_T_FILENAME(fInfo);
|
||||||
|
if (curName == NULL) continue;
|
||||||
|
if (curName[0] == '.') continue;
|
||||||
|
if (strcmp(curName, "CVS") == 0) continue;
|
||||||
|
if (!FIND_T_IS_DIR(fInfo)) continue;
|
||||||
|
CHDIR(curName);
|
||||||
|
strcat(curSubdir, "/");
|
||||||
|
strcat(curSubdir, curName);
|
||||||
|
printf(NEWLINE "processing subdirectory %s/..." NEWLINE, curSubdir);
|
||||||
|
filesProcessed += process_sub(data_file, struct_file);
|
||||||
|
CHDIR("..");
|
||||||
|
strcpy(curSubdir, oldSubdir);
|
||||||
|
} while (FINDNEXT_SUCCEEDED(FINDNEXT(fret, &fInfo)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fret = FINDFIRST_FILE("*.*", &fInfo);
|
||||||
|
if (FINDFIRST_SUCCEEDED(fret)) {
|
||||||
|
/* at least one file in directory */
|
||||||
|
do {
|
||||||
|
if (FIND_T_IS_FILE(fInfo)) {
|
||||||
|
const char *curName = FIND_T_FILENAME(fInfo);
|
||||||
|
printf("processing %s/%s..." NEWLINE, curSubdir, curName);
|
||||||
|
if (process_file(data_file, struct_file, curName) < 0) {
|
||||||
|
printf(NEWLINE "Error... aborting" NEWLINE);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
filesProcessed++;
|
||||||
|
}
|
||||||
|
} while (FINDNEXT_SUCCEEDED(FINDNEXT(fret, &fInfo)));
|
||||||
|
}
|
||||||
|
return filesProcessed;
|
||||||
|
}
|
||||||
|
|
||||||
|
int get_file_size(const char* filename)
|
||||||
|
{
|
||||||
|
FILE *inFile;
|
||||||
|
int file_size = -1;
|
||||||
|
inFile = fopen(filename, "rb");
|
||||||
|
if (inFile == NULL) {
|
||||||
|
printf("Failed to open file \"%s\"\n", filename);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
fseek(inFile, 0, SEEK_END);
|
||||||
|
file_size = ftell(inFile);
|
||||||
|
fclose(inFile);
|
||||||
|
return file_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void process_file_data(const char *filename, FILE *data_file)
|
||||||
|
{
|
||||||
|
FILE *source_file;
|
||||||
|
size_t len, written, i, src_off=0;
|
||||||
|
|
||||||
|
source_file = fopen(filename, "rb");
|
||||||
|
|
||||||
|
do {
|
||||||
|
size_t off = 0;
|
||||||
|
len = fread(file_buffer_raw, 1, COPY_BUFSIZE, source_file);
|
||||||
|
if (len > 0) {
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
|
sprintf(&file_buffer_c[off], "0x%02.2x,", file_buffer_raw[i]);
|
||||||
|
off += 5;
|
||||||
|
if ((++src_off % HEX_BYTES_PER_LINE) == 0) {
|
||||||
|
memcpy(&file_buffer_c[off], NEWLINE, NEWLINE_LEN);
|
||||||
|
off += NEWLINE_LEN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
written = fwrite(file_buffer_c, 1, off, data_file);
|
||||||
|
}
|
||||||
|
} while(len > 0);
|
||||||
|
fclose(source_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
int write_checksums(FILE *struct_file, const char *filename, const char *varname,
|
||||||
|
u16_t hdr_len, u16_t hdr_chksum)
|
||||||
|
{
|
||||||
|
int chunk_size = TCP_MSS;
|
||||||
|
int offset;
|
||||||
|
size_t len;
|
||||||
|
int i = 0;
|
||||||
|
FILE *f;
|
||||||
|
#if LWIP_TCP_TIMESTAMPS
|
||||||
|
/* when timestamps are used, usable space is 12 bytes less per segment */
|
||||||
|
chunk_size -= 12;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
fprintf(struct_file, "#if HTTPD_PRECALCULATED_CHECKSUM" NEWLINE);
|
||||||
|
fprintf(struct_file, "const struct fsdata_chksum chksums_%s[] = {" NEWLINE, varname);
|
||||||
|
|
||||||
|
memset(file_buffer_raw, 0xab, sizeof(file_buffer_raw));
|
||||||
|
f = fopen(filename, "rb");
|
||||||
|
if (f == INVALID_HANDLE_VALUE) {
|
||||||
|
printf("Failed to open file \"%s\"\n", filename);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
if (hdr_len > 0) {
|
||||||
|
/* add checksum for HTTP header */
|
||||||
|
fprintf(struct_file, "{%d, 0x%04x, %d}," NEWLINE, 0, hdr_chksum, hdr_len);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
for (offset = hdr_len; ; offset += len) {
|
||||||
|
unsigned short chksum;
|
||||||
|
len = fread(file_buffer_raw, 1, chunk_size, f);
|
||||||
|
if (len == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
chksum = ~inet_chksum(file_buffer_raw, (u16_t)len);
|
||||||
|
/* add checksum for data */
|
||||||
|
fprintf(struct_file, "{%d, 0x%04x, %d}," NEWLINE, offset, chksum, len);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
fclose(f);
|
||||||
|
fprintf(struct_file, "};" NEWLINE);
|
||||||
|
fprintf(struct_file, "#endif /* HTTPD_PRECALCULATED_CHECKSUM */" NEWLINE);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
int process_file(FILE *data_file, FILE *struct_file, const char *filename)
|
||||||
|
{
|
||||||
|
char *pch;
|
||||||
|
char varname[MAX_PATH_LEN];
|
||||||
|
int i = 0;
|
||||||
|
char qualifiedName[MAX_PATH_LEN];
|
||||||
|
int file_size;
|
||||||
|
u16_t http_hdr_chksum = 0;
|
||||||
|
u16_t http_hdr_len = 0;
|
||||||
|
int chksum_count = 0;
|
||||||
|
|
||||||
|
/* create qualified name (TODO: prepend slash or not?) */
|
||||||
|
sprintf(qualifiedName,"%s/%s", curSubdir, filename);
|
||||||
|
/* create C variable name */
|
||||||
|
strcpy(varname, qualifiedName);
|
||||||
|
/* convert slashes & dots to underscores */
|
||||||
|
while ((pch = strpbrk(varname, "./\\")) != NULL) {
|
||||||
|
*pch = '_';
|
||||||
|
}
|
||||||
|
#if ALIGN_PAYLOAD
|
||||||
|
/* to force even alignment of array */
|
||||||
|
fprintf(data_file, "static const " PAYLOAD_ALIGN_TYPE " dummy_align_%s = %d;" NEWLINE, varname, payload_alingment_dummy_counter++);
|
||||||
|
#endif /* ALIGN_PAYLOAD */
|
||||||
|
fprintf(data_file, "static const unsigned char data_%s[] = {" NEWLINE, varname);
|
||||||
|
/* encode source file name (used by file system, not returned to browser) */
|
||||||
|
fprintf(data_file, "/* %s (%d chars) */" NEWLINE, qualifiedName, strlen(qualifiedName)+1);
|
||||||
|
file_put_ascii(data_file, qualifiedName, strlen(qualifiedName)+1, &i);
|
||||||
|
#if ALIGN_PAYLOAD
|
||||||
|
/* pad to even number of bytes to assure payload is on aligned boundary */
|
||||||
|
while(i % PAYLOAD_ALIGNMENT != 0) {
|
||||||
|
fprintf(data_file, "0x%02.2x,", 0);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
#endif /* ALIGN_PAYLOAD */
|
||||||
|
fprintf(data_file, NEWLINE);
|
||||||
|
|
||||||
|
file_size = get_file_size(filename);
|
||||||
|
if (includeHttpHeader) {
|
||||||
|
file_write_http_header(data_file, filename, file_size, &http_hdr_len, &http_hdr_chksum);
|
||||||
|
}
|
||||||
|
if (precalcChksum) {
|
||||||
|
chksum_count = write_checksums(struct_file, filename, varname, http_hdr_len, http_hdr_chksum);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* build declaration of struct fsdata_file in temp file */
|
||||||
|
fprintf(struct_file, "const struct fsdata_file file_%s[] = { {" NEWLINE, varname);
|
||||||
|
fprintf(struct_file, "file_%s," NEWLINE, lastFileVar);
|
||||||
|
fprintf(struct_file, "data_%s," NEWLINE, varname);
|
||||||
|
fprintf(struct_file, "data_%s + %d," NEWLINE, varname, i);
|
||||||
|
fprintf(struct_file, "sizeof(data_%s) - %d," NEWLINE, varname, i);
|
||||||
|
fprintf(struct_file, "%d," NEWLINE, includeHttpHeader);
|
||||||
|
if (precalcChksum) {
|
||||||
|
fprintf(struct_file, "#if HTTPD_PRECALCULATED_CHECKSUM" NEWLINE);
|
||||||
|
fprintf(struct_file, "%d, chksums_%s," NEWLINE, chksum_count, varname);
|
||||||
|
fprintf(struct_file, "#endif /* HTTPD_PRECALCULATED_CHECKSUM */" NEWLINE);
|
||||||
|
}
|
||||||
|
fprintf(struct_file, "}};" NEWLINE NEWLINE);
|
||||||
|
strcpy(lastFileVar, varname);
|
||||||
|
|
||||||
|
/* write actual file contents */
|
||||||
|
i = 0;
|
||||||
|
fprintf(data_file, NEWLINE "/* raw file data (%d bytes) */" NEWLINE, file_size);
|
||||||
|
process_file_data(filename, data_file);
|
||||||
|
fprintf(data_file, "};" NEWLINE NEWLINE);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int file_write_http_header(FILE *data_file, const char *filename, int file_size,
|
||||||
|
u16_t *http_hdr_len, u16_t *http_hdr_chksum)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
int response_type = HTTP_HDR_OK;
|
||||||
|
int file_type = HTTP_HDR_DEFAULT_TYPE;
|
||||||
|
const char *cur_string;
|
||||||
|
size_t cur_len;
|
||||||
|
int written = 0;
|
||||||
|
size_t hdr_len = 0;
|
||||||
|
u16_t acc;
|
||||||
|
const char *file_ext;
|
||||||
|
int j;
|
||||||
|
|
||||||
|
memset(hdr_buf, 0, sizeof(hdr_buf));
|
||||||
|
|
||||||
|
if (useHttp11) {
|
||||||
|
response_type = HTTP_HDR_OK_11;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(data_file, NEWLINE "/* HTTP header */");
|
||||||
|
if (strstr(filename, "404") == filename) {
|
||||||
|
response_type = HTTP_HDR_NOT_FOUND;
|
||||||
|
if (useHttp11) {
|
||||||
|
response_type = HTTP_HDR_NOT_FOUND_11;
|
||||||
|
}
|
||||||
|
} else if (strstr(filename, "400") == filename) {
|
||||||
|
response_type = HTTP_HDR_BAD_REQUEST;
|
||||||
|
if (useHttp11) {
|
||||||
|
response_type = HTTP_HDR_BAD_REQUEST_11;
|
||||||
|
}
|
||||||
|
} else if (strstr(filename, "501") == filename) {
|
||||||
|
response_type = HTTP_HDR_NOT_IMPL;
|
||||||
|
if (useHttp11) {
|
||||||
|
response_type = HTTP_HDR_NOT_IMPL_11;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cur_string = g_psHTTPHeaderStrings[response_type];
|
||||||
|
cur_len = strlen(cur_string);
|
||||||
|
fprintf(data_file, NEWLINE "/* \"%s\" (%d bytes) */" NEWLINE, cur_string, cur_len);
|
||||||
|
written += file_put_ascii(data_file, cur_string, cur_len, &i);
|
||||||
|
i = 0;
|
||||||
|
if (precalcChksum) {
|
||||||
|
memcpy(&hdr_buf[hdr_len], cur_string, cur_len);
|
||||||
|
hdr_len += cur_len;
|
||||||
|
}
|
||||||
|
|
||||||
|
cur_string = serverID;
|
||||||
|
cur_len = strlen(cur_string);
|
||||||
|
fprintf(data_file, NEWLINE "/* \"%s\" (%d bytes) */" NEWLINE, cur_string, cur_len);
|
||||||
|
written += file_put_ascii(data_file, cur_string, cur_len, &i);
|
||||||
|
i = 0;
|
||||||
|
if (precalcChksum) {
|
||||||
|
memcpy(&hdr_buf[hdr_len], cur_string, cur_len);
|
||||||
|
hdr_len += cur_len;
|
||||||
|
}
|
||||||
|
|
||||||
|
file_ext = filename;
|
||||||
|
while(strstr(file_ext, ".") != NULL) {
|
||||||
|
file_ext = strstr(file_ext, ".");
|
||||||
|
file_ext++;
|
||||||
|
}
|
||||||
|
if((file_ext == NULL) || (*file_ext == 0)) {
|
||||||
|
printf("failed to get extension for file \"%s\", using default.\n", filename);
|
||||||
|
} else {
|
||||||
|
for(j = 0; j < NUM_HTTP_HEADERS; j++) {
|
||||||
|
if(!strcmp(file_ext, g_psHTTPHeaders[j].extension)) {
|
||||||
|
file_type = g_psHTTPHeaders[j].headerIndex;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (j >= NUM_HTTP_HEADERS) {
|
||||||
|
printf("failed to get file type for extension \"%s\", using default.\n", file_ext);
|
||||||
|
file_type = HTTP_HDR_DEFAULT_TYPE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (useHttp11) {
|
||||||
|
char intbuf[MAX_PATH_LEN];
|
||||||
|
memset(intbuf, 0, sizeof(intbuf));
|
||||||
|
|
||||||
|
cur_string = g_psHTTPHeaderStrings[HTTP_HDR_CONTENT_LENGTH];
|
||||||
|
cur_len = strlen(cur_string);
|
||||||
|
fprintf(data_file, NEWLINE "/* \"%s%d\r\n\" (%d+ bytes) */" NEWLINE, cur_string, file_size, cur_len+2);
|
||||||
|
written += file_put_ascii(data_file, cur_string, cur_len, &i);
|
||||||
|
if (precalcChksum) {
|
||||||
|
memcpy(&hdr_buf[hdr_len], cur_string, cur_len);
|
||||||
|
hdr_len += cur_len;
|
||||||
|
}
|
||||||
|
|
||||||
|
_itoa(file_size, intbuf, 10);
|
||||||
|
strcat(intbuf, "\r\n");
|
||||||
|
cur_len = strlen(intbuf);
|
||||||
|
written += file_put_ascii(data_file, intbuf, cur_len, &i);
|
||||||
|
i = 0;
|
||||||
|
if (precalcChksum) {
|
||||||
|
memcpy(&hdr_buf[hdr_len], intbuf, cur_len);
|
||||||
|
hdr_len += cur_len;
|
||||||
|
}
|
||||||
|
|
||||||
|
cur_string = g_psHTTPHeaderStrings[HTTP_HDR_CONN_CLOSE];
|
||||||
|
cur_len = strlen(cur_string);
|
||||||
|
fprintf(data_file, NEWLINE "/* \"%s\" (%d bytes) */" NEWLINE, cur_string, cur_len);
|
||||||
|
written += file_put_ascii(data_file, cur_string, cur_len, &i);
|
||||||
|
i = 0;
|
||||||
|
if (precalcChksum) {
|
||||||
|
memcpy(&hdr_buf[hdr_len], cur_string, cur_len);
|
||||||
|
hdr_len += cur_len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cur_string = g_psHTTPHeaderStrings[file_type];
|
||||||
|
cur_len = strlen(cur_string);
|
||||||
|
fprintf(data_file, NEWLINE "/* \"%s\" (%d bytes) */" NEWLINE, cur_string, cur_len);
|
||||||
|
written += file_put_ascii(data_file, cur_string, cur_len, &i);
|
||||||
|
i = 0;
|
||||||
|
if (precalcChksum) {
|
||||||
|
memcpy(&hdr_buf[hdr_len], cur_string, cur_len);
|
||||||
|
hdr_len += cur_len;
|
||||||
|
|
||||||
|
LWIP_ASSERT("hdr_len <= 0xffff", hdr_len <= 0xffff);
|
||||||
|
LWIP_ASSERT("strlen(hdr_buf) == hdr_len", strlen(hdr_buf) == hdr_len);
|
||||||
|
acc = ~inet_chksum(hdr_buf, (u16_t)hdr_len);
|
||||||
|
*http_hdr_len = (u16_t)hdr_len;
|
||||||
|
*http_hdr_chksum = acc;
|
||||||
|
}
|
||||||
|
|
||||||
|
return written;
|
||||||
|
}
|
||||||
|
|
||||||
|
int file_put_ascii(FILE *file, const char* ascii_string, int len, int *i)
|
||||||
|
{
|
||||||
|
int x;
|
||||||
|
for(x = 0; x < len; x++) {
|
||||||
|
unsigned char cur = ascii_string[x];
|
||||||
|
fprintf(file, "0x%02.2x,", cur);
|
||||||
|
if ((++(*i) % HEX_BYTES_PER_LINE) == 0) {
|
||||||
|
fprintf(file, NEWLINE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
int s_put_ascii(char *buf, const char *ascii_string, int len, int *i)
|
||||||
|
{
|
||||||
|
int x;
|
||||||
|
int idx = 0;
|
||||||
|
for(x = 0; x < len; x++) {
|
||||||
|
unsigned char cur = ascii_string[x];
|
||||||
|
sprintf(&buf[idx], "0x%02.2x,", cur);
|
||||||
|
idx += 5;
|
||||||
|
if ((++(*i) % HEX_BYTES_PER_LINE) == 0) {
|
||||||
|
sprintf(&buf[idx], NEWLINE);
|
||||||
|
idx += NEWLINE_LEN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return len;
|
||||||
|
}
|
Binary file not shown.
@ -0,0 +1,8 @@
|
|||||||
|
// stdafx.cpp : source file that includes just the standard includes
|
||||||
|
// MakeFSData_proj.pch will be the pre-compiled header
|
||||||
|
// stdafx.obj will contain the pre-compiled type information
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
|
||||||
|
// TODO: reference any additional headers you need in STDAFX.H
|
||||||
|
// and not in this file
|
@ -0,0 +1,15 @@
|
|||||||
|
// stdafx.h : include file for standard system include files,
|
||||||
|
// or project specific include files that are used frequently, but
|
||||||
|
// are changed infrequently
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "targetver.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <tchar.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: reference additional headers your program requires here
|
@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// Including SDKDDKVer.h defines the highest available Windows platform.
|
||||||
|
|
||||||
|
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
|
||||||
|
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
|
||||||
|
|
||||||
|
#include <SDKDDKVer.h>
|
@ -0,0 +1,245 @@
|
|||||||
|
/*
|
||||||
|
FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd.
|
||||||
|
|
||||||
|
|
||||||
|
***************************************************************************
|
||||||
|
* *
|
||||||
|
* FreeRTOS tutorial books are available in pdf and paperback. *
|
||||||
|
* Complete, revised, and edited pdf reference manuals are also *
|
||||||
|
* available. *
|
||||||
|
* *
|
||||||
|
* Purchasing FreeRTOS documentation will not only help you, by *
|
||||||
|
* ensuring you get running as quickly as possible and with an *
|
||||||
|
* in-depth knowledge of how to use FreeRTOS, it will also help *
|
||||||
|
* the FreeRTOS project to continue with its mission of providing *
|
||||||
|
* professional grade, cross platform, de facto standard solutions *
|
||||||
|
* for microcontrollers - completely free of charge! *
|
||||||
|
* *
|
||||||
|
* >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
|
||||||
|
* *
|
||||||
|
* Thank you for using FreeRTOS, and thank you for your support! *
|
||||||
|
* *
|
||||||
|
***************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
This file is part of the FreeRTOS distribution.
|
||||||
|
|
||||||
|
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License (version 2) as published by the
|
||||||
|
Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
|
||||||
|
>>>NOTE<<< The modification to the GPL is included to allow you to
|
||||||
|
distribute a combined work that includes FreeRTOS without being obliged to
|
||||||
|
provide the source code for proprietary components outside of the FreeRTOS
|
||||||
|
kernel. FreeRTOS is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
more details. You should have received a copy of the GNU General Public
|
||||||
|
License and the FreeRTOS license exception along with FreeRTOS; if not it
|
||||||
|
can be viewed here: http://www.freertos.org/a00114.html and also obtained
|
||||||
|
by writing to Richard Barry, contact details for whom are available on the
|
||||||
|
FreeRTOS WEB site.
|
||||||
|
|
||||||
|
1 tab == 4 spaces!
|
||||||
|
|
||||||
|
http://www.FreeRTOS.org - Documentation, latest information, license and
|
||||||
|
contact details.
|
||||||
|
|
||||||
|
http://www.SafeRTOS.com - A version that is certified for use in safety
|
||||||
|
critical systems.
|
||||||
|
|
||||||
|
http://www.OpenRTOS.com - Commercial support, development, porting,
|
||||||
|
licensing and training services.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
|
|
||||||
|
/* lwIP core includes */
|
||||||
|
#include "lwip/opt.h"
|
||||||
|
#include "lwip/sys.h"
|
||||||
|
#include "lwip/timers.h"
|
||||||
|
#include "lwip/debug.h"
|
||||||
|
#include "lwip/stats.h"
|
||||||
|
#include "lwip/init.h"
|
||||||
|
#include "lwip/tcpip.h"
|
||||||
|
#include "lwip/netif.h"
|
||||||
|
#include "lwip/tcp.h"
|
||||||
|
#include "lwip/udp.h"
|
||||||
|
#include "lwip/dns.h"
|
||||||
|
#include "lwip/dhcp.h"
|
||||||
|
#include "lwip/autoip.h"
|
||||||
|
#include "lwip/sockets.h"
|
||||||
|
|
||||||
|
/* lwIP netif includes */
|
||||||
|
#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 the port-dependent configuration */
|
||||||
|
#include "lwipcfg_msvc.h"
|
||||||
|
|
||||||
|
static struct netif netif;
|
||||||
|
|
||||||
|
static void apps_init( void );
|
||||||
|
|
||||||
|
#define ssiTASK_STATS_INDEX 0
|
||||||
|
#define ssiRUN_TIME_STATS_INDEX 1
|
||||||
|
|
||||||
|
extern void vBasicTelnetServer( void *pvParameters );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The SSI handler callback function passed to lwIP.
|
||||||
|
*/
|
||||||
|
static unsigned short uslwIPAppsSSIHandler( int iIndex, char *pcBuffer, int iBufferLength );
|
||||||
|
|
||||||
|
|
||||||
|
/* The SSI strings that are embedded in the served html files. */
|
||||||
|
static const char *pccSSITags[] =
|
||||||
|
{
|
||||||
|
"rtos_stats",
|
||||||
|
"run_stats"
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* Called from the TCP/IP thread. */
|
||||||
|
void lwIPAppsInit( void *pvArgument )
|
||||||
|
{
|
||||||
|
ip_addr_t ipaddr, netmask, gw;
|
||||||
|
extern err_t ethernetif_init( struct netif *netif );
|
||||||
|
|
||||||
|
( void ) pvArgument;
|
||||||
|
|
||||||
|
ip_addr_set_zero( &gw );
|
||||||
|
ip_addr_set_zero( &ipaddr );
|
||||||
|
ip_addr_set_zero( &netmask );
|
||||||
|
|
||||||
|
LWIP_PORT_INIT_GW(&gw);
|
||||||
|
LWIP_PORT_INIT_IPADDR(&ipaddr);
|
||||||
|
LWIP_PORT_INIT_NETMASK(&netmask);
|
||||||
|
printf("Starting lwIP, local interface IP is %s\n", ip_ntoa(&ipaddr));
|
||||||
|
|
||||||
|
netif_set_default(netif_add(&netif, &ipaddr, &netmask, &gw, NULL, ethernetif_init, tcpip_input));
|
||||||
|
|
||||||
|
#if LWIP_NETIF_STATUS_CALLBACK
|
||||||
|
netif_set_status_callback(&netif, status_callback);
|
||||||
|
#endif /* LWIP_NETIF_STATUS_CALLBACK */
|
||||||
|
#if LWIP_NETIF_LINK_CALLBACK
|
||||||
|
netif_set_link_callback(&netif, link_callback);
|
||||||
|
#endif /* LWIP_NETIF_LINK_CALLBACK */
|
||||||
|
|
||||||
|
netif_set_up( &netif );
|
||||||
|
apps_init();
|
||||||
|
http_set_ssi_handler( uslwIPAppsSSIHandler, pccSSITags, sizeof( pccSSITags ) / sizeof( char * ) );
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* 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 */
|
||||||
|
|
||||||
|
xTaskCreate( vBasicTelnetServer, ( signed char * ) "Telnet", configMINIMAL_STACK_SIZE * 10, NULL, configMAX_PRIORITIES - 2, NULL );
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
static unsigned short uslwIPAppsSSIHandler( int iIndex, char *pcBuffer, int iBufferLength )
|
||||||
|
{
|
||||||
|
static unsigned int uiUpdateCount = 0;
|
||||||
|
static char cUpdateString[ 200 ];
|
||||||
|
extern char *pcMainGetTaskStatusMessage( void );
|
||||||
|
|
||||||
|
( void ) iBufferLength;
|
||||||
|
|
||||||
|
/* The SSI handler function that generates text depending on the index of
|
||||||
|
the SSI tag encountered. */
|
||||||
|
|
||||||
|
switch( iIndex )
|
||||||
|
{
|
||||||
|
case ssiTASK_STATS_INDEX :
|
||||||
|
vTaskList( pcBuffer );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ssiRUN_TIME_STATS_INDEX :
|
||||||
|
vTaskGetRunTimeStats( pcBuffer );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
uiUpdateCount++;
|
||||||
|
sprintf( cUpdateString, "\r\n\r\n%u\r\nStatus - %s", uiUpdateCount, pcMainGetTaskStatusMessage() );
|
||||||
|
strcat( pcBuffer, cUpdateString );
|
||||||
|
return strlen( pcBuffer );
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
@ -0,0 +1,46 @@
|
|||||||
|
/**
|
||||||
|
* Additional settings for the win32 port.
|
||||||
|
* Copy this to lwipcfg_msvc.h and make the config changes you need.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* configuration for this port */
|
||||||
|
#define PPP_USERNAME "Admin"
|
||||||
|
#define PPP_PASSWORD "pass"
|
||||||
|
|
||||||
|
|
||||||
|
/** Define this to the GUID of the windows network adapter to use
|
||||||
|
* or NOT define this if you want PACKET_LIB_ADAPTER_NR to be used */
|
||||||
|
/*#define PACKET_LIB_ADAPTER_GUID "00000000-0000-0000-0000-000000000000"*/
|
||||||
|
/*#define PACKET_LIB_GET_ADAPTER_NETADDRESS(addr) IP4_ADDR((addr), 192,168,1,0)*/
|
||||||
|
/*#define PACKET_LIB_QUIET*/
|
||||||
|
|
||||||
|
#define LWIP_PORT_INIT_IPADDR(addr) IP4_ADDR((addr), configIP_ADDR0,configIP_ADDR1,configIP_ADDR2,configIP_ADDR3)
|
||||||
|
#define LWIP_PORT_INIT_GW(addr) IP4_ADDR((addr), 192,168,0,3)
|
||||||
|
#define LWIP_PORT_INIT_NETMASK(addr) IP4_ADDR((addr), 255,255,255,0)
|
||||||
|
|
||||||
|
/* remember to change this MAC address to suit your needs!
|
||||||
|
the last octet will be increased by netif->num for each netif */
|
||||||
|
#define LWIP_MAC_ADDR_BASE {0x00,0x01,0x02,0x03,0x04,0x05}
|
||||||
|
|
||||||
|
/* configuration for applications */
|
||||||
|
|
||||||
|
#define LWIP_CHARGEN_APP 0
|
||||||
|
#define LWIP_DNS_APP 0
|
||||||
|
#define LWIP_HTTPD_APP 1
|
||||||
|
/* Set this to 1 to use the netconn http server,
|
||||||
|
* otherwise the raw api server will be used. */
|
||||||
|
/*#define LWIP_HTTPD_APP_NETCONN */
|
||||||
|
#define LWIP_NETBIOS_APP 0
|
||||||
|
#define LWIP_NETIO_APP 0
|
||||||
|
#define LWIP_PING_APP 0
|
||||||
|
#define LWIP_RTP_APP 0
|
||||||
|
#define LWIP_SHELL_APP 0
|
||||||
|
#define LWIP_SNTP_APP 0
|
||||||
|
#define LWIP_SOCKET_EXAMPLES_APP 0
|
||||||
|
#define LWIP_TCPECHO_APP 0
|
||||||
|
/* Set this to 1 to use the netconn tcpecho server,
|
||||||
|
* otherwise the raw api server will be used. */
|
||||||
|
/*#define LWIP_TCPECHO_APP_NETCONN */
|
||||||
|
#define LWIP_UDPECHO_APP 0
|
||||||
|
|
||||||
|
|
@ -0,0 +1,297 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||||
|
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||||
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||||
|
* OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* This file is part of the lwIP TCP/IP stack.
|
||||||
|
*
|
||||||
|
* Author: Adam Dunkels <adam@sics.se>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#ifndef __LWIPOPTS_H__
|
||||||
|
#define __LWIPOPTS_H__
|
||||||
|
|
||||||
|
/* SSI options. */
|
||||||
|
#define TCPIP_THREAD_NAME "tcpip"
|
||||||
|
#define LWIP_HTTPD_MAX_TAG_NAME_LEN 20
|
||||||
|
#define LWIP_HTTPD_MAX_TAG_INSERT_LEN 1024
|
||||||
|
#define TCPIP_THREAD_PRIO configLWIP_TASK_PRIORITY
|
||||||
|
#define TCPIP_THREAD_STACKSIZE configMINIMAL_STACK_SIZE * 3
|
||||||
|
|
||||||
|
#define DEFAULT_TCP_RECVMBOX_SIZE 5
|
||||||
|
#define DEFAULT_ACCEPTMBOX_SIZE 5
|
||||||
|
|
||||||
|
#define NO_SYS 0
|
||||||
|
#define LWIP_SOCKET (NO_SYS==0)
|
||||||
|
#define LWIP_NETCONN (NO_SYS==0)
|
||||||
|
|
||||||
|
#define LWIP_IGMP 1
|
||||||
|
#define LWIP_ICMP 1
|
||||||
|
#define LWIP_SNMP 1
|
||||||
|
|
||||||
|
#define LWIP_DNS 1
|
||||||
|
|
||||||
|
#define LWIP_HAVE_LOOPIF 1
|
||||||
|
#define LWIP_NETIF_LOOPBACK 1
|
||||||
|
#define LWIP_LOOPBACK_MAX_PBUFS 10
|
||||||
|
|
||||||
|
#define TCP_LISTEN_BACKLOG 0
|
||||||
|
|
||||||
|
#define LWIP_COMPAT_SOCKETS 1
|
||||||
|
#define LWIP_SO_RCVTIMEO 1
|
||||||
|
#define LWIP_SO_RCVBUF 1
|
||||||
|
|
||||||
|
#define LWIP_TCPIP_CORE_LOCKING 0
|
||||||
|
|
||||||
|
#define LWIP_NETIF_LINK_CALLBACK 0
|
||||||
|
#define LWIP_NETIF_STATUS_CALLBACK 0
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef LWIP_DEBUG
|
||||||
|
|
||||||
|
#define LWIP_DBG_MIN_LEVEL 0
|
||||||
|
#define PPP_DEBUG LWIP_DBG_OFF
|
||||||
|
#define MEM_DEBUG LWIP_DBG_OFF
|
||||||
|
#define MEMP_DEBUG LWIP_DBG_OFF
|
||||||
|
#define PBUF_DEBUG LWIP_DBG_OFF
|
||||||
|
#define API_LIB_DEBUG LWIP_DBG_ON
|
||||||
|
#define API_MSG_DEBUG LWIP_DBG_ON
|
||||||
|
#define TCPIP_DEBUG LWIP_DBG_ON
|
||||||
|
#define NETIF_DEBUG LWIP_DBG_ON
|
||||||
|
#define SOCKETS_DEBUG LWIP_DBG_OFF
|
||||||
|
#define DNS_DEBUG LWIP_DBG_OFF
|
||||||
|
#define AUTOIP_DEBUG LWIP_DBG_OFF
|
||||||
|
#define DHCP_DEBUG LWIP_DBG_OFF
|
||||||
|
#define IP_DEBUG LWIP_DBG_O
|
||||||
|
#define IP_REASS_DEBUG LWIP_DBG_ON
|
||||||
|
#define ICMP_DEBUG LWIP_DBG_OFF
|
||||||
|
#define IGMP_DEBUG LWIP_DBG_OFF
|
||||||
|
#define UDP_DEBUG LWIP_DBG_OFF
|
||||||
|
#define TCP_DEBUG LWIP_DBG_ON
|
||||||
|
#define TCP_INPUT_DEBUG LWIP_DBG_ON
|
||||||
|
#define TCP_OUTPUT_DEBUG LWIP_DBG_ON
|
||||||
|
#define TCP_RTO_DEBUG LWIP_DBG_ON
|
||||||
|
#define TCP_CWND_DEBUG LWIP_DBG_ON
|
||||||
|
#define TCP_WND_DEBUG LWIP_DBG_ON
|
||||||
|
#define TCP_FR_DEBUG LWIP_DBG_ON
|
||||||
|
#define TCP_QLEN_DEBUG LWIP_DBG_ON
|
||||||
|
#define TCP_RST_DEBUG LWIP_DBG_ON
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define LWIP_DBG_TYPES_ON (LWIP_DBG_ON|LWIP_DBG_TRACE|LWIP_DBG_STATE|LWIP_DBG_FRESH|LWIP_DBG_HALT)
|
||||||
|
|
||||||
|
#define TCPIP_MBOX_SIZE 10
|
||||||
|
|
||||||
|
/* ---------- Memory options ---------- */
|
||||||
|
/* MEM_ALIGNMENT: should be set to the alignment of the CPU for which
|
||||||
|
lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2
|
||||||
|
byte alignment -> define MEM_ALIGNMENT to 2. */
|
||||||
|
/* MSVC port: intel processors don't need 4-byte alignment,
|
||||||
|
but are faster that way! */
|
||||||
|
#define MEM_ALIGNMENT 4
|
||||||
|
|
||||||
|
/* MEM_SIZE: the size of the heap memory. If the application will send
|
||||||
|
a lot of data that needs to be copied, this should be set high. */
|
||||||
|
#define MEM_SIZE 10240
|
||||||
|
|
||||||
|
/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application
|
||||||
|
sends a lot of data out of ROM (or other static memory), this
|
||||||
|
should be set high. */
|
||||||
|
#define MEMP_NUM_PBUF 16
|
||||||
|
/* MEMP_NUM_RAW_PCB: the number of UDP protocol control blocks. One
|
||||||
|
per active RAW "connection". */
|
||||||
|
#define MEMP_NUM_RAW_PCB 3
|
||||||
|
/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
|
||||||
|
per active UDP "connection". */
|
||||||
|
#define MEMP_NUM_UDP_PCB 4
|
||||||
|
/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
|
||||||
|
connections. */
|
||||||
|
#define MEMP_NUM_TCP_PCB 5
|
||||||
|
/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
|
||||||
|
connections. */
|
||||||
|
#define MEMP_NUM_TCP_PCB_LISTEN 8
|
||||||
|
/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
|
||||||
|
segments. */
|
||||||
|
#define MEMP_NUM_TCP_SEG 16
|
||||||
|
/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
|
||||||
|
timeouts. */
|
||||||
|
#define MEMP_NUM_SYS_TIMEOUT 15
|
||||||
|
|
||||||
|
/* The following four are used only with the sequential API and can be
|
||||||
|
set to 0 if the application only will use the raw API. */
|
||||||
|
/* MEMP_NUM_NETBUF: the number of struct netbufs. */
|
||||||
|
#define MEMP_NUM_NETBUF 2
|
||||||
|
/* MEMP_NUM_NETCONN: the number of struct netconns. */
|
||||||
|
#define MEMP_NUM_NETCONN 10
|
||||||
|
/* MEMP_NUM_TCPIP_MSG_*: the number of struct tcpip_msg, which is used
|
||||||
|
for sequential API communication and incoming packets. Used in
|
||||||
|
src/api/tcpip.c. */
|
||||||
|
#define MEMP_NUM_TCPIP_MSG_API 16
|
||||||
|
#define MEMP_NUM_TCPIP_MSG_INPKT 16
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------- Pbuf options ---------- */
|
||||||
|
/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
|
||||||
|
#define PBUF_POOL_SIZE 100
|
||||||
|
|
||||||
|
/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
|
||||||
|
#define PBUF_POOL_BUFSIZE 128
|
||||||
|
|
||||||
|
/* PBUF_LINK_HLEN: the number of bytes that should be allocated for a
|
||||||
|
link level header. */
|
||||||
|
#define PBUF_LINK_HLEN 16
|
||||||
|
|
||||||
|
/** SYS_LIGHTWEIGHT_PROT
|
||||||
|
* define SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection
|
||||||
|
* for certain critical regions during buffer allocation, deallocation and memory
|
||||||
|
* allocation and deallocation.
|
||||||
|
*/
|
||||||
|
#define SYS_LIGHTWEIGHT_PROT (NO_SYS==0)
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------- TCP options ---------- */
|
||||||
|
#define LWIP_TCP 1
|
||||||
|
#define TCP_TTL 255
|
||||||
|
|
||||||
|
/* Controls if TCP should queue segments that arrive out of
|
||||||
|
order. Define to 0 if your device is low on memory. */
|
||||||
|
#define TCP_QUEUE_OOSEQ 1
|
||||||
|
|
||||||
|
/* TCP Maximum segment size. */
|
||||||
|
#define TCP_MSS 1024
|
||||||
|
|
||||||
|
/* TCP sender buffer space (bytes). */
|
||||||
|
#define TCP_SND_BUF 2048
|
||||||
|
|
||||||
|
/* TCP sender buffer space (pbufs). This must be at least = 2 *
|
||||||
|
TCP_SND_BUF/TCP_MSS for things to work. */
|
||||||
|
#define TCP_SND_QUEUELEN (4 * TCP_SND_BUF/TCP_MSS)
|
||||||
|
|
||||||
|
/* TCP writable space (bytes). This must be less than or equal
|
||||||
|
to TCP_SND_BUF. It is the amount of space which must be
|
||||||
|
available in the tcp snd_buf for select to return writable */
|
||||||
|
#define TCP_SNDLOWAT (TCP_SND_BUF/2)
|
||||||
|
|
||||||
|
/* TCP receive window. */
|
||||||
|
#define TCP_WND 8096
|
||||||
|
|
||||||
|
/* Maximum number of retransmissions of data segments. */
|
||||||
|
#define TCP_MAXRTX 12
|
||||||
|
|
||||||
|
/* Maximum number of retransmissions of SYN segments. */
|
||||||
|
#define TCP_SYNMAXRTX 4
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------- ARP options ---------- */
|
||||||
|
#define LWIP_ARP 1
|
||||||
|
#define ARP_TABLE_SIZE 10
|
||||||
|
#define ARP_QUEUEING 1
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------- IP options ---------- */
|
||||||
|
/* Define IP_FORWARD to 1 if you wish to have the ability to forward
|
||||||
|
IP packets across network interfaces. If you are going to run lwIP
|
||||||
|
on a device with only one network interface, define this to 0. */
|
||||||
|
#define IP_FORWARD 1
|
||||||
|
|
||||||
|
/* IP reassembly and segmentation.These are orthogonal even
|
||||||
|
* if they both deal with IP fragments */
|
||||||
|
#define IP_REASSEMBLY 1
|
||||||
|
#define IP_REASS_MAX_PBUFS 10
|
||||||
|
#define MEMP_NUM_REASSDATA 10
|
||||||
|
#define IP_FRAG 1
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------- ICMP options ---------- */
|
||||||
|
#define ICMP_TTL 255
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------- DHCP options ---------- */
|
||||||
|
/* Define LWIP_DHCP to 1 if you want DHCP configuration of
|
||||||
|
interfaces. */
|
||||||
|
#define LWIP_DHCP 0
|
||||||
|
|
||||||
|
/* 1 if you want to do an ARP check on the offered address
|
||||||
|
(recommended). */
|
||||||
|
#define DHCP_DOES_ARP_CHECK (LWIP_DHCP)
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------- AUTOIP options ------- */
|
||||||
|
#define LWIP_AUTOIP 0
|
||||||
|
#define LWIP_DHCP_AUTOIP_COOP (LWIP_DHCP && LWIP_AUTOIP)
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------- UDP options ---------- */
|
||||||
|
#define LWIP_UDP 1
|
||||||
|
#define LWIP_UDPLITE 1
|
||||||
|
#define UDP_TTL 255
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------- Statistics options ---------- */
|
||||||
|
|
||||||
|
#define LWIP_STATS 1
|
||||||
|
#define LWIP_STATS_DISPLAY 1
|
||||||
|
|
||||||
|
#if LWIP_STATS
|
||||||
|
#define LINK_STATS 1
|
||||||
|
#define IP_STATS 1
|
||||||
|
#define ICMP_STATS 1
|
||||||
|
#define IGMP_STATS 1
|
||||||
|
#define IPFRAG_STATS 1
|
||||||
|
#define UDP_STATS 1
|
||||||
|
#define TCP_STATS 1
|
||||||
|
#define MEM_STATS 1
|
||||||
|
#define MEMP_STATS 1
|
||||||
|
#define PBUF_STATS 1
|
||||||
|
#define SYS_STATS 1
|
||||||
|
#endif /* LWIP_STATS */
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------- PPP options ---------- */
|
||||||
|
|
||||||
|
#define PPP_SUPPORT 0 /* Set > 0 for PPP */
|
||||||
|
|
||||||
|
#if PPP_SUPPORT
|
||||||
|
|
||||||
|
#define NUM_PPP 1 /* Max PPP sessions. */
|
||||||
|
|
||||||
|
|
||||||
|
/* Select modules to enable. Ideally these would be set in the makefile but
|
||||||
|
* we're limited by the command line length so you need to modify the settings
|
||||||
|
* in this file.
|
||||||
|
*/
|
||||||
|
#define PPPOE_SUPPORT 1
|
||||||
|
#define PPPOS_SUPPORT 1
|
||||||
|
|
||||||
|
#define PAP_SUPPORT 1 /* Set > 0 for PAP. */
|
||||||
|
#define CHAP_SUPPORT 1 /* Set > 0 for CHAP. */
|
||||||
|
#define MSCHAP_SUPPORT 0 /* Set > 0 for MSCHAP (NOT FUNCTIONAL!) */
|
||||||
|
#define CBCP_SUPPORT 0 /* Set > 0 for CBCP (NOT FUNCTIONAL!) */
|
||||||
|
#define CCP_SUPPORT 0 /* Set > 0 for CCP (NOT FUNCTIONAL!) */
|
||||||
|
#define VJ_SUPPORT 1 /* Set > 0 for VJ header compression. */
|
||||||
|
#define MD5_SUPPORT 1 /* Set > 0 for MD5 (see also CHAP) */
|
||||||
|
|
||||||
|
#endif /* PPP_SUPPORT */
|
||||||
|
|
||||||
|
#endif /* __LWIPOPTS_H__ */
|
@ -0,0 +1,452 @@
|
|||||||
|
/*
|
||||||
|
FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd.
|
||||||
|
|
||||||
|
|
||||||
|
***************************************************************************
|
||||||
|
* *
|
||||||
|
* FreeRTOS tutorial books are available in pdf and paperback. *
|
||||||
|
* Complete, revised, and edited pdf reference manuals are also *
|
||||||
|
* available. *
|
||||||
|
* *
|
||||||
|
* Purchasing FreeRTOS documentation will not only help you, by *
|
||||||
|
* ensuring you get running as quickly as possible and with an *
|
||||||
|
* in-depth knowledge of how to use FreeRTOS, it will also help *
|
||||||
|
* the FreeRTOS project to continue with its mission of providing *
|
||||||
|
* professional grade, cross platform, de facto standard solutions *
|
||||||
|
* for microcontrollers - completely free of charge! *
|
||||||
|
* *
|
||||||
|
* >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
|
||||||
|
* *
|
||||||
|
* Thank you for using FreeRTOS, and thank you for your support! *
|
||||||
|
* *
|
||||||
|
***************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
This file is part of the FreeRTOS distribution.
|
||||||
|
|
||||||
|
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License (version 2) as published by the
|
||||||
|
Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
|
||||||
|
>>>NOTE<<< The modification to the GPL is included to allow you to
|
||||||
|
distribute a combined work that includes FreeRTOS without being obliged to
|
||||||
|
provide the source code for proprietary components outside of the FreeRTOS
|
||||||
|
kernel. FreeRTOS is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
more details. You should have received a copy of the GNU General Public
|
||||||
|
License and the FreeRTOS license exception along with FreeRTOS; if not it
|
||||||
|
can be viewed here: http://www.freertos.org/a00114.html and also obtained
|
||||||
|
by writing to Richard Barry, contact details for whom are available on the
|
||||||
|
FreeRTOS WEB site.
|
||||||
|
|
||||||
|
1 tab == 4 spaces!
|
||||||
|
|
||||||
|
http://www.FreeRTOS.org - Documentation, latest information, license and
|
||||||
|
contact details.
|
||||||
|
|
||||||
|
http://www.SafeRTOS.com - A version that is certified for use in safety
|
||||||
|
critical systems.
|
||||||
|
|
||||||
|
http://www.OpenRTOS.com - Commercial support, development, porting,
|
||||||
|
licensing and training services.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
*******************************************************************************
|
||||||
|
* -NOTE- The Win32 port is a simulation (or is that emulation?) only! Do not
|
||||||
|
* expect to get real time behaviour from the Win32 port or this demo
|
||||||
|
* application. It is provided as a convenient development and demonstration
|
||||||
|
* test bed only. This was tested using Windows XP on a dual core laptop.
|
||||||
|
*
|
||||||
|
* - 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
|
||||||
|
*******************************************************************************
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* In addition to the standard demo tasks, the following tasks and tests are
|
||||||
|
* defined and/or created within this file:
|
||||||
|
*
|
||||||
|
* "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.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* Standard includes. */
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
/* Kernel includes. */
|
||||||
|
#include <FreeRTOS.h>
|
||||||
|
#include "task.h"
|
||||||
|
#include "queue.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"
|
||||||
|
|
||||||
|
/* Utils includes. */
|
||||||
|
#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 )
|
||||||
|
|
||||||
|
/* Task function prototypes. */
|
||||||
|
static void prvCheckTask( void *pvParameters );
|
||||||
|
|
||||||
|
/* Defined in lwIPApps.c. */
|
||||||
|
extern void lwIPAppsInit( void *pvArguments );
|
||||||
|
|
||||||
|
/* Callbacks to handle the command line commands defined by the xTaskStats and
|
||||||
|
xRunTimeStats command definitions respectively. These functions are not
|
||||||
|
reentrant! They must be used from one task only - or at least by only one task
|
||||||
|
at a time. */
|
||||||
|
static const signed char *prvTaskStatsCommand( void );
|
||||||
|
static const signed char *prvRunTimeStatsCommand( void );
|
||||||
|
|
||||||
|
/* The string that latches the current demo status. */
|
||||||
|
static char *pcStatusMessage = "All tasks running without error";
|
||||||
|
|
||||||
|
/* Variables used in the creation of the run time stats time base. Run time
|
||||||
|
stats record how much time each task spends in the Running state. */
|
||||||
|
long long llInitialRunTimeCounterValue = 0LL, llRunTimeStatsDivisor = 0LL;
|
||||||
|
|
||||||
|
/* 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. */
|
||||||
|
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 )
|
||||||
|
{
|
||||||
|
/* 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
|
||||||
|
|
||||||
|
/* Register two command line commands to show task stats and run time stats
|
||||||
|
respectively. */
|
||||||
|
vCmdIntRegisterCommand( &xTaskStats );
|
||||||
|
vCmdIntRegisterCommand( &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;
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
static void prvCheckTask( void *pvParameters )
|
||||||
|
{
|
||||||
|
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( ;; )
|
||||||
|
{
|
||||||
|
/* 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() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
void vApplicationIdleHook( void )
|
||||||
|
{
|
||||||
|
const unsigned long ulMSToSleep = 5;
|
||||||
|
|
||||||
|
/* Sleep to reduce CPU load, but don't sleep indefinitely in case there are
|
||||||
|
tasks waiting to be terminated by the idle task. */
|
||||||
|
Sleep( ulMSToSleep );
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
void vApplicationMallocFailedHook( void )
|
||||||
|
{
|
||||||
|
const unsigned long ulLongSleep = 1000UL;
|
||||||
|
|
||||||
|
/* Can be implemented if required, but probably not required in this
|
||||||
|
environment and running this demo. */
|
||||||
|
taskDISABLE_INTERRUPTS();
|
||||||
|
for( ;; )
|
||||||
|
{
|
||||||
|
Sleep( ulLongSleep );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
void vApplicationStackOverflowHook( void )
|
||||||
|
{
|
||||||
|
const unsigned long ulLongSleep = 1000UL;
|
||||||
|
|
||||||
|
/* Can be implemented if required, but probably not required in this
|
||||||
|
environment and running this demo. */
|
||||||
|
taskDISABLE_INTERRUPTS();
|
||||||
|
for( ;; )
|
||||||
|
{
|
||||||
|
Sleep( ulLongSleep );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
taskDISABLE_INTERRUPTS();
|
||||||
|
for( ;; )
|
||||||
|
{
|
||||||
|
Sleep( ulLongSleep );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
char *pcMainGetTaskStatusMessage( void )
|
||||||
|
{
|
||||||
|
return pcStatusMessage;
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
void vMainConfigureTimerForRunTimeStats( void )
|
||||||
|
{
|
||||||
|
LARGE_INTEGER liPerformanceCounterFrequency, liInitialRunTimeValue;
|
||||||
|
|
||||||
|
/* Initialise the variables used to create the run time stats time base.
|
||||||
|
Run time stats record how much time each task spends in the Running
|
||||||
|
state. */
|
||||||
|
|
||||||
|
if( QueryPerformanceFrequency( &liPerformanceCounterFrequency ) == 0 )
|
||||||
|
{
|
||||||
|
llRunTimeStatsDivisor = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* How many times does the performance counter increment in 10ms? */
|
||||||
|
llRunTimeStatsDivisor = liPerformanceCounterFrequency.QuadPart / 1000LL;
|
||||||
|
|
||||||
|
/* What is the performance counter value now, this will be subtracted
|
||||||
|
from readings taken at run time. */
|
||||||
|
QueryPerformanceCounter( &liInitialRunTimeValue );
|
||||||
|
llInitialRunTimeCounterValue = liInitialRunTimeValue.QuadPart;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
unsigned long ulMainGetRunTimeCounterValue( void )
|
||||||
|
{
|
||||||
|
LARGE_INTEGER liCurrentCount;
|
||||||
|
unsigned long ulReturn;
|
||||||
|
|
||||||
|
/* What is the performance counter value now? */
|
||||||
|
QueryPerformanceCounter( &liCurrentCount );
|
||||||
|
|
||||||
|
/* Subtract the performance counter value reading taken when the
|
||||||
|
application started to get a count from that reference point, then
|
||||||
|
scale to a 32 bit number. */
|
||||||
|
ulReturn = ( unsigned long ) ( ( liCurrentCount.QuadPart - llInitialRunTimeCounterValue ) / llRunTimeStatsDivisor );
|
||||||
|
|
||||||
|
return ulReturn;
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
static const signed char *prvTaskStatsCommand( void )
|
||||||
|
{
|
||||||
|
static signed char *pcReturn = NULL;
|
||||||
|
|
||||||
|
/* This is the callback function that is executed when the command line
|
||||||
|
command defined by the xTaskStats structure is entered. This function
|
||||||
|
is called repeatedly until it returns NULL. It is therefore not re-entrant
|
||||||
|
and must not be called from more than one task - or at least - not from
|
||||||
|
more than one task at the same time. */
|
||||||
|
if( pcReturn == NULL )
|
||||||
|
{
|
||||||
|
/* Generate a table of task state. */
|
||||||
|
vTaskList( cTxBuffer );
|
||||||
|
pcReturn = cTxBuffer;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* This command only returns one string, so the second time it is
|
||||||
|
called it just resets itself and returns NULL to say no more strings
|
||||||
|
are going to be generated. */
|
||||||
|
pcReturn = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pcReturn;
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
static const signed char *prvRunTimeStatsCommand( void )
|
||||||
|
{
|
||||||
|
static signed char *pcReturn = NULL;
|
||||||
|
|
||||||
|
/* This is the callback function that is executed when the command line
|
||||||
|
command defined by the xRunTimeStats structure is entered. This function
|
||||||
|
is called repeatedly until it returns NULL. It is therefore not re-entrant
|
||||||
|
and must not be called from more than one task - or at least - not from
|
||||||
|
more than one task at the same time. */
|
||||||
|
|
||||||
|
if( pcReturn == NULL )
|
||||||
|
{
|
||||||
|
/* Generate a table of run time stats. */
|
||||||
|
vTaskGetRunTimeStats( cTxBuffer );
|
||||||
|
pcReturn = cTxBuffer;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* This command only returns one string, so the second time it is
|
||||||
|
called it just resets itself and returns NULL to say no more strings
|
||||||
|
are going to be generated. */
|
||||||
|
pcReturn = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pcReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue