Finally modified to receive TCP echoes

This commit is contained in:
Alexey Bazlaev 2023-02-17 18:52:04 +07:00
parent 14157aaf99
commit 4d9d6c1138
9 changed files with 277 additions and 175 deletions

View File

@ -202,7 +202,7 @@ const BaseType_t xBacklog = 20;
configASSERT( xConnectedSocket != FREERTOS_INVALID_SOCKET );
/* Spawn a task to handle the connection. */
xTaskCreate( prvServerConnectionInstance, "EchoServer", usUsedStackSize, ( void * ) xConnectedSocket, tskIDLE_PRIORITY, NULL );
xTaskCreate( prvServerConnectionInstance, "EchoServer", usUsedStackSize, ( void * ) xConnectedSocket, tskIDLE_PRIORITY + 1, NULL );
}
}
/*-----------------------------------------------------------*/
@ -281,8 +281,9 @@ uint8_t *pucRxBuffer;
/* Finished with the socket, buffer, the task. */
vPortFree( pucRxBuffer );
FreeRTOS_closesocket( xConnectedSocket );
#ifdef DEBUG_TASK_DELETE
vTaskDelete( NULL );
#endif
}
/*-----------------------------------------------------------*/

View File

@ -188,6 +188,7 @@
eDHCPState_t eExpectedState )
{
BaseType_t xGivingUp = pdFALSE;
char cBuffer[16];
#if ( ipconfigUSE_DHCP_HOOK != 0 )
eDHCPCallbackAnswer_t eAnswer;
@ -402,7 +403,8 @@
/* Look for acks coming in. */
if( prvProcessDHCPReplies( dhcpMESSAGE_TYPE_ACK ) == pdPASS )
{
FreeRTOS_debug_printf( ( "vDHCPProcess: acked %xip\n", ( unsigned ) FreeRTOS_ntohl( EP_DHCPData.ulOfferedIPAddress ) ) );
FreeRTOS_inet_ntoa( EP_DHCPData.ulOfferedIPAddress, cBuffer );
FreeRTOS_printf( ( "vDHCPProcess: acked ip %s\n", cBuffer) );
/* DHCP completed. The IP address can now be used, and the
* timer set to the lease timeout time. */
@ -728,6 +730,7 @@
/* memcpy() helper variables for MISRA Rule 21.15 compliance*/
const void * pvCopySource;
void * pvCopyDest;
char cBuffer[ 16 ];
/* Passing the address of a pointer (pucUDPPayload) because FREERTOS_ZERO_COPY is used. */
lBytes = FreeRTOS_recvfrom( xDHCPSocket, &pucUDPPayload, 0U, FREERTOS_ZERO_COPY, NULL, NULL );
@ -964,7 +967,8 @@
{
/* HT:endian: used to be network order */
EP_DHCPData.ulOfferedIPAddress = pxDHCPMessage->ulYourIPAddress_yiaddr;
FreeRTOS_printf( ( "vDHCPProcess: offer %xip\n", ( unsigned ) FreeRTOS_ntohl( EP_DHCPData.ulOfferedIPAddress ) ) );
FreeRTOS_inet_ntoa( EP_DHCPData.ulOfferedIPAddress, cBuffer );
FreeRTOS_printf( ( "vDHCPProcess: offer ip %s\n", cBuffer) );
xReturn = pdPASS;
}
}
@ -1094,6 +1098,7 @@
BaseType_t xResult = pdFAIL;
uint8_t * pucUDPPayloadBuffer;
struct freertos_sockaddr xAddress;
char cBuffer[ 16 ];
static const uint8_t ucDHCPRequestOptions[] =
{
/* Do not change the ordering without also changing
@ -1133,7 +1138,9 @@
pvCopyDest = &pucUDPPayloadBuffer[ dhcpFIRST_OPTION_BYTE_OFFSET + dhcpDHCP_SERVER_IP_ADDRESS_OFFSET ];
( void ) memcpy( pvCopyDest, pvCopySource, sizeof( EP_DHCPData.ulDHCPServerAddress ) );
FreeRTOS_debug_printf( ( "vDHCPProcess: reply %xip\n", ( unsigned ) FreeRTOS_ntohl( EP_DHCPData.ulOfferedIPAddress ) ) );
FreeRTOS_inet_ntoa( EP_DHCPData.ulOfferedIPAddress, cBuffer );
FreeRTOS_printf( ( "vDHCPProcess: reply ip %s\n", cBuffer) );
iptraceSENDING_DHCP_REQUEST();
if( FreeRTOS_sendto( xDHCPSocket, pucUDPPayloadBuffer, sizeof( DHCPMessage_IPv4_t ) + uxOptionsLength, FREERTOS_ZERO_COPY, &xAddress, ( socklen_t ) sizeof( xAddress ) ) == 0 )

View File

@ -298,6 +298,7 @@
void vTCPStateChange( FreeRTOS_Socket_t * pxSocket,
enum eTCP_STATE eTCPState )
{
char cBuffer[16];
FreeRTOS_Socket_t * xParent = pxSocket;
BaseType_t bBefore = tcpNOW_CONNECTED( ( BaseType_t ) pxSocket->u.xTCP.eTCPState ); /* Was it connected ? */
BaseType_t bAfter = tcpNOW_CONNECTED( ( BaseType_t ) eTCPState ); /* Is it connected now ? */
@ -495,9 +496,10 @@
{
if( ( xTCPWindowLoggingLevel >= 0 ) && ( ipconfigTCP_MAY_LOG_PORT( pxSocket->usLocalPort ) ) )
{
FreeRTOS_debug_printf( ( "Socket %u -> %xip:%u State %s->%s\n",
FreeRTOS_inet_ntoa( FreeRTOS_ntohl(pxSocket->u.xTCP.ulRemoteIP), cBuffer );
FreeRTOS_debug_printf( ( "Socket %u -> ip %s:%u State %s->%s\n",
pxSocket->usLocalPort,
( unsigned ) pxSocket->u.xTCP.ulRemoteIP,
cBuffer,
pxSocket->u.xTCP.usRemotePort,
FreeRTOS_GetTCPStateName( ( UBaseType_t ) xPreviousState ),
FreeRTOS_GetTCPStateName( ( UBaseType_t ) eTCPState ) ) );

View File

@ -49,9 +49,10 @@
//#define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 1
//#define ipconfigZERO_COPY_RX_DRIVER 1
//#define ipconfigZERO_COPY_TX_DRIVER 1
#define ipconfigUSE_LINKED_RX_MESSAGES 1
//#define ipconfigUSE_LINKED_RX_MESSAGES 1
//#define ipconfigUDP_MAX_RX_PACKETS 10
#define ipconfigSUPPORT_SIGNALS 1
//#define ipconfigSUPPORT_SIGNALS 1
#define ipconfigUSE_TCP_WIN 0
#ifdef DEBUG

View File

@ -265,14 +265,17 @@ int32_t ARM_ETH_MAC_SetAddressFilter (const ARM_ETH_MAC_ADDR *ptr_addr, uint32_t
*/
int32_t ARM_ETH_MAC_SendFrame (const uint8_t *frame, uint32_t len, uint32_t flags)
{
FreeRTOS_debug_printf(("ARM_ETH_MAC_SendFrame\n"));
if (frame != NULL & len > 0)
{
if (SUCCESS == enet_frame_transmit((uint8_t*)frame, len))
return ARM_DRIVER_OK;
else
{
FreeRTOS_debug_printf(("ARM_ETH_MAC_SendFrame_Error\n"));
return ARM_DRIVER_ERROR;
}
}else
FreeRTOS_debug_printf(("ARM_ETH_MAC_SendFrame_Error_PARAMETER\n"));
return ARM_DRIVER_ERROR_PARAMETER;
}
@ -287,15 +290,17 @@ int32_t ARM_ETH_MAC_SendFrame (const uint8_t *frame, uint32_t len, uint32_t flag
*/
int32_t ARM_ETH_MAC_ReadFrame (uint8_t *frame, uint32_t len)
{
FreeRTOS_debug_printf(("ARM_ETH_MAC_ReadFrame\n"));
if (frame != NULL & len > 0)
{
if (SUCCESS == enet_frame_receive(frame, len))
return ARM_DRIVER_OK;
else
{
FreeRTOS_debug_printf(("ARM_ETH_MAC_ReadFrame_Error\n"));
return ARM_DRIVER_ERROR;
}
}else
FreeRTOS_debug_printf(("ARM_ETH_MAC_ReadFrame_Error_PARAMETER\n"));
return ARM_DRIVER_ERROR_PARAMETER;
}

View File

@ -22,8 +22,8 @@
#define RTE_RTOS_FreeRTOS_CORE /* RTOS FreeRTOS Core */
/* ARM.FreeRTOS::RTOS:Event Groups:10.5.1 */
#define RTE_RTOS_FreeRTOS_EVENTGROUPS /* RTOS FreeRTOS Event Groups */
/* ARM.FreeRTOS::RTOS:Heap:Heap_2:10.5.1 */
#define RTE_RTOS_FreeRTOS_HEAP_2 /* RTOS FreeRTOS Heap 2 */
/* ARM.FreeRTOS::RTOS:Heap:Heap_4:10.5.1 */
#define RTE_RTOS_FreeRTOS_HEAP_4 /* RTOS FreeRTOS Heap 4 */
/* GigaDevice::Device:GD32F10x_StdPeripherals:DMA:2.0.2 */
#define RTE_DEVICE_STDPERIPHERALS_DMA
/* GigaDevice::Device:GD32F10x_StdPeripherals:ENET:2.0.2 */

File diff suppressed because one or more lines are too long

View File

@ -125,7 +125,7 @@
<SetRegEntry>
<Number>0</Number>
<Key>DLGTARM</Key>
<Name>(1010=1360,271,1810,828,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)</Name>
<Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
@ -157,7 +157,39 @@
<Bp>
<Number>0</Number>
<Type>0</Type>
<LineNumber>612</LineNumber>
<LineNumber>511</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134229006</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>.\FreeRTOS\source\FreeRTOS_DHCP.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\Test_project_for_GD32107C_EVAL\FreeRTOS/source/FreeRTOS_DHCP.c\511</Expression>
</Bp>
<Bp>
<Number>1</Number>
<Type>0</Type>
<LineNumber>1350</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>0</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>.\FreeRTOS\source\FreeRTOS_TCP_Transmission.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
<Bp>
<Number>2</Number>
<Type>0</Type>
<LineNumber>474</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>0</Address>
<ByteObject>0</ByteObject>
@ -171,9 +203,9 @@
<Expression></Expression>
</Bp>
<Bp>
<Number>1</Number>
<Number>3</Number>
<Type>0</Type>
<LineNumber>591</LineNumber>
<LineNumber>657</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>0</Address>
<ByteObject>0</ByteObject>
@ -186,6 +218,86 @@
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
<Bp>
<Number>4</Number>
<Type>0</Type>
<LineNumber>282</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>0</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>.\main.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
<Bp>
<Number>5</Number>
<Type>0</Type>
<LineNumber>469</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>0</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>.\main.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
<Bp>
<Number>6</Number>
<Type>0</Type>
<LineNumber>474</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>0</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>.\main.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
<Bp>
<Number>7</Number>
<Type>0</Type>
<LineNumber>652</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>0</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>.\main.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
<Bp>
<Number>8</Number>
<Type>0</Type>
<LineNumber>657</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>0</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>.\main.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
</Breakpoint>
<WatchWindow1>
<Ww>
@ -216,7 +328,7 @@
<Ww>
<count>5</count>
<WinNumber>1</WinNumber>
<ItemText>dma_current_rxdesc</ItemText>
<ItemText>dma_current_txdesc</ItemText>
</Ww>
<Ww>
<count>6</count>
@ -226,14 +338,39 @@
<Ww>
<count>7</count>
<WinNumber>1</WinNumber>
<ItemText>pxCurrentTCB</ItemText>
<ItemText>pucRxBuffer</ItemText>
</Ww>
<Ww>
<count>8</count>
<WinNumber>1</WinNumber>
<ItemText>EP_DHCPData</ItemText>
</Ww>
<Ww>
<count>9</count>
<WinNumber>1</WinNumber>
<ItemText>EP_IPv4_SETTINGS</ItemText>
</Ww>
<Ww>
<count>10</count>
<WinNumber>1</WinNumber>
<ItemText>xDHCPData</ItemText>
</Ww>
<Ww>
<count>11</count>
<WinNumber>1</WinNumber>
<ItemText>xNetworkAddressing</ItemText>
</Ww>
<Ww>
<count>12</count>
<WinNumber>1</WinNumber>
<ItemText>eLeasedAddress</ItemText>
</Ww>
</WatchWindow1>
<MemoryWindow1>
<Mm>
<WinNumber>1</WinNumber>
<SubType>0</SubType>
<ItemText>0x200072FA</ItemText>
<ItemText>EP_DHCPData</ItemText>
<AccSizeX>0</AccSizeX>
</Mm>
</MemoryWindow1>
@ -254,7 +391,7 @@
</Mm>
</MemoryWindow3>
<ScvdPack>
<Filename>E:\Arm\Packs\ARM\CMSIS-FreeRTOS\10.5.1\CMSIS\RTOS2\FreeRTOS\FreeRTOS.scvd</Filename>
<Filename>C:\Users\User\AppData\Local\Arm\Packs\ARM\CMSIS-FreeRTOS\10.5.1\CMSIS\RTOS2\FreeRTOS\FreeRTOS.scvd</Filename>
<Type>ARM.CMSIS-FreeRTOS.10.5.1</Type>
<SubType>1</SubType>
</ScvdPack>
@ -300,12 +437,6 @@
<pszMrulep></pszMrulep>
<pSingCmdsp></pSingCmdsp>
<pMultCmdsp></pMultCmdsp>
<SystemViewers>
<Entry>
<Name>System Viewer\ENET_DMA</Name>
<WinId>35905</WinId>
</Entry>
</SystemViewers>
</TargetOption>
</Target>
@ -651,7 +782,7 @@
<GroupNumber>2</GroupNumber>
<FileNumber>28</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\FreeRTOS\source\portable\NetworkInterface\board_family\NetworkInterface.c</PathWithFileName>

View File

@ -339,7 +339,7 @@
<v6Rtti>0</v6Rtti>
<VariousControls>
<MiscControls>-D DEBUG -Wno-pragma-pack -Wno-macro-redefined</MiscControls>
<Define></Define>
<Define>DEBUG_TASK_DELETE</Define>
<Undefine></Undefine>
<IncludePath>.\FreeRTOS\source\portable\NetworkInterface\include;.\FreeRTOS\source\include;.\FreeRTOS\source\portable\Compiler\Keil;.\DemoTasks\include</IncludePath>
</VariousControls>
@ -779,7 +779,7 @@
<targetInfo name="Target 1"/>
</targetInfos>
</component>
<component Cbundle="FreeRTOS" Cclass="RTOS" Cgroup="Heap" Cvariant="Heap_2" Cvendor="ARM" Cversion="10.5.1" condition="FreeRTOS Heap">
<component Cbundle="FreeRTOS" Cclass="RTOS" Cgroup="Heap" Cvariant="Heap_4" Cvendor="ARM" Cversion="10.5.1" condition="FreeRTOS Heap">
<package name="CMSIS-FreeRTOS" schemaVersion="1.7.7" url="https://www.keil.com/pack/" vendor="ARM" version="10.5.1"/>
<targetInfos>
<targetInfo name="Target 1"/>