Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Reading data from memory card using CRBasic


mschlumpf Jun 27, 2019 05:32 PM

Hi,

We use a variety of CR5000 and CR3000 loggers to capture 10Hz eddy covariance data. Each one is set up with a CF memory card. The program also stores data to the card at 10Hz using the TableFile command. Each day a new file is created and every month we swap out the memory card.

I would like to incorporate some code that reads the timestamp of the most recent entry stored on the card (not the CPU table) at a given interval. I would like to contrast that timestamp with current time and set a flag if the difference is greater than a day (indicating the logger has not written to the card in more than a day).

Is this possible? I seem to be only able to find ways to access cpu memory through crbasic.

Mikael


JDavis Jun 27, 2019 09:56 PM

I suggest reading Status.CardStatus instead. It will be much simpler that using file commands to read timestamps out of files. Table 112 in the CR3000 manual shows the possible values. The pdf of the current manual shows it on page 449. You expect the status to contain "Card OK".

You can also check Status.CardBytesFree. It should be >0.

If your program contains TableFile(), CardStatus is "Card OK", and CardBytesFree is >0, the datalogger is writing data to the card.

You can use the last file name returned by TableFile() along with the FileTime() instruction to see when the most recent data file was started. The modified time of the file will be set when it is created, and not be updating.


mschlumpf Jun 27, 2019 11:22 PM

We wanted to figure out an alternate method because this has apparently happened even when CardStatus is ok. Also, for some reason the card bytes free variable in the status table seems to be often inaccurate, especially with older cr5000's. 

I was trying to work with FileTime(), but creating the file handle using FileOpen didn't seem to work. Doesn't seem to want to accept "CRD:" as a device type. Also, how do you get the last name returned by TableFile()? I didn't think Table file returned anything? Could you show some excample code for both of these by any chance?

Thanks,

Mikael

Log in or register to post/reply in the forum.