Hi, I am customizing the web_hvac application provided by freescale. I have change a webpage in order to type a text in a field, and then click on a button to send that text to the microcontroller. Then I store that information into flash. Problem arrives when I click the button and the function executes.
The following mistake comes:
TCP/IP, Task ID 0x10005, TD 0x20006a34
Task Error Code Out of Memory(0x4), State Rx Msg Blocked, timeout
I am not sure that this will get solve by adding more stack to TCP/IP task, and that is I the reason I am also posting the function I am using to resolve the click on the button. This function is based on functions provided by freescale, therefore I dont know if the problem is the function.
int cgi_clave_ingresar(HTTPD_SESSION_STRUCT *session) { uint_32 len = 0,index=0; char clave[100]; boolean bParams = FALSE; char buffer[100]; uint_8 MensajeCan[8], i; RTC_TIME_STRUCT time_rtc; html_head(session->sock,"HVAC Settings response"); httpd_sendstr(session->sock, "<BODY>\n"); httpd_sendstr(session->sock, "<br><br>\n"); if (session->request.content_len) { len = session->request.content_len; len = httpd_read(session, buffer, (int)((len > sizeof(buffer)) ? sizeof(buffer) : len)); buffer[len] = 0; session->request.content_len -= len; len = 0; if (httpd_get_varval(session, buffer, "clave", clave, sizeof(clave))) { bParams = TRUE; if(PasswordIn[0] == 0x03){ printf("El sistema esta bloqueado por intentos fallidos, espere un tiempo\n"); return; } if(Password[0] == clave[0] && Password[1] == clave[1] && Password[2] == clave[2] && Password[3] == clave[3] && Password[4] == clave[4] && Password[5] == clave[5]){ //Si el password es correcto lo almacena para las demas tareas. for(i = 0 ; i <= 5; i++){ WriteByte(clave[i], PASSWORD_IN + i); MensajeCan[ i+1 ] = clave[i]; } MensajeCan[ 0 ] = WR_PASSWORD_IN; FifoInsertDataCAN(MensajeCan, GRYPHON_BROADCAST ); } else{ switch(PasswordIn[0]){ //se utiliza el mismo arreglo de chars para guardar la cantidad de intentos case(0x00): printf("Primer Intento, la palabra clave es incorrecta\n"); WriteByte(0x01, PASSWORD_IN) ; //PasswordIn[0] = 0x01; break; case(0x01): printf("Segundo Intento, la palabra clave es incorrecta\n"); WriteByte(0x02, PASSWORD_IN) ; //PasswordIn[0] = 0x02; break; case(0x02): printf("Tercer Intento, la palabra clave es incorrecta\n"); printf("No se pueden realizar mas intentos\n"); WriteByte(0x03, PASSWORD_IN) ; //PasswordIn[0] = 0x03; _rtc_get_time (&time_rtc); WriteByte(time_rtc.minutes, PASSWORD_IN + 1); //PasswordIn[1] = time_rtc.minutes; //Tambien se almacena el minuto break; //del tercer intento fallido } } httpd_sendstr(session->sock, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">" "<html><head><title>MQX</title>" "<meta http-equiv=\"REFRESH\" content=\"0;url=hvac.html\"></HEAD>" "<BODY></BODY></HTML>"); } } if (!bParams) { httpd_sendstr(session->sock, "No parameters received.<br>\n"); } return session->request.content_len; }
I dont know what is going on. Functions write byte use _lwmem_alloc so the buffer to write in flash should not be included in the stack provided for the task. Besides, when I add breakpoints to this function ( cgi_clave_ingresar)the error doesnt come always in the same line. 0_o
Thanks for your help
Hi !
It looks like as you allocated all memory and TCP/IP stack can't allocate memory - check available free memory (MQX->Lightweight Memory Blocks), and check if you correctly release memory allocated in your write byte function...
The TCP/IP task may be running out of memory due to the number of connections. Increasing the TCP/IP stack size will not solve the problem - in fact, it will do the opposite, as less memory will be available for dynamic resources. As suggested, using Lightweight Memory Blocks will tell you what memory is currently allocated.
You can also set a breakpoint on line 79 of td_serr.c, to catch the spot that you are running out of memory.
Also, there is a vFTF session tomorrow (July 15th @ 3:30 EDT) on RTCS: "vFTF - Implementing Ethernet Connectivity with the Complimentary Freescale MQX RTOS" which covers some things you can do to reduce memory requirements.