Tool/software: TI-RTOS
Hi,
I am trying to add Ethernet communication to my existing project. I use TCP IP stack in TI-RTOS. When my MCU is configured as a server and my remote device is a client communication works fine. I stream 24 bytes approximately at 3kHz rate. I am trying to implement the opposite case with MCU acting as a client. I am able to establish connection, however after couple of seconds transmission stops. I have used Wireshark to look at the transmission communicates. I always get TCP WINDOW FULL, TCP RETRANSMISSION a couple of times and finally it ends with TCP ZERO COMMUNICATE. TCP client (MCU) stops transmission, even though the send() command is in tcpHandler() task while(1) loop and semaphore or ctr1 variable (depending how I release the loop()) are being set by the interrupt. I used loging info to check that.
I attach fragment of my code below. I am currently triggering tcp_task from a timer interrupt (I tried using semaphores and dummy control variable to trigger task loop).
Void tcpHandler(UArg arg0, UArg arg1) // tcp task { SOCKET lSocket; struct sockaddr_in sLocalAddr; fdOpenSession(TaskSelf()); lSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (lSocket < 0) { System_printf("tcpHandler: socket failed\n"); Task_exit(); return; } memset((char *)&sLocalAddr, 0, sizeof(sLocalAddr)); sLocalAddr.sin_family = AF_INET; sLocalAddr.sin_addr.s_addr = inet_addr("18.62.20.135");//htonl(INADDR_ANY); sLocalAddr.sin_port = htons(5000); System_printf("connected!"); TimerDisable(TIMER2_BASE, TIMER_A); // enable Timer 2 System_flush(); while(connect(lSocket, (struct sockaddr *)&sLocalAddr, sizeof(sLocalAddr)) < 0){ SysCtlDelay(g_ui32SysClock/200); } int nbytes = 3*8; TimerEnable(TIMER2_BASE, TIMER_A); // enable Timer 2 while (true) { if(ctr1==1){ // res=Semaphore_pend(TCP_semaphore, BIOS_WAIT_FOREVER); Log_info1("TOGGLED2 [%u] TIMES",ToggleCount); // send toggle count to UIA char temp[24]=data_to_transmit; send(lSocket, (char *)&temp, nbytes, 0 ); ctr1=0; } } } void ISRTimer(void) { TimerIntClear(TIMER2_BASE, TIMER_TIMA_TIMEOUT); // must clear timer flag FROM timer Log_info1("TOGGLED [%u] TIMES",ToggleCount); // send toggle count to UIA ToggleCount += 1; // keep track of #toggles // Semaphore_post(TCP_semaphore); ctr1=1; }
I have tried also assigning static IP to PC and Tiva and connecting directly with a switch. Same result.
Thanks in advance.
CCS7.3
TI-RTOS 2.16.1.14
XDC 3.32.0.06