Home/Support/Support Forum/Why my files are empty every time I restast the RCM4300???
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

Why my files are empty every time I restast the RCM4300???

0 votes
Dear all,

My application is running on a RCM4300. The program is intended to acquire data and store them in the on-board SD Card, additionally there's an FTP Server in charge to provide access to the stored data. The FTP Server is running as a Costate.

In principle it works fine. The problem is that after restarting the module the data in the files desappear. The files are there but not the data.

Any ideas?
asked Apr 26, 2016 in Rabbit by Andreu New to the Community (2 points)

Please log in or register to answer this question.

4 Answers

+1 vote
Do you have a battery connected for the RTC and SRAM? The FAT file system needs a block of battery backed RAM to work correctly over power cycles.

Regards,
Peter
answered Apr 26, 2016 by petermcs Veteran of the Digi Community (1,128 points)
+1 vote
Hello, There is a sample application FTP_FAT.C provided by Digi under C:\DCRABBIT_10.72\Samples\tcpip\ftp

Test the RCM4300 with this sample app.
answered May 5, 2016 by cpigilam Veteran of the Digi Community (655 points)
0 votes
Yes I have a battery, but I didn't know such effect. I will check the voltage through the power up cycle.

The other possibility I'm thinking of is related to some sort of uncompatibility between the FAT_file and the SSPEC library functions. If the battery back up works fine I will be back with a more detailed Explanation on the Problem.

Thanks for the help
Andreu
answered Apr 27, 2016 by Andreu New to the Community (2 points)
0 votes
I already checked the back up battery. It Looks to be Ok. However, is a Kind of noisy. It shows spykes of about 1 Vpp. I will Change the battery anyway.

Here a little piece of my code. Please let me know if you see anything weird:


in my custom json library:

/* START FUNCTION DESCRIPTION *****************
json_addValueNumber <json.LIB>
SYNTAX: int json_addValueNumber(FATfile *file, void *value, int type, const far char *after)

KEYWORDS: json

DESCRIPTION: function to write numerical values into a json formatted file.

END DESCRIPTION ********************************************/
int json_addValueNumber(FATfile *file, void *value, int type, const far char *after)
{
auto int rc=0;
switch(type)
{
case UCHR:
sprintf(buf, "%c\0",*(unsigned char*)value);
break;
case UINT:
sprintf(buf, "%u\0",*(unsigned int*)value);
break;
case INT:
sprintf(buf, "%d\0",*(int*)value);
break;
case USINT:
sprintf(buf, "%u\0",*(unsigned short*) value);
break;
case FLOAT:
sprintf(buf, "%.2f\0",*(float*)value);
break;
default:
break;
}
if(after!=NULL) f_strcat(buf, after);
rc=fat_xWrite(file, (long)buf, strlen(buf));
return rc;
}


in the main program:

// Mount SD card

fCheckError(sspec_automount(SSPEC_MOUNT_ANY, NULL, NULL, NULL),FailedFunct017,"!=",0);

while(1)
{
loophead();
costate 1 //...
costate 2 //...
costate // data logging
{
waitfor(DelaySec(DataReg_T));
if (Exp_running == 1)
{
sprintf(s,DataTmp);
fCheckError(fat_Open(fat_part_mounted[0],s,FAT_FILE,FAT_OPEN,&DataTemp_file,&prealloc),FailedFunct041,"!=",0);
fat_Seek(&DataTemp_file, -6, SEEK_END);
fCheckError(fat_Write(&DataTemp_file,",\r\n",3),FailedFunct032,"!=",3);
sprintf(s,"#%d\0",meascount);
json_addName(&DataTemp_file,NULL,s,"[");
json_addValueNumber(&DataTemp_file,(unsigned int*)&Stirring,FLOAT,",");
json_addValueNumber(&DataTemp_file,(unsigned int*)&InternalTemp,FLOAT,",");
json_addValueNumber(&DataTemp_file,(unsigned int*)&FeedTemp,FLOAT,",");
json_addValueNumber(&DataTemp_file,(unsigned int*)&HumidifierTemp,FLOAT,",");
json_addValueNumber(&DataTemp_file,(unsigned int*)&MBRTemp,FLOAT,",");
json_addValueNumber(&DataTemp_file,(unsigned int*)&DO,FLOAT,",");
json_addValueNumber(&DataTemp_file,(unsigned int*)&pHbis,FLOAT,",");
json_addValueNumber(&DataTemp_file,(unsigned int*)&P1,FLOAT,",");
json_addValueNumber(&DataTemp_file,(unsigned int*)&P2,FLOAT,",");
json_addValueNumber(&DataTemp_file,(unsigned int*)&P3,FLOAT,",");
json_addValueNumber(&DataTemp_file,(unsigned int*)&Flow1,FLOAT,",");
json_addValueNumber(&DataTemp_file,(unsigned int*)&Flow2,FLOAT,",");
json_addValueNumber(&DataTemp_file,(unsigned int*)&Flow3,FLOAT,",");
json_addValueNumber(&DataTemp_file,(unsigned int*)&ElapsedTime,FLOAT,"]");
fCheckError(fat_Write(&DataTemp_file,"\r\n}\r\n}",6),FailedFunct032,"!=",6);
fCheckError(fat_Close(&DataTemp_file),FailedFunct042,"!=",0);
meascount++;
}
}
}




Somewhere else before powering down:



// Unmount all of the mounted FAT partitions & devices before exit
for (i = 0; i < num_fat_devices * FAT_MAX_PARTITIONS;i += FAT_MAX_PARTITIONS)
{
if (fat_part_mounted) fat_UnmountDevice(fat_part_mounted->dev);
}
answered Apr 27, 2016 by Andreu New to the Community (2 points)
...