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.

How to clear CR100 memory of CC5MPX image files


TaCaPica Oct 21, 2014 11:00 AM

Hi

I have a system that uses the CC5MPX internal clock to take picture, that i delete every time i link my station to loggernet. Everything is fine till here, but when i don't have communications during a period of time (2h is suficiente) the loggers internal memory becomes full and i can take any more pictures and thats a big problem for me.

My ideia is if i dont have a communication in the period of an hour, delete the oldest picture taken, and do a 15min check and so on. My problem is how to do this. Can anyone help me. Is there any command that i can use to clean a specific file from memory?

Best regards

JP Rodrigues


aps Oct 21, 2014 11:14 AM

The Filemanage command allows you to delete files.


TaCaPica Oct 21, 2014 11:47 AM

Thanks APS

I will try it!

Best regards


TaCaPica Oct 21, 2014 01:36 PM

Hi again APS

I tryed to delete some files in a lab test with a datalogger that i have here with me. It didnt erase the files i wanted even when i gave it the specific name of the file (that will be a problem, bacause i want to delete a certain kind of files -JPEG- with diferente name every single time it gets a picture)

I will post the code for a look from you.

Best regards

'Variaveis

Public PTemp, batt_volt
Public relogio(9)
Public NumFicheiros, FileListDest(12) As String * 50
Public test

'Programa
BeginProg
SequentialMode


Scan (5,Sec,0,0)
RealTime(relogio())

PanelTemp (PTemp,250)

Battery (batt_volt)


' If relogio(5) = 10 OR relogio(5) = 25 OR relogio(5) = 40 OR relogio(5) = 55 AND relogio(6) <15 Then
NumFicheiros=FileList ("CPU",FileListDest())
If NumFicheiros>3 Then
FileManage ("CPU:"+"FileListdest(1)",8)
FileManage ("CPU:*.jpeg",8)
test=23
EndIf
'EndIf

NextScan
EndProg

* Last updated by: TaCaPica on 10/21/2014 @ 7:38 AM *


aps Oct 22, 2014 02:42 PM

Your program has an error. Filelist returns the filename including the drive name already appended to it. So the first filemanage command should just be:

FileManage (FileListDest(1),8)


Sam Nov 10, 2014 02:02 AM

TaCaPica,

Please do not store images to the CPU drive.
CPU is flash and writing those images files to the CPU drive frequently will ultimately lead to a flash memory failure, the time to which will be dependent on the frequency at which you are acquiring and storing those images.

Please put the images onto USR (or CRD or USB).

To create a USR drive use DevConfig to set USR Drive Size (Advanced tab) to a size that is large enough to hold your pictures + extra (say multiple extra images). Alternatively you can set the USR drive programmatically using SetStatus("USRDriveFree",xxxx) where xxxx is the number of bytes.

You also could just configure the datalogger to manage the files for you using the "Files Manager" setting, again on the Advanced tab in DevConfig. For example,

PakBus Address = PakBus Address of CC5MPX
Files Manger File Name = myImage.jpg
Count = 3


Below is a function I wrote for another project for keeping only X number of newest files. You could try it out if you want to handle all of this in code.


Const RotateFileMaxNumFile = 50
Sub RotateFile(FilePrefix As String * 32, NumKeep As Long)

Dim FNames(RotateFileMaxNumFile) As String * 48, Matches As Long
Dim FNum As Long, FTime As Long, FName As String * 48, I As Long
Dim OldestTime As Long, OldestFile As String * 48

Do
Move (FNames,RotateFileMaxNumFile,"",1) 'init list
FNum = FileList (Left (FilePrefix,3),FNames) 'get list

Matches = 0 'init
OldestTime = &h7FFFFFFF 'init as big as possible
OldestFile = "" 'init
For I = 1 To FNum 'for all files
FName = FNames(I) 'pull out working name
If InStr (1,FName,FilePrefix,2) = 1 Then
Matches += 1 'found a match
FTime = FileTime (FName) 'get timestamp
If FTime < OldestTime Then
'oldest matching file so far
OldestTime = FTime
OldestFile = FName
EndIf
EndIf
Next I

If Matches > NumKeep Then
'too many files, delete the oldest one found
FileManage (OldestFile,8)
EndIf

Loop While ((Matches-1) > NumKeep) 'do again if needed

EndSub


BeginProg
Scan (1,Sec,0,0)

'call sub routine
'only keep 3 files that start with "USR:myImage"
Call RotateFile("USR:myImage", 3)

NextScan
EndProg

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