LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Delete files from specific path (cRIO 9076)

Solved!
Go to solution

Hello everyone

 

I have an application that measures Tension, THD, currents, etc... This application is running under a cRIO 9076 and is placed in site, accessible via ip with RT Application running.

The information that is measured is written in a spreadsheet and is accessible via ftp in some excel spreadsheets created every day at 00:00. The problem is after some days the memory is full and no more space is allowed to create a new spreadsheet, so the cRIO is only monitoring in real time and doesn't save the reports.

I'm working in a solution to delete the oldest files. This solution work well in my PC, but when i put into cRIO the files are not deleted and gives error 43.

I send an image attached to see my code.

 

Any suggestion would be great. 

Download All
0 Kudos
Message 1 of 9
(2,160 Views)

Hi marcofs,

 


@marcofs wrote:

I'm working in a solution to delete the oldest files. This solution work well in my PC, but when i put into cRIO the files are not deleted and gives error 43.


When those files are located on the harddrive of your PC then your cRIO will not be able to delete them!

PC and cRIO are both computers on their own: you don't want other computers being able to delete files on your own computer…

 


@marcofs wrote:

The information that is measured is written in a spreadsheet and is accessible via ftp in some excel spreadsheets created every day at 00:00.

Any suggestion would be great. 


When you have access to those files using FTP functions then you need to use even more FTP functions to delete from your file server…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 9
(2,156 Views)

Hi GerdW

 

Thanks by your reply.

 

Maybe i don't express the problem as it was.

 

I don't want cRIO to delete files from my PC, i want to delete files from c:\Events located in the hard drive of cRIO.

 

I've been tested the code in my PC and works well, but when i put into the cRIO code it doesn't work and return error 43. As i have searched maybe i don't have permission in cRIO to delete files, but if i can create a file, why i can't delete the older file?

0 Kudos
Message 3 of 9
(2,151 Views)
Solution
Accepted by topic author marcofs

When dealing with paths, you really should avoid string operations.  The actual file name is fine to build with a string, but changing the path to a string, concatinate, and then convert back is not recommended.  I am mostly worried about the '\' you are adding into the path name.  You should create the file name and then use Build Path.

 

I am concerned that you are getting error code 43.  That error code is for "Operation Canceled".  This tells me you are passing in an invalid path, making the function want to pop up a dialog, which cannot be done in RT (no UI).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 9
(2,141 Views)

Your cRIO 9076 runs VxWorks as operating system. That operating system does NOT use backslashes as file level separator but forward slashes like Unix systems. Your main problem starts at how you construct the file name for your data file.

 

You convert the start path to a string and then do path manipulations using the Windows path syntax on the string. That is totally wrong as crossrulz already explained.

 

And you may now say that the path constants also show the Windows path syntax. Yes that is right because the diagram is shown on your Windows computer and LabVIEW uses the syntax of the platform it is showing a diagram on to render the path, but it doesn't store it in that format internally but in a platform independent format that is automatically interpreted correctly on the target platform according to its own path syntax.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 5 of 9
(2,135 Views)

Thanks for your help.

 

I solved the case with the solution in attached image.

0 Kudos
Message 6 of 9
(2,090 Views)

While what crossrulz and Rolf wrote about a file-path on VxWorks is true this does not explain your error 43 (if error 43 happens on your delete loop as shown in your picture).

That loop starts with a file path constant "C:\events", which is totally valid even on VxWorks since it is a file path constant. LabVIEW will handle the correct conversion from backslash to forwardslash.

 

You also should be able to delete files in general - I have done so myself and it is definitely possible.

 

I think your error cause is that you try to delete all files that have been created at least one hour ago - so still form the same day. Pehaps you are still accessing files from the same day somewhere else in your program code. I suggest to only delete files that are older that 24 h or even 48 hours (i.e. your date comparision should be at least > 86400 and not 3600).

 

Another improvement might be to delete files that you have downloaded by ftp directly via ftp after the download.

 

Regards, Jens

 

EDIT: oh - 5 minutes too late with my answer 😉...

Kudos are welcome...
Message 7 of 9
(2,086 Views)

Instead of using the "Confirm" input, I would use a Case Structure.  It makes it a little more obvious what is happening as well as not relying on an error situation.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 8 of 9
(2,081 Views)

I have improved the code and now i have a more decent proccess but a little bit more slow than the other one.

 

I think that the problem is the popup to confirm the file to delete.

 

I put in the attachment the cut of the code with the more recent improvments. Now i'm searching for a way to download directly the files from cRIO to PC and erase them after.

 

Thanks to all.

0 Kudos
Message 9 of 9
(1,999 Views)