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: 

Stoping VI inbetween when program seeking data from serial port.

I have an application in which I need to read data from two serial port one after other.

 

One read will read 14 byte and other 08 bytes(Just info).

 

Now in between if user need to stop the VI then how to stop it?

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 1 of 8
(2,484 Views)

Hi Ranjeet,

 

check your stop condition and stop your VI. Check it twice (or more often) when you need to.

 

You should obey DATAFLOW in doing so…

Best regards,
GerdW


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

A state machine could do this easily.  Just have a state to check for the stop (or any other events).


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 8
(2,446 Views)

Here is my VI

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 4 of 8
(2,423 Views)

What modification I need?

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 5 of 8
(2,414 Views)

Hi Ranjeet,

 


What modification I need?


 

At first you should consider using the auto-cleanup tool before posting your VIs…

Next you should remove the local variables and use wires instead! THINK DATAFLOW!

 

Then you should not use a timeout of 200s for your serial port communication. As you can't break a VISARead function while it waits for some data on the port you really should use a different scheme for reading the ports!

 

As said before: use a state machine. You can stop the state machine after each state…

Best regards,
GerdW


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

Thanks, next time I will keep this in mind(I wasnt aware of it ).

 

Ok will use wire


@GerdW wrote:

 

Then you should not use a timeout of 200s for your serial port communication. As you can't break a VISARead function while it waits for some data on the port you really should use a different scheme for reading the ports!

 


As you suggested, small timeout will work here? I think that is good idea. Ok l will try to use state machine. As I told in my question that I have two read, will I need to make same timeout?

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 7 of 8
(2,389 Views)

Hi Ranjeet,

 

smaller timeouts should work too (default is 10s). The timeout value depends on the responsiveness of your devices. When you do some real error handling you might filter TimedOut-errors…

 

- You don't need to set the same timeout value for both ports, each is handled on its own.

Best regards,
GerdW


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