04-21-2015 08:47 AM
Hi Folks.
I am trying to program a Nordic Semiconductor device from within Labview. I am using a bat file (text version attached) to implement this. When I run the bat file directly it works fine every time. But when I try and do it through Labview more often than not if fails to run. I am using system Exec.VI but it seems to be very unreliable or do I have it set up wrong. Anyone got any ideas on how to solve this?
Thanks,
Mark.
04-21-2015 08:55 AM
What does "fails to run" mean?
Don't paths containing spaces need to be surrounded in double quotes?
Mike...
04-21-2015 09:01 AM
About the only thing I see with the system exec calls is you may want to set the running directory to be the folder that has the bat file in it.
Now for your serial communications...Do NOT use the Bytes At Port. You are just opening yourself up to some reallly interesting race conditions. Since the termination character is turned on, just tell the VISA Read to read more bytes than you would ever expect from the instrument. The VISA Read will stop the read when it finds the termination character (which is currently set to a Line Feed, 0xA).
04-21-2015 09:03 AM
By fails to run I mean that it will not program the device. When I run the bat file directly it works fine so the problem is deffinately within Labview and how it is running the bat file. Is there a specific way to run the bat file that I am doing wrong?
Mark.
04-21-2015 09:13 AM - edited 04-21-2015 09:14 AM
And where exactly are your hex files located? In the directory with your bat file? Then it would be a smart idea to follow the earlier advice to set the working directory to whatever directory you expect the external command to consider its current path. Otherwise it will inherit whatever is the current path of LabVIEW at that moment, which happens to be the directory in which LabVIEW.exe is located at startup and whatever path you last happened to be in when using a file dialog box in LabVIEW, because that is how Windows file dialogs work.
04-21-2015 09:16 AM
@R.Peters wrote:
And where exactly are your hex files located? In the directory with your bat file? Then it would be a smart idea to follow the earlier advice to set the working directory to whatever directory you expect the external command to consider its current path. Otherwise it will inherit whatever is the current path of LabVIEW at that moment, which happens to be the directory in which LabVIEW.exe is located at startup and whatever path you last happened to be in when using a file dialog box in LabVIEW, because that is how Windows file dialogs work.
If you look at the code, the OP is actually setting the working directory to "C:\". Actually, this makes a lot more sense. A bat file, when run in Windows, sets the running directory to its current location. Do the same in LabVIEW.
04-21-2015 10:54 AM
I did change the directory and it is working better now. However when I run the installed version on a different machine it is a bit tempormental. Any one know why this may be???
04-21-2015 11:08 AM
Define tempormental. Describe what you mean. Describe what you see. Describe what it does. When building an EXE functions like "Current VI Path" may act different because of where the file is on disk. If you are having paths be referenced to this function you might be getting the wrong path and it would never work. I wouldn't call that tempormental, but it is a common problem.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
04-21-2015 11:49 AM
I will review all the paths from my pc to the target pc and make sure they match. What I meant by tempormental was that it dosn't always program from the labview program, but does always pregram directly from the bat file. Everything from the bat file onwards is fine, the trouble comes from the calling of the bat file and associated files.