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

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?

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

1 Like

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

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
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,β€œ,
β€œ,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,"
}
}β€œ,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[i]) fat_UnmountDevice(fat_part_mounted[i]->dev);
}

Hello, There is a sample application FTP_FAT.C provided by Digi under C:\DCRABBIT_10.72\Samples cpip\ftp

Test the RCM4300 with this sample app.

1 Like