BrokenArrow Posted June 20, 2007 Report Share Posted June 20, 2007 Scenario of a given program I'm debugging: There's a file called Howdy.txt. It either has 7 characters in it or nothing. Parallel loops... Loop 1 writes to Howdy.txt file every 2 minutes to 30 minutes. Loop 2 opens up Howdy.txt every 1000mS and looks at it - to see if it's been written to. This happens all the time, 24/7. With this scenario, it appears there's a small chance the file can be open at the same time in two places. Is this common? Can it cause problems? The VI's are Write Characters To Fle and Read Characters From File. Thanks! Richard Quote Link to comment
Grampa_of_Oliva_n_Eden Posted June 20, 2007 Report Share Posted June 20, 2007 QUOTE(BrokenArrow @ Jun 19 2007, 09:03 AM) Scenario of a given program I'm debugging:There's a file called Howdy.txt. It either has 7 characters in it or nothing. Parallel loops... Loop 1 writes to Howdy.txt file every 2 minutes to 30 minutes. Loop 2 opens up Howdy.txt every 1000mS and looks at it - to see if it's been written to. This happens all the time, 24/7. With this scenario, it appears there's a small chance the file can be open at the same time in two places. Is this common? Can it cause problems? The VI's are Write Characters To Fle and Read Characters From File. Thanks! Richard Provided they both use seperate "opens" and file ref's AND ther is only one writter*, you should be OK. The file system (as realized throught the LV API's) track the file pointer seperately for each ref. * There was a bug in LV 7.X where LV could mix up the file ref nums (which is a big problem if the two files are data log files of different types! You do not want to try and untagle one of these.) Ben Quote Link to comment
Ton Plomp Posted June 20, 2007 Report Share Posted June 20, 2007 QUOTE(BrokenArrow @ Jun 19 2007, 03:03 PM) Scenario of a given program I'm debugging:There's a file called Howdy.txt. It either has 7 characters in it or nothing. A better solution is the fileinfo primitive: http://zone.ni.com/reference/en-XX/help/371361B-01/glang/file_directory_info/' target="_blank">Link If I were you I'd use a messaging system, but since you are debugging most likely you inherited the code :headbang: Ton Quote Link to comment
BrokenArrow Posted June 21, 2007 Author Report Share Posted June 21, 2007 QUOTE(Ben @ Jun 19 2007, 09:09 AM) Provided they both use seperate "opens" and file ref's AND ther is only one writter*, you should be OK.... Ben, By "use seperate "opens"" do you mean are the VI's different that do the opening? There's definately one write. QUOTE(tcplomp @ Jun 19 2007, 09:14 AM) A better solution is the fileinfo primitive: Link If I were you I'd use a messaging system, but since you are debugging most likely you inherited the code :headbang: Ton That's a great idea Ton. That way, it's not opening and closing the file just to see if it has changed. Or, if it does open it, at least it's a different open as Ben recommended. -Richard ----------------------------- p.s. Is writing to a file a common way to share a variable? (keep in mind this is 5.1) Quote Link to comment
Ton Plomp Posted June 21, 2007 Report Share Posted June 21, 2007 QUOTE(BrokenArrow @ Jun 20 2007, 03:15 AM) p.s. Is writing to a file a common way to share a variable? (keep in mind this is 5.1) No, a [wiki]functional_global_variable[/wiki] would be better. A simple bit register (keep high) is this: http://forums.lavag.org/index.php?act=attach&type=post&id=6170''>http://forums.lavag.org/index.php?act=attach&type=post&id=6170'>http://forums.lavag.org/index.php?act=attach&type=post&id=6170 Ton Quote Link to comment
Wolfram Posted June 21, 2007 Report Share Posted June 21, 2007 ZITAT(BrokenArrow @ Jun 19 2007, 03:03 PM) Parallel loops...Loop 1 writes to Howdy.txt file every 2 minutes to 30 minutes. Loop 2 opens up Howdy.txt every 1000mS and looks at it - to see if it's been written to. This happens all the time, 24/7. With this scenario, it appears there's a small chance the file can be open at the same time in two places. Is this common? Can it cause problems? The VI's are Write Characters To Fle and Read Characters From File. You can do this when you open the file in loop 2 only as "read only". Then it should work. Wolfram Quote Link to comment
BrokenArrow Posted June 21, 2007 Author Report Share Posted June 21, 2007 QUOTE(tcplomp @ Jun 20 2007, 01:53 AM) a [wiki]functional_global_variable[/wiki] would be better. Ton, I love LV2G's, thanks for the idea. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.