LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Wait for event on serial port

Hello.

 

I created a VI to check if my serial port is well configured,

the way I use to read the serial port in this VI is the one I use in my main program.

The problem is that the VI miss many events ( mouse event of another computer).

I do not understand the problem ...

I post my VI, I am aware that how I manages the appearance of the text is very bad but it works :).

 

Thanks

0 Kudos
Message 1 of 6
(2,837 Views)

Hi demum,

 

you miss events of another computer? How do you even plan to recognize them?

 

Hints:

- You can configure the VISA timeout at InitSerialPort, no need for an additional property node.

- While loops running just once with out any shift register are quite senseless.

- placing your event structure inside a while loop inside your big while loop seems "interesting", but still wrong to me...

Best regards,
GerdW


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

Hi GerdW

 

Thank for tips about time out, about the while loop, you're right i just delete it thanks(to much case structure today ><).

 

About the shift register :

The loop is here because i want the possibility to stop the timeout of visa , the only solution i found is to divide the timeout and to read the serial port in a loop. In my VI, every 50 ms (timeout) the serial port is read ,the loop run 100 time (if it dont find events ) this is the aim of the shift register . This is like a 5s timeout but with the possibility to stop it.

About the frame on com port :

I want to detect touchs on a touch screen. So, The touch screen is connected to a computer and i use a program which send a frame on serial port each time the mouse is moving. With a crossover cable, I'm reading the serial port on an another computer (the one which use the VI).
I just want to detect when there is a frame.

I hope this is not too incomprehensible.

Thanks
Demum

0 Kudos
Message 3 of 6
(2,823 Views)
You still have a couple of 1-iteration while loops to get rid of. Also, why are you reinitializing the com port and closing it on every iteration of the outer while loop? Those activities should only be done once. Initialize at the beginning of the program before the while loop, and close the port at the end after the while loop.
0 Kudos
Message 4 of 6
(2,814 Views)

Hi,

 

Why don't you use VISA Event VIs?

There is one event that could detect if a frame is sent to the serail port.

 

Sincerely

David S.| Certified LabVIEW Associate Developer
National Instruments France


0 Kudos
Message 5 of 6
(2,787 Views)

Hi,

 

@Raven: Thanks for your advices, I deleted some loop and I moved Serial open & Close out of the main loop.

@DavidS: I want the possibility to stop waiting whenever i want .

 

But finaly, it seem's that the probleme come from the program which send fram on serial port.

I works perfectly now..

 

Thanks for help everybody.

And sorry for an another usless post ... 🙂

0 Kudos
Message 6 of 6
(2,762 Views)