Hi everyone,
I'm trying to open a file in the httpserver example,
as in the topic

I'm having trouble to open file in read mode.
I wrote a function that try to open a file, but if the file doesn't exists it will be created.
Unfortunately, if I call the function after netappstart then the program crash and the console give me:
ti.sysbios.knl.Task: line 370: E_stackOverflow: Task 0x200231c8 stack overflow.
xdc.runtime.Error.raise: terminating execution
My function is:
int file_handler(unsigned long *ulToken, long *lFileHandle){
long lRetVal = -1;
int loopcount=0;
int controllo=0;
unsigned char gaucOldMacDonald[]="100";
unsigned char gaucOldMacDonald2[]="100";
char subbuff[5]; //vale per pushlight, dimdom, heatdom, pushutter per lo stato
char subbuff2[5];
int stato_lampada;
unsigned char gaucCmpBuf[BUF_SIZE];
unsigned char gaucCmpBuf2[BUF_SIZE];
bzero(gaucCmpBuf,BUF_SIZE);
UART_PRINT("I try\n\r");
lRetVal = sl_FsOpen((unsigned char *)USER_FILE_NAME,
FS_MODE_OPEN_READ,
ulToken,
lFileHandle);
UART_PRINT("Here\n\r");
if(lRetVal<0){
UART_PRINT("Il file doesn't exists\n\r");
lRetVal = sl_FsOpen((unsigned char *)USER_FILE_NAME,
FS_MODE_OPEN_CREATE(65536,
_FS_FILE_OPEN_FLAG_COMMIT|_FS_FILE_PUBLIC_WRITE),
ulToken,
lFileHandle);
controllo=1;
UART_PRINT("FILE_CREATED\n\r");
}else{
UART_PRINT("File esistente\n\r");
//il file esiste già
lRetVal = sl_FsRead(*lFileHandle,
(unsigned int)(loopcount * sizeof(gaucOldMacDonald)),
gaucCmpBuf, sizeof(gaucOldMacDonald));
controllo=0;
}
lRetVal=sl_FsClose(*lFileHandle,0,0,0);
if(controllo==0){
memcpy(subbuff, &gaucCmpBuf[0],1);
subbuff[1]='\0';
duty_cycle=atoi(subbuff);
}
bzero(gaucCmpBuf2,BUF_SIZE);
lRetVal = sl_FsOpen((unsigned char *)USER_FILE_NAME2,
FS_MODE_OPEN_READ,
ulToken,
lFileHandle);
return 0;
}