Sending Email with more than 1500 line in 1 time on Fastrak


#1

Hi, We have a strange issue on Fastrack Supreme 20!
At the begin, we use the SMTP Sdk sample and modify the original static void smtp_ClientTestDataWriteHandler(void) to:

ascii Buffer[100];
int index=0;
int testww = 0;
for(index=0;index<=mesureencours;index++){
	//debug remplissage a fond
  	Tblmesures[index].jours = 31;
	Tblmesures[index].mois = 12;
	Tblmesures[index].annee = 2010;
	Tblmesures[index].heure = 24;
	Tblmesures[index].minute = 59;
	Tblmesures[index].conso[0] = 999999;
	Tblmesures[index].conso[1] = 999999;
	Tblmesures[index].conso[2] = 999999;
	Tblmesures[index].conso[3] = 999999;
	Tblmesures[index].conso[4] = 999999;
	Tblmesures[index].Temp[0] = 99;
	Tblmesures[index].Temp[1] = 99;
	wm_sprintf(Buffer,"%d.%d.%d %d:%d\t%li\t%li\t%li\t%li\t%li\t%d.%d\n",Tblmesures[index].jours,Tblmesures[index].mois,Tblmesures[index].annee,Tblmesures[index].heure,Tblmesures[index].minute,Tblmesures[index].conso[0],Tblmesures[index].conso[1],Tblmesures[index].conso[2],Tblmesures[index].conso[3],Tblmesures[index].conso[4],Tblmesures[index].Temp[0],Tblmesures[index].Temp[1]);
	wip_write( pSmtpClientCtx->DataChannel, Buffer, strlen(Buffer) );
}
	wip_write( pSmtpClientCtx->DataChannel, "\n\n\tV1.00", 27 );
	Wip_SMTPCloser();

Where Wip_SMTPCloser() is simply:

adl_atSendResponse ( ADL_AT_UNS, "Wip_SMTPCloser\r\n" );
smtp_ClientTestCtx_t *pSmtpClientCtx = (smtp_ClientTestCtx_t *)&smtp_ClientTestCtx;
wipclosedebugDataChannel = wip_close(pSmtpClientCtx->DataChannel);
pSmtpClientCtx->DataChannel = NULL;
wipclosedebugCnxChannel = wip_close(pSmtpClientCtx->CnxChannel);
pSmtpClientCtx->CnxChannel = NULL;
wip_debug("\t\t\tData et Cnx Channel Closed return: %d %d\n\r",wipclosedebugDataChannel,wipclosedebugCnxChannel);

But we discover that over aproximatly 139 line of mesure (occurences of for) the wip_write function does not work anymore and return 0, wip_write seem to don’t directly write on the smtp data channel but before in a buffer that become full and sometime we receive the email but with only 139lines and sometime not! After that, we choose to add a waiting function when wip_write retunr 0 to let the time to the pseudo buffer to flush itself, we also put to sleep the watchdog during 1 min, deactivate the software WD and the code become:

//kill pendant 10min le watchdog hardware
test = adl_wdPut2Sleep(ADL_TMR_MN_TO_TICK(1));
wip_debug("\t***** WDKill = %d\n\r",test);
//kill le wd soft
adl_wdDeActiveAppWd();

for(preindex=0;preindex<mesureencours/INDEX_MAIL;preindex++){
    wip_debug("\t\tpreindex = %d\r\n",preindex);
    for(index=0;index<=INDEX_MAIL;index++){
	    	//test is to have the maximum size
	    	Tblmesures[preindex*INDEX_MAIL+index].jours = 31;
	    	Tblmesures[preindex*INDEX_MAIL+index].mois = 12;
	    	Tblmesures[preindex*INDEX_MAIL+index].annee = 2010;
	    	Tblmesures[preindex*INDEX_MAIL+index].heure = 24;
	    	Tblmesures[preindex*INDEX_MAIL+index].minute = 59;
	    	Tblmesures[preindex*INDEX_MAIL+index].conso[0] = 999999;
	    	Tblmesures[preindex*INDEX_MAIL+index].conso[1] = 999999;
	    	Tblmesures[preindex*INDEX_MAIL+index].conso[2] = 999999;
	    	Tblmesures[preindex*INDEX_MAIL+index].conso[3] = 999999;
	    	Tblmesures[preindex*INDEX_MAIL+index].conso[4] = 999999;
	    	Tblmesures[preindex*INDEX_MAIL+index].Temp[0] = 99;
	    	Tblmesures[preindex*INDEX_MAIL+index].Temp[1] = 99;
	    	//fin test
	    	wm_sprintf(Buffer,"%d.%d.%d %d:%d\t%li\t%li\t%li\t%li\t%li\t%d.%d\n",Tblmesures[preindex*INDEX_MAIL+index].jours,Tblmesures[preindex*INDEX_MAIL+index].mois,Tblmesures[preindex*INDEX_MAIL+index].annee,Tblmesures[preindex*INDEX_MAIL+index].heure,Tblmesures[preindex*INDEX_MAIL+index].minute,Tblmesures[preindex*INDEX_MAIL+index].conso[0],Tblmesures[preindex*INDEX_MAIL+index].conso[1],Tblmesures[preindex*INDEX_MAIL+index].conso[2],Tblmesures[preindex*INDEX_MAIL+index].conso[3],Tblmesures[preindex*INDEX_MAIL+index].conso[4],Tblmesures[preindex*INDEX_MAIL+index].Temp[0],Tblmesures[preindex*INDEX_MAIL+index].Temp[1]);
	    	longeur = strlen(Buffer);
	    	retourwrite += wip_write( pSmtpClientCtx->DataChannel, Buffer, longeur );
	    	//if(retourwrite<longeur){
	    	if(retourwrite>=5200){//approximatly 75 line with full size
	    		wip_debug("\t\t\tboucle de tempo wip_write return: %d pour %d\n\r",retourwrite,5200);
	    		//wait during buffer flushing
                         //attent pour vider le pseudo buffer
	    		unsigned int j,k;
	    		float l=3.12;
					for(j=0;j<(65000);j++){
						for(k=0;k<4;k++){
							l+=l*.00001;
	    			    }
	    			    l=l*2*cos(l*10*pow(3.15698+l,l))/sqrt(3.256*sqrt(l)*pow(l,pow(l,pow(l,l))));
					}
//NB the for(for)) sequence take about 10sec
				retourwrite = 0;
	    	}
	    }
	}
	wip_write( pSmtpClientCtx->DataChannel, "\n\n\tV1.00", 27 );
	Wip_SMTPCloser();

