LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Secured file I/O

The machine code is done in LV2009 on a WIN_7 platform. Queued State Machine architecture inside 50ms timed loop. Launches into a Main and once user makes a selection, launches one amoung some 40 sub-VIs and the main FP is removed. All well . Code working.

 

But there has been a random code-crash or application-freezing issue, when a File I/O operation is on. Inside the code there are various occassions where I open a CSV file and append result data to it. Finally after the whole test is over, the complete CSV file is sent to a central server for saving. And most times its "Error 1" which says that some input parameter in file path is invalid and also displays the full file path - of course there is no error as i can see and defenitley no disallowed characters. And since the file name is programmatically done, the possibility of such rogue characters is not possible. So that Error-1 is actually a wrong message in itself.

 

What I would like to know is : Is there any way that a File I/O operation can be made robust ? One idea that occurs to me is an added verification to see if the file path meets stiuplated rules. Apart from this  are there any other methods ? And is it a good idea to keep writing data to HDD on the fly when the machine is going through its sequences ?- I have some CanOpen communications also in code.  Would it be better to store all the test values on to a array or cluster variable and after the test completion, dump the whole thing on to a CSV file in the HDD ??

Thanks 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 1 of 4
(2,446 Views)

Hi Raghunathan,

  Are you sure that your VI is crashing because of the same Error1 which is generated by a file/IO function?

 

Regards,

SrikrishnaNF

Regards,
Srikrishna


0 Kudos
Message 2 of 4
(2,438 Views)

I think I would recommend a top-level server /daemon / actor for your file I/O.  When you start your program, start up the server.  Communicate to / from it using queues.  The underlying code should be a queue-based task handler.  The server can open the file, write to the file, close the file, and copy the file to other locations.  Since all writing is done at a single location, you can buffer data for more efficient writing or flush every write for safety, at your option.  All operations on the file will occur in a single thread, even though the commands for the operations could come from multiple locations.  This should make the operation fairly robust.

 

Note that the actor framework (included in LabVIEW 2012) makes this kind of thing fairly easy but will incur an extra data copy over a custom solution.  In your case, this should not be an issue, since you seem to be dealing with fairly small data sets.

 

If you have further questions, let us know.  Post code if you can.

0 Kudos
Message 3 of 4
(2,419 Views)

A top level server / daemon / actor ? I guess I can follow your concept but have no clue on how to go about implementing a top level server. A simple example would help me get started . Thanks.

 

And you are right in saying that my data to be written is not much - some 150 numbers of double precision values plus a few string values.

 

Posting code - well in this case its too large a code to post. But I can explain the structure if that helps :

  • On launch, a Login screen appears.
  • Once Login is verified, it unloads and loads a MAIN.VI.
  • The MAIN.VI has a 50ms timed loop and acquires all field I/O constantly. This I/O image is stored in Functional Globals.
  • The MAIN.VI has many option buttons like EDIT, AUTO, SEMI-AUTO etc .
  • Assume the user chooses AUTO.  It immediatley results in removing the FP of MAIN.VI and loads the FP of AUTO.VI.
  • Now AUTO .VI is the actual machine sequence code starting point and has a user ENTRYFORM.VI for entering details about the device under test. The file saving process starts here and all device data are stored ( as binary) in a unique file [SlNo_DayDate_Time.xxx]
  • After this, ENTRYFORM.VI unloads and the SEQ_01.VI for the sequence 1 loads and starts executing. This  SEQ_01.VI gets all I/O inputs through FGs from MAIN which is constantly updating the image in background.  SEQ_01.VI is a Queued State Machine stucture.
  • After SEQ_01.VI completes, it appends all test data to the same file [SlNo_DayDate_Time.xxx],  unloads itself and loads SEQ_02.VI.
  • The same process repeats till the final SEQ_N.VI and at the end, the whole result file [SlNo_DayDate_Time.xxx]  is saved to the local PC as well as a central server.

So in the above  scenario how do I bring in  the top level daemon to streamline the HDD read / writes ??

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 4 of 4
(2,399 Views)