rooneytoons wrote on Monday, July 16, 2018:
I am trying to create a simple client/server demo sending small packets across the network using a loopback interface on my EFM32 GG Cortex-M3 microcontroller.
I have copied verbatim the example code given on the freeros website here https://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_Networking_Tutorial_Receiving_TCP_Data.html and here https://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_Networking_Tutorial_Sending_TCP_Data.html for sending and recieving.
In my main function I simply call the FreeRTOS_IPStart() function (which replaces the FreeRTOS_IPInit function) and then starts the threads, main function looks like this:
void main ( void )
{
CHIP_Init();
SWO_SetupForPrint();
extern NetworkInterface_t *xLoopbackInterface;
pxLoopback_FillInterfaceDescriptor(1, xLoopbackInterface);
FreeRTOS_AddNetworkInterface(xLoopbackInterface);
FreeRTOS_IPStart();
xTaskCreate(prvEchoClientRxTask, "rx", 300, NULL, 1U, &RXTask);
xTaskCreate(vTCPSend, "tx", 300, NULL, 2U, &TXTask);
vTaskStartScheduler();
for(;;){
puts("shouldnt be here");
}
return;
}
I am unsure whether or not the way I have initialised the interface is right or not - I am using the FreeRTOS +TCP unofficial release with the loopback NetworkInterface.c
Stepping through, I meet my first problem in FreeRTOS_connect, when the prvConnectStart( pxSocket, pxAddress) is called the socket has not yet been bound, so goes into the condition that binds the socket…
else if( socketSOCKET_IS_BOUND( pxSocket ) == pdFALSE )
{
/* Bind the socket to the port that the client task will send from.
Non-standard, so the error returned is that returned by bind(). */
xResult = FreeRTOS_bind( ( Socket_t ) pxSocket, NULL, 0u );
}
xResult becomes zero here, indicating a successful bind.
Back in the connect function, xResult becomes equal to the return value of FreeRTOS_issocketconnected( pxSocket ); which is 0.
The code then finally gets stuck looping in the idle hook after xEventGroupWaitBits() is called.
I am using GCC compiler and am programming on Silicon labs’ IDE ‘Simplicity Studios’.
Thanks for any help!