FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [May 2013 Threads]
We are porting FreeRTOS on Pxa303 board, we want to establish ethernet communication between 2 pxa303 boards. We are using FreeRTOS+UDP(FreeRTOSV7.4.1\FreeRTOS-Plus\Source\FreeRTOS-Plus-UDP) for this purpose, twoechoclients.c(FreeRTOSV7.4.1\FreeRTOS-Plus\Demo\Common\FreeRTOS_Plus_UDP_Demos\EchoClients\) as a client applicaion, as mentioned at http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/Embedded_Ethernet_Examples/Common_Echo_Clients.shtml, website suggests desktop computer to use as a server, but we want another pxa303 board to be used as a server. Can any one guide us with how to program a server application for Pxa303 board?
FreeRTOS+UDP uses a standard (ish) sockets interface, so the procedure is as per using any other Berkeley sockets IP stack:
1) Call FreeRTOS_socket() to create a socket - it will be created with a receive block time of portMAX_DELAY.
2) Call FreeRTOS_bind() to bind the socket to the echo port (port 7 by default).
3) Call FreeRTOS_recvfrom() on the socket. If configINCLUDE_vTaskSuspend is set to 1 the call will only return once data has been received.
4) Call FreeRTOS_sendto() to send the received data back from whence it came.
5) Go back to step 3 to wait for more data.
It would look something like this (I have not tried running this code! It is for example only)
static void prvEchoServer( void *pvParameters )
{
xSocket_t xSocket;
struct freertos_sockaddr xAddress;
/* Make sure array is large enough and that it does not overflow the
task stack. Make it static if necessary. */
int8_t cBuffer[ 25 ];
uint32_t xAddressLength = sizeof( xAddress );
long lBytes;
/* Remove compiler warning about unused parameters. */
( void ) pvParameters;
for( ;; )
{
/* Create a socket. */
xSocket = FreeRTOS_socket( FREERTOS_AF_INET,
FREERTOS_SOCK_DGRAM,
FREERTOS_IPPROTO_UDP );
/* Bind the the standard echo server port number. */
xAddress.sin_port = FreeRTOS_htons( echoECHO_PORT );
FreeRTOS_bind( xSocket, &xAddress, sizeof( xAddress ) );
/* Send a number of echo requests. */
for( ;; )
{
/* Wait for data to arrive on the echo port. */
lBytes = FreeRTOS_recvfrom( xSocket, cBuffer, sizeof( cBuffer ),
0, &xAddress, &xAddressLength );
/* Send the received data back from the originating address. */
FreeRTOS_sendto( xSocket, cBuffer, lBytes, 0,
&xAddress, xAddressLength );
}
}
}
Regards.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.