Hi, I've been testing my new web page overnight for the last 2 nights
and when I come back in the morning the browswer is hung in a "Cannot
find server" screen. I can still ping and FTP the board at this point, but can't access any web page. This has happened before I included the floating point library in the project and afterwards.
My test page uses "<meta http-equiv="refresh" content="20">" to
refresh the page every 20 secs. I've tested the page during the day
and it looks OK, displaying the proper values etc.
I made the changes in the web server code to supports 5 char £xxxx
sequences and every page looks OK. The code I added in webinterface.c
in fcInsertString() to handle my new page is
case 'W': // ADC Raw
iChan=*ptrBuffer;
iChan-='1';
cPtr = fnDebugDec( (long)ADC_Chans[iChan].Raw, 0, cValue);
*usLengthToSend = (cPtr - cValue);
break;
case 'Z': // ADC Min
iChan=*ptrBuffer;
iChan-='1';
cPtr = fnDebugDec( (long)ADC_Chans[iChan].Min, 0, cValue);
*usLengthToSend = (cPtr - cValue);
break;
case 'H': // ADC Max
iChan=*ptrBuffer;
iChan-='1';
cPtr = fnDebugDec( (long)ADC_Chans[iChan].Max, 0, cValue);
*usLengthToSend = (cPtr - cValue);
break;
case 'T': // ADC AlarmLo
iChan=*ptrBuffer;
iChan-='1';
cPtr = fnFltToStr(ADC_Chans[iChan].AlarmLo, cValue);
*usLengthToSend = (cPtr - cValue);
break;
case 'G': // ADC AlarmHi
iChan=*ptrBuffer;
iChan-='1';
cPtr = fnFltToStr(ADC_Chans[iChan].AlarmHi, cValue);
*usLengthToSend = (cPtr - cValue);
break;
case 'Q': // ADC AlarmState
iChan=*ptrBuffer;
iChan-='1';
cPtr=uStrcpy(cValue,aAlarmStates[ADC_ChansiChan].AlarmState]);
*usLengthToSend = (cPtr - cValue)-1;
break;
Looking at the memory stats before and after it hangs shows
Free heap = 0x0af4 from 0x4c00
Unused stack = 0x2823
so that looks OK.
I can try refreshing a dummy page that doesn't do any
dynamic processing overnight and see what happens. I've been running
my regular page for 3.5 hours this morning so far and it hasn't
failed yet. I've been running these tests from the CW debuger.
Here's my string <--> float functions, but the web hung before used these
float fnStrToFlt(char* aStr) {
// Convert a non terminated string to a float. Limited to 1 dec place
float Result=0;
int i,Frac=0;
int Mult=1,Len;
int DecPlaces=0;
char* pEnd=aStr;
char* pDec=NULL;
while (((*pEnd>='0') && (*pEnd<='9')) || (*pEnd=='.') ) {
// Find the end of the str
if (*pEnd=='.')
pDec=pEnd; // Remember decimal place
pEnd++;
}
Len=pEnd-aStr;
if (pDec)
DecPlaces=pEnd-pDec-1;
while (DecPlaces>1) {
// Limit to 1 dec place
pEnd--;
Len--;
DecPlaces--;
}
while (Len-->0) {
--pEnd;
if (DecPlaces>0) {
if (*pEnd!='.')
Frac=((*pEnd)-'0');
pEnd--; // Skip dot
DecPlaces--;
Len--;
}
else {
i=((*pEnd)-'0');
i*=Mult;
Result+=i;
Mult*=10;
}
}
if (Frac>0)
Result+=(float)Frac/10;
return(Result);
};
char* fnFltToStr(float aFlt, char* aStr) {
// Convert a float to a non terminated string. Return
// a pointer to the next char posistion that would have
// been written. Len of the string=cp-aStr. Limited to 1 dec
// place
int i=(int) aFlt; // Chop off fraction
float f=aFlt-i; // Fraction
char* cp;
cp=fnDebugDec(i,0,aStr); // int part
*cp++='.'; // decimal point
if ((f*=10)) {
if ((int) (f*10)>=5)
f+=.1;
}
i=(int)f;
cp=fnDebugDec(i,0,cp); // fractional part
return(cp);
}
Thanks,
John