From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Executing multiple command lines in command prompt (windows)

Solved!
Go to solution

Hi,

 

I am currrently using the command prompt in the windows to try to send a command to the microcontroller that is connected through TCP connection.

 

I am able to use the normal cmd.exe to send the command but am unable to send all the command successfully using labview. 

 

The Vi. that I am using the the system exec.vi found in labview connectivity section. 

 

Basically what I want to send is "telnet A1" in the cmd.exe to establish connection to the microcontroller, followed by "FOR A1 100 GO" which will be intepreted by the microcontroller to make the necessary motion. But currently, the problem is that I can only establish connection using the system exec.vi but am unable to send the second part of the message "FOR A1 100 GO". 

 

My command line i tried typing is cme.exe /K telnet A1 & FOR A1 100 GO. it seems that labview is only able to execute the first command part. Is there any other alternatives? 

 

Thanks everyone for your help. 

0 Kudos
Message 1 of 9
(4,623 Views)

Why not use the TCP VIs to communicate directly with the device? Its seems like an overly complicated method to use the systemexec call and a command line telnet.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 2 of 9
(4,619 Views)

Hi,

 

Yes, I have tried using TCP command, but the program is very unstable as sometimes I am unable to connect unless i restart my computer and network. It seems that somehow the port is used, but I can always access my microcontroller using the command prompt even when the error occurs. Do you happen to know what is the underlying problem? Thanks for your help.

 

Jh

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

Without seeing your code I would have no idea. Also, are you checking for errors and handling them?



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 4 of 9
(4,610 Views)

Hi,

 

Thanks for the help, the picture shows 1 of the error which state Error 56, the error occurs occasionally whenever I have used the command prompt to send a message to the microcontroller.

Alternatively, there are times when no errors occur but my microcontroller does not move as well. It does move if I were to send the command through the cmd prompt.

 

And I have attached a picture of my program as well. I am currently using Labview 2010 32bit. Thanks.

 

Jh

 

0 Kudos
Message 5 of 9
(4,593 Views)

I'd start by placing the Delay inside the Write-flat sequence. It's happened several times to me that a 50-100ms wait between write and reading the result solves the problem. Also run the code in Highlight mode, if it works then, it's definatly a timing issue.

 

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
Message 6 of 9
(4,578 Views)
Ok, thanks for your advice, will definitely try it when I get back to my laboratory this Monday, will update you if it is successful. Thanks everyone for your kind assistance.
0 Kudos
Message 7 of 9
(4,565 Views)
Solution
Accepted by topic author jhao

I suspect that there are timing issues with this code. Forst, you should cleanup it up as it is very difficult to follow. Wires are hidden under objects, the whole thing is much larger than a typical display, and the code is generally very disorganized. I would also suggest you look into using a state machine as well as an event structure to catch the UI events such as the start button.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 8 of 9
(4,549 Views)

Hi,

 

Thanks for everyone help, after cleaning out the code, i realise that it actually the command send to the microcontroller that is the problem, as it require me to key in the enter key. And it was only possible after cleaning up the whole program and trying to isolate each event to run separately. Thanks everyone for your advice and help. Smiley Happy

Message 9 of 9
(4,477 Views)