LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bat file not running correctly from Labview.

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.

Download All
0 Kudos
Message 1 of 9
(3,770 Views)

What does "fails to run" mean?

Don't paths containing spaces need to be surrounded in double quotes?

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 9
(3,763 Views)

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).


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
0 Kudos
Message 3 of 9
(3,756 Views)

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.

0 Kudos
Message 4 of 9
(3,754 Views)

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.

0 Kudos
Message 5 of 9
(3,744 Views)

@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.


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
0 Kudos
Message 6 of 9
(3,734 Views)

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???

0 Kudos
Message 7 of 9
(3,705 Views)

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.

0 Kudos
Message 8 of 9
(3,699 Views)

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.

0 Kudos
Message 9 of 9
(3,688 Views)