LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

i am reading from a file in 1 vi on 1 machine, and then writing

to the same file on another machine, However, there is the problem of the 2 vi's trying to access the same file? I believe i can use semaphores to doe this. I do not know much, besides a bit of the theory tehreof, Please advise how to go about this? Thanks
0 Kudos
Message 1 of 6
(2,855 Views)
to the same file on another machine, However, there is the problem of the 2 vi's trying to access the same file? I believe i can use semaphores to doe this. I do not know much, besides a bit of the theory tehreof, Please advise how to go about this? ThanksI don't think you can have problems if files are in different machines, because they are not the same file, but if you still want to know more about semaphores, just check for LV examples, there is at least one good example that shows how semaphores work.
Good luck
0 Kudos
Message 2 of 6
(2,855 Views)
to the same file on another machine, However, there is the problem of the 2 vi's trying to access the same file? I believe i can use semaphores to doe this. I do not know much, besides a bit of the theory tehreof, Please advise how to go about this? Thankshi
They are accessing the same file on a server.
0 Kudos
Message 3 of 6
(2,855 Views)
to the same file on another machine, However, there is the problem of the 2 vi's trying to access the same file? I believe i can use semaphores to doe this. I do not know much, besides a bit of the theory tehreof, Please advise how to go about this? ThanksMatrix,

there are no problems accessing a file if you have only one Writer and some Readers. Each one opens the file and then performs the proper operations on it.

Regards.

Linus
0 Kudos
Message 4 of 6
(2,855 Views)
to the same file on another machine, However, there is the problem of the 2 vi's trying to access the same file? I believe i can use semaphores to doe this. I do not know much, besides a bit of the theory tehreof, Please advise how to go about this? ThanksI assume the file is on a shared network volume, otherwise it wouldn't be an issue, because it's not really the same file.

The semaphore you want is already built into the file system. When you create the file, or open it for writing, you have the option of specifying the OPEN MODE and the DENY MODE. The OPEN MODE determines how THIS FUNCTION will access the file, the DENY MODE determines how ANOTHER PROCESS will be allowed to access the same file during this operation.

Depending on what you want to do, you could write to it from VI #1 using WRITE ONLY and DENY READ AND WRITE.

VI #1 has to check errors when opening the file, because it won't necessarily be available.

Then VI #2 would open it using READ ONLY and DENY READ AND WRITE, and check
errors, because it won't necessarily be readable.

If a permissions error occurs on either VI #1 or #2, wait a while and try again, or noify the user, whatever. But you MUST check errors.

This gives exclusive access to one VI or the other.

If you need to, you can relax the DENY parameter and have simultaneous access. Read the HELP for the OPEN FILE function.

PAY ATTENTION TO ERROR RESULTS from the file functions. Don't assume there will be no errors just because 99.9999% of the time there aren't any.

Make your operations as quick as possible, to reduce the chances of a collision.
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 5 of 6
(2,855 Views)
to the same file on another machine, However, there is the problem of the 2 vi's trying to access the same file? I believe i can use semaphores to doe this. I do not know much, besides a bit of the theory tehreof, Please advise how to go about this? ThanksHA! I just realized that this question is OVER TWO YEARS OLD!.

Dunno why the system floated it to the top of my basket...
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 6 of 6
(2,855 Views)