LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Generating event at availability of data at ethernet port

Can labVIEW detect/ generate an event as soon as the data is available at ethernet port? My idea is to use then a event structure to perform desired action.....

Is this possible? Can any one guide how to proceed on this? Sample code can be of great help!

 

Thanks in advance!

0 Kudos
Message 1 of 12
(3,770 Views)

Hi there

 

try the functions in

 

Instrument I/O -> VISA -> VISA Advanced -> Event Handling

 

Don't know if that works for TCP/IP, but it's worth a try

 

 

 

 

 

Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
Message 2 of 12
(3,767 Views)

You're probably thinking of the VISA Enable Event and VISA Wait on Event. Unfortunately, those won't work since they're designed for use with GPIB, serial, and VXI.

 

To poster: One simple solution is to have a loop that simply calls TCP Read and if there's data you simply generate a user event for your event structure. I would suggest looking up user events. There's an example that ships with LabVIEW.

 

Other than that you could delve into the API appropriate for whatever operating system you're using and hook into it to have it call a LabVIEW VI as a callback. I would try the previous suggestion first, though.  

Message 3 of 12
(3,761 Views)

smercurio_fc,

I think you want me to poll the ethernet port using TCP read and then generate user event, but I don't want to do this polling thing. Since data that may arrive at port at irregular intervals and less frequent (30 sec, 1 min. 5min.). So polling port at let's say at 1 sec. shall unnecessary west my processor time. So I want to write program using direct events from ethernet port.

 

Any suggession on this??

 

Thanks! 

0 Kudos
Message 4 of 12
(3,734 Views)

Hi there

 

VISA also works with TCP (see attachment), but the VISA events don't ......

 

TCP Read uses a TimeOut parameter, so "polling" dosn't mean to waste huge amounts of resources. The TCP Read function returns only when a time out or data arrived. You can catch the time out case and fire the user event after data arrived.

Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
Message 5 of 12
(3,723 Views)

Hi Chris,

I think you forgot to attach the attachment!

0 Kudos
Message 6 of 12
(3,719 Views)

 

Yes, you're right. Use the

 

 Examples -> Networking -> TCP & UDP -> Data Server.vi

 

to write to Port 6340 on localhost.

 

 

Message Edited by chrisger on 08-29-2008 05:29 AM
Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
Download All
Message 7 of 12
(3,716 Views)

ITA wrote:

smercurio_fc,

I think you want me to poll the ethernet port using TCP read and then generate user event, but I don't want to do this polling thing. Since data that may arrive at port at irregular intervals and less frequent (30 sec, 1 min. 5min.). So polling port at let's say at 1 sec. shall unnecessary west my processor time. So I want to write program using direct events from ethernet port.


Have you actually tried this? You'll find that it's not "wasting" a whole lot of resources. If you create a VI that's just a loop with a 1 second delay and a TCP Read you'll find that it barely registers on the CPU graph, if at all.

 


chrisger wrote:
TCP Read uses a TimeOut parameter, so "polling" dosn't mean to waste huge amounts of resources.

See my response. 

 

That said, if you do not like the polling mechanism, then as I said, you need to look into using whatever API is available for your operating system and hook into the callbacks, if any, that are available for the TCP/IP stack.

0 Kudos
Message 8 of 12
(3,696 Views)

Polling is not necessary.

 

Wire a -1 into the timeout for the tcp read and it will block. Then fire your event when you get data. To terminate the TCP Read loop simply close its connection and the TCP Read will error out.

 

Example Diagram 

 

 

Message Edited by NathanK on 08-29-2008 11:02 AM
Message 9 of 12
(3,688 Views)

Thanks to all of you.

 

Nathank, I have observed:

If I wire -1 to time out of tcp read, then it waits for NUMBER OF BYTES TO READ (512/ 1024 etc.) specified to tcp read function. (Have tried with keeping no. of bytes to read terminal unwired, changing the modes of tcp read like CRLF, STANDARD, BUFFERED etc......)

 

In my application I am not sure, how much bytes of data shall appear at what frequency to tcp port......Smiley Sad

 

Any suggessions??

0 Kudos
Message 10 of 12
(3,621 Views)