Now we seem to go over 590 lines but the Fastrack reboot every time my log I got:

***** WDKill = 0
               preindex = 0
                preindex = 1
                preindex = 2
                        boucle de tempo wip_write return: 1450 pour 5200
               preindex = 3
                preindex = 4
                        boucle de tempo wip_write return: 1450 pour 5200
               preindex = 5
                preindex = 6
                        boucle de tempo wip_write return: 1450 pour 5200
               preindex = 7
                preindex = 8
                preindex = 9
                        boucle de tempo wip_write return: 1450 pour 5200
               preindex = 10
                preindex = 11
                        boucle de tempo wip_write return: 1450 pour 5200
               preindex = 12
                preindex = 13
                        boucle de tempo wip_write return: 1450 pour 5200
               preindex = 14
                preindex = 15
                        boucle de tempo wip_write return: 1450 pour 5200
               preindex = 16
                preindex = 17
                preindex = 18
                        boucle de tempo wip_write return: 1450 pour 5200
               preindex = 19
                preindex = 20
                        boucle de tempo wip_write return: 1450 pour 5200
               preindex = 21
                preindex = 22
                        boucle de tempo wip_write return: 1450 pour 5200
               preindex = 23
                preindex = 24
                        boucle de tempo wip_write return: 1450 pour 5200
               preindex = 25
                preindex = 26
                preindex = 27
                        boucle de tempo wip_write return: 1450 pour 5200
               preindex = 28
                preindex = 29
                        boucle de tempo wip_write return: 1450 pour 5200
               preindex = 30
                preindex = 31
                        boucle de tempo wip_write return: 1450 pour 5200
               preindex = 32
                preindex = 33
                preindex = 34
                        boucle de tempo wip_write return: 1450 pour 5200
               preindex = 35
                preindex = 36
                        boucle de tempo wip_write return: 1450 pour 5200
               preindex = 37
                preindex = 38
                        boucle de tempo wip_write return: 1450 pour 5200
               preindex = 39
                preindex = 40
                        boucle de tempo wip_write return: 1450 pour 5200
               preindex = 41
                preindex = 42
                preindex = 43
                        boucle de tempo wip_write return: 1450 pour 5200
               preindex = 44
                preindex = 45
                        boucle de tempo wip_write return: 1450 pour 5200
               preindex = 46
                preindex = 47
                        boucle de tempo wip_write return: 1450 pour 5200
               preindex = 48
                preindex = 49
                        boucle de tempo wip_write return: 1450 pour 5200
               preindex = 50
                preindex = 51
                preindex = 52
                        boucle de tempo wip_write return: 1450 pour 5200
               preindex = 53
                preindex = 54
                        boucle de tempo wip_write return: 1450 pour 5200
               preindex = 55
                preindex = 56
                        boucle de tempo wip_write return: 1450 pour 5200
               preindex = 57
                preindex = 58
                preindex = 59
                        boucle de tempo wip_write return: 1450 pour 5200
+WIND: 13
adl_main

If someone could help…

An other poitn, in the WIP plugin documentation, it’s write that, when the wip_write return 0 or a number less than the expected wrote char number, we have to wait the next WIP_CEV_WRITE event… but I never catch again a WIP_CEV_WRITE event?? so how to doing that?