LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Command Prompt did not receive commands from LabVIEW Sometimes

Hi all,

 

I am sending commands from LabVIEW to cmd to quiry for USB device location (i.e. Port_xxx.Hub_xxx). The main VI is Launch and Monitor Command2.vi.

 

I found a code from this forum and modify it to the application i need.

This code sending windows command to powershell in cmd to obtain the device instance path, and use the instance path to enquire the usb location.

 

However, i found the code sometimes doesn't work properly.

Let's say when i run for the first time, i get what i need but when i run the VI for the second time, what i have sent to cmd doesn't appear on cmd windows. Instead, the cmd windows is like keep flashing abnormally.

If the VI runs properly everytime when i hightlight execution for the subVI Paste Command into Command Window.In this case user should be able to see the USB device location at the output Array.

 

I have attached the VI here. Can anyone advise on this?

 

0 Kudos
Message 1 of 5
(2,275 Views)

Hi 123,

 

are trying to use the clipboard for data exchange between LabVIEW and a PowerShell window? I don't think this will work reliably…

 

Why don't you call the PowerShell again with your new command?

Why don't you use the network (localhost) for reliable communication between different processes?

Why don't you even have PowerShell store it's result into a file you can easily read with LabVIEW?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(2,253 Views)

Hi GerdW,

 

Why don't you call the PowerShell again with your new command?

I cannot call powershell again for every new command. That is because the cmd will become unstable and i can't see the commands sent from LabVIEW appear on the cmd windows.

Why don't you use the network (localhost) for reliable communication between different processes?

Can you provide some sample VI that using this method? I am sorry as i am not familiar with that. But i would like to try.

Why don't you even have PowerShell store it's result into a file you can easily read with LabVIEW?

Because i did not know other method. Can you show me how to do that?

 

Best regards,

Crystal

0 Kudos
Message 3 of 5
(2,214 Views)

In general, if you want to perform several commands with cmd or powershell i'd suggest making a .bat or .ps1 file and call that. That can be done programmatically if need be. As to writing a file, you need to pipe the result to out-file.

From the link below

Get-Process | Out-File -FilePath .\Process.txt

 

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/out-file?view=powers...

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 5
(2,164 Views)

Hi Yamaeda,

 

I have been using a batch file. But the commands sent doesn't appeared on the cmd windows.

Sometimes it works but sometimes not.

Anyway i have solved my problem by adding a delay in the Paste Command into Command Window.vi.

 

Best regards,

Crystal

0 Kudos
Message 5 of 5
(2,128 Views)