TCP communication

Hi everyone
I would like to use TCP communication to send temperature sensor data and data from my USB camera to another client pc. I have  tried using remote panels with limited success because of  the bandwidth requirements for the camera. Using the VI attached can someone help me on how I can use TCP communication in this application. An illustration (or reference) would be greatly appreciated .
Solved!
Go to Solution.
Attachments:
nstflux01-1.vi ‏113 KB

sent wrote:
Ok, so here is my shot at what you guys are talking about. The sever and client see each other just fine but I cannot read any of the data. I think that  my problem is that I don't know how to read the scan correctly. Can someone show how to do that ?
Do you know that format of your messages? Are they terminated with a specific character or pattern? A common way for messages to be sent via TCP is to have some type of message header which identifies the message type and generally provides the message length. If you data follows such a protocol you will need to get the specifics of the header. You would then read the header which will let you know how much more data you will need to read. The most basic header is simply the number of data bytes that follow. So the message would consist of a number (generally 4 bytes) followed by the number of bytes for the value of number.
If you don't have a message header of any type another way that you can read variable length data (but it is not fool proof) is to read a single character. This is where you would have your overall timeout for receiving a message. If you don't receive a message in the designated amount of time you can perform what ever error handling you need. Once you a read a single character you then begin reading chunks of data (perhaps 1024 bytes at a time) and use a very short timeout. When a timeout occurs on this read that would be an indication that there is no more data. This type of approach only works when you have some time between your messages.
The last alternative is if you have some type of message termination character or pattern. In this case you would read data until you see the termination character or pattern.
Mark Yedinak
"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot

Similar Messages

  • How to combine TCP communication VI to other Labview VI

    Hi, 
    I am doing a project that is a sport timing system. In my timing system, I am trying to communicate with another computer by using TCP/IP while the timing system is running.
    I am trying to combine it into a VI, I have tried to solve it by convert one of the VI to sub VI, but it doesn't work or 1 computer cannot run TCP VI and my Timing System at the same time.
    Can any one know how to solve this problem ?
    Attachments:
    3switch 3-2-2012.vi ‏14 KB
    timing system A 24-2-2012.vi ‏48 KB
    timing system b 1-3-2012.vi ‏29 KB

    Hi, 
    timing system b is a sport timing system that like a stopwatch with 24 three-input switch( 0s,2s or 50s will added to the total time if turn on 1 of them).
    TCP communicator active and passive are the other 2 VI. I want to combine  TCP communicator actives VI and timing system b' VI into a VI (that run in computer A).
    And the TCP communicator  passive is run in another computer( computer B). 
    about the stop button in timing system b's VI, the Vi can't function when I add a stop button in it, but it run normally once I removed the stop button. The timing system b is based on the NI tutorial or examples. I based on the example to design the stop watch function. 
    Please help me how to solve it.
    Thanks 
    Attachments:
    timing system b 1-3-2012.vi ‏29 KB
    a TCP Communicator - Passive.vi ‏33 KB
    a TCP communicator Active 1-3-2012.vi ‏31 KB

  • Error 63 in executable TCP communication VI

    Hi guys,
    I'm having some trouble with 'simple' TCP communication between two LabVIEW executables.
    It works fine if both VIs are on the same machine (localhost or 127.0.0.1, the computer with the development system), but if I compile and then run them I get error 63 ('Network connection was refused...') for the VI that contains 'TCP open connection'.
    I have read the forums and a number of NI KB articles, but I'm still not sure what properties and options I have to set. There doesn't seem to be a good how to guide.
    To keep things simple, I have built two example VIs that ship with LabVIEW 8.6 into executables: 'TCP Communicator - Active.vi' and 'TCP Communicator - Passive.vi' (C:\Program Files\National Instruments\LabVIEW 8.6\examples\comm\TCP.llb). Only modification: I have increased the timeout for 'TCP listen' from 10 to 25 seconds, to make the executable easier to use on slower machines.
    The example programs should work like an instant messaging system:
    - Start the 'passive' VI, this VI starts a TCP listener service on the specified port and network address.
    - Start the 'active' VI next, this VI tries to connect to the 'passive' VI over TCP.
    - When the connection is established, you can send and receive text messages
    That's how it should work and, as long as both VIs run in the development system, it does.
    In executable form however, it does not.
    I have a suspicion I need to add a number of entries to the ini file to allow access from everyone, not just 127.0.0.1
    Other troubleshooting suggestions I have read:
    - setting the 'Svr.TCPAccess' property at run-time
    - modifying 'Tools > Options > VI Server: Configuration'
    Can anybody give me some pointers on where to start debugging? For your convenience I have attached the executables and their ini files.
    Thanks in advance for your help.
    Paul
    Attachments:
    NI-TCP-comms.zip ‏593 KB

    Hi Akiel,
    Thank you for your reply. I did some more experimenting, here's what I did:
    I started the 'active' VI and immediately got error 63, whether or not the 'passive' VI was running (on the local machine).
    I pressed 'continue' in the error dialog and execution of the program stopped.
    I copied the 'passive' VI to another computer, turned of the Windows (7) Firewall and then ran it.
    I then changed the machine field of the 'active' program from 'localhost' to 192.168.1.17 (the address of the remote computer).
    I restarted the 'passive' program (because of error 56, time out)
    I restarted the 'active' program
    This time both programs behave as expected.
    Repeated the above experiment with the firewall turned back on, with both programs on the same machine.
    This time it does work without modifications
    Looks like Windows Firewall is probably to blame here, it's behaviour is unpredictable when it comes to whether or not it blocks connections.
    Now for the big challenge: getting the Windows 2008 R2 firewall to cooperate with LabVIEW. 
    I'll update this post when I have more information.
    Paul

  • TCP Communication - How can I remove the priority of which VI will run first?

    Hi. I would appreciate for any advise.
    I want to communicate (send data) to another PC using wireless radio. I am presently testing the shipped examples;
    TCP Communicator Active.vi and  TCP Communicator Passive.vi. I will run first the Passive.vi in the other pc (as
    indicated in the instruction) and then Active.vi on this pc.
    I want to remove or neglect the priority of which VI will run at first (either of the VI can run first).
    If in the case either one of the PC is not transmitting data, it will just trigger a LED or any kind of indicator.
    Can anyone helped me to do this? or is there any other example vi that will do it?
    Thanks a lot.

    Hi Mr Christian,
    i decided to use TCP/IP for peer to peer communication. I made an example VI of what i am doing but i cant make it right especially on the "Time out error". I would appreciate for any advise.
    Kindly see the attached VI's. The Crane 1 will be the Master or Server and Crane 2 and 3 are Slaves or Clients. Slaves VI will pass their data to Master while Master will distribute the data to each VI.
    As a rule, i have to run the Master or Server first and Slaves will follow.
    But as soon as i do this i am getting this Time Out error hence data are not being passed. I tried changing the values of time out constant but not lucky so far. I know that if i can fix this time out error, all the VI can communicate properly. I should see three moving cranes on each VI.
    Additional question; If all of the VI are running, and I intentionally Stop for instance Crane 3 (Slave), then it will show an error (LED) that Crane 3 data is not available. So far i can do this.
    But for instance I will run again Crane 3 (Slave), is there a way to RESET the connection programatically so that Master VI will once again accept the Crane 3 VI?
    Any advise I would greatly appreciate.
    Thanks a lot.
    Attachments:
    Crane 1 (Master).vi ‏40 KB
    Crane 2(Slave).vi ‏35 KB
    Crane 3 (Slave).vi ‏35 KB

  • Monitor TCP communication.

    I want to monitor TCP communication from my client to the server.
    I am using google web service,and using my client i am sending the request and receiving the response.i want to monitor those communications.
    Any one have any code.
    Thanx

    You can try using jpcap

  • TCP Communication Problem - not passing data???

    Hello.
    I am working on TCP communication. I need to pass data from one PC to another and vise versa. I started with the shipped example TCP Communicator Active and Passive VI. Using the shipped example only with the Wireless Unit connected to both PC i am able to communicate and pass data between each PC.
    Now, placing the shipped example VI to my Main VI (separate while loop), I am NOT able to make it run properly. What happens is even if i move the control data on one PC it does not update to the other PC.
    I am attaching the example VI and I would appreciate for any advise.
    Thank you very much. 
    regards,
    jtc
    Attachments:
    TCP Communicator Active.vi ‏51 KB
    TCP Communicator Passive.vi ‏53 KB

    Hi jtc,
    "if you need to share data aquiired rapidly, a work-around is to accumulate the acquired data and send larger "bundles" less frequently" - do you have a simple example VI for this?
    No!   - though we could develop something - but a solution for the current example, might not be helpful to your final program.  For instance, we would capture & accumulate a "batch" of data "produced" by individual user actions, then send the "batch" of data to the other machine and what? Perform all the updates to the GUI in rapid succession (what's the point?.)  Show the last user action/setting?
    It might be a good time to develop the architecture for the Master and Slave applications.
    This sounds like an interesting application!  Do you mind sharing some detail?  For instance, are the slaves generating data?  Are there a fixed number of slaves?  Is it necessary to mirror the Master's data on all the connected slaves?
    Like Johnny-5 said: "Input, I need Input!"
    Cheers!
    Message Edited by tbd on 10-17-2008 08:29 PM
    "Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)

  • NI VBAI TCP Communication With Staubli CS8 Controller

    I have a Staubli CS8 controller running the VAL3 programming language. Their documentation is light but I managed to brute force the solution to controlling DIO (Digital Input/Output) commands. I am having trouble brute forcing the SIO (Serial Input/Output) commands. The Staubli appears to only be capable of being the TCP/IP communication Master. I have my laptop's IP address configured in the Staubli controller with the ethernet socket name of "test". With the NI VBAI TCP/IP communication manager set up as slave and the TCP server enabled, the Staubli controller claims it is actively communicating with the NI VBAI socket server, and status is OK. In the VAL3 programming language I believe I have correctly linked the sioLink(siotest,io:test) between the variable name and the actual hardware device port. I try to send serial text strings from the CS8 to the VBAI. But I cannot figure out where to observe the serial communication traffic in VBAI. I have it set up right now to run infinitely and check the TCP port for serial input, but don't see any results. Anyone integrate these two systems yet? I have been using both for quite some time so I'll catch on fast if someone can run me through some quick steps if they have done this before with NI and Staubli. Thanks.

    Actually the VBAI side of the communication was easy and straighforward. Plenty of help files and info on the NI support site. The Staubli side was more complex with minimal information supplied in the programming manual, and I was having trouble with that. After experimenting further I was able to transfer data between VBAI and the CS8 controller. If anyone else ever tries this here is what you need to on the Staubli side of the communication:
    Set up the ethernet socket on the teach pendant:
    Create a new socket and call it VBAI (or anything you really want)
    Set the Staubli up as the TCP communication SERVER
    Set the termination character for " ; " which is Staubli ASCII character 59 (default is ASCII character 13 which I could not generate in VBAI)
    Create the Staubli program (VAL3 language ONLY):
    Create a new program in your application
    You need to create a serial input output variable (In the data sheet add a new SIO variable, call it sioASCII or whatever you want)
    Also create a string variable (In data sheet add a new STRING variable, call it sTEXT or whatever)
    Now you must link this variable to the actual hardware socket
    Then read the socket and output the value to the teach pendant display screen like this:
    UserPage ()
    CLS ()
    sioLink ( sioASCII , io:VBAI)
    sTEXT = sioASCII
    putLn ( sTEXT )
    Run your VB Inspection on infinite loop first, then run the Staubli program and the inspection data will be displayed on the CS8 teachpendant. Yeah, it always looks to easy after you figure it out the hard way.

  • Technology blocks TCP communication?

    My doubt is: How is the transmission of packets? For Socket?
    Someone there knows answer me?
    Ps: I am Brazilian I'm using google translator
    Tanks

    Hi Camilo,
    Your question is How LAbVIEW Transfer TCP packets? Is by socket?
    In the following link you can see what socket service LabVIEW uses to TCP Communications
    http://digital.ni.com/public.nsf/allkb/07E11647E145A62A86256B19006DCD1D?OpenDocument
    Regards,
    Abel Souza
    Engenheiro de Aplicações
    National Instruments Brasil

  • TCP communication and Remote Panel programming

    Hi all:
    I am developing a LabVIEW program which is to used remotely. I am planning on using Remote Panel Access or TCP Communication for my application. I would like to know why is a better choice and what are the factors I should consider in choosing one of these. Jsut for information, I am also using serial communication in this program using RS232 cable.
    Thanks in advance,

    I am not sure what the legal aspects are for the Run Time Engine.  You will have to dig deeper or contact NI if it will not let you load it.  From what I read is:
    Additionally, the Run-Time Engine allows your browser to display VIs that are embedded in Web pages.  There are two downloads that are available. You only need to install one of them. LVRunTimeEng.exe is a smaller download intended when viewing Remote Front Panels in Web pages. It does not contain the full run-time engine, but will allow some executables to run..............
    http://digital.ni.com/softlib.nsf/websearch/1F1EBEA6D03A67E6862570A400531F97?opendocument&node=13205...
    Yes, you can have an executable and that would be the preferred method.  Start small and work up to the final version.  Start by using your developer version and have it generate the WEB page.  Using the same computer you can view the page and take control using Microsoft Internet Express.  From there build it into an application, try it again.  When all looks good then put it on the server.  You are limited by licenses on how many WEB pages you can have running.
    Hope this helps,
    Matt
    Message Edited by mfitzsimons on 11-01-2005 10:17 AM
    Matthew Fitzsimons
    Certified LabVIEW Architect
    LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison

  • Need help with Modbus RTU over TCP communication

    Hello!
    I'm working with a project that involves communication between a LabView PC, a cRIO-9073 and a few Crouzet PLC's with XN05 modbus extentions. The issue I'm having is to get a stable and reliable connection between the units. The cRIO is communicating with the PLC's by Modbus RTU over TCP and I've created code that read and write to them in a sequential order to avoid possible ModBus conflicts. The LabView PC is sending a "ping" (boolean true) every second to the cRIO over UDP and the cRIO is then sending the "ping" to the PLC over Modbus/TCP. The PLC has a timer that waits for pings, if no ping has been recieved in 7 seconds the emergency brakes are applied and the system shuts down.
    The main problems right now is:
    * After a while I lose the connection between the LabView PC and the cRIO. "Connection with RealTime target cRIO-9073 has been lost".
     - I also get either error code 56 or 66 on the TCP link.
    * The second problem is that if I quickly pull a TP-cable from, let's say, a PLC and then directly plug it back in I want the TCP connection to quickly reestablish. However what happens is that the "pings" from the cRIO stops coming to the PLC for like 5-6 seconds (time to reestablish link?), which means the 7 second timer is almost full. One option would be to raise that timer value, but the drawback is that the system will take longer time to respond to an true error which could be bad.. My question is simply, does it really take 5-6 seconds to establish a TCP connection between a cRIO and a PLC? What affects the time? 
    I would greatly appreciate help or respons on this one. I attach a simplified version of the code I use (all variables and such has been replaced with constants). 
    Is this a good way to do a ModBus communication over TCP with 3 PLC's?  Is there a better, safer, more reliable way? All suggestions on improvment is appreciated
    Thanks!
    /J
    Attachments:
    MB_TCP.vi ‏29 KB
    MB_PLC.vi ‏28 KB

    Dear J,
    Check the state machine Architecture here.
    1. In your acquisition if you got error in any system you close all TCP connections that is not right your other systems are working fine.
    2. You go with parallel loop connection. For each PLC you run separate code with error handlers.
    3. Check the attached VI for TCP Read. Same VI you can modify and use for your ModBUS operations.
    4. In you Sub VI you are passing a constant cluster. I am not able to understand what is the use of case structure inside the subVI, In you code you are passing the constant so its always same.
    As you done previously made 3 loops or VIs to read the data in a main VI. First try to made one VI with one PLC, remove your all bugs and errors and copy it 3-time with different-different configurations.
    Thanks and Regards
    Himanshu Goyal | LabVIEW Engineer- Power System Automation
    Values that steer us ahead: Passion | Innovation | Ambition | Diligence | Teamwork
    It Only gets BETTER!!!
    Attachments:
    Tcp Host.vi ‏28 KB

  • TCP communication fails

    I have a VI that communicates to six devices simultaneously over Ethernet. Three of these devices are on a serial port server so the PC recognizes them as serial ports and I use Visa Serial for this communication. The other connection is to a PLC. The problem is with the two watlow controllers connected via ethernet. After a couple hours of continuous run, the information from the Watlows gets garbled or fails completely while my other devices communicate just fine. If I stop and restart Labview the communications come back properly.
    The program opens three TCP connections each to a different IP Address. then goes into two while loops. One while loop is faster and talks with the PLC. The other while loop is slower and talking to the Watlows. I use the same remote ports for all three and asked the customer to change them to be 502, 503, 504 but this caused an immediate loss of communications.
    Anybody have any ideas? These are Watlow EZ-Zone controllers.
    Attachments:
    SIP Main Interface Beta IV.vi ‏535 KB

    Hi Technics,
    Did you try to use the Process Monitor from Microsoft to see why the communication hangs up ? There are many more programs that can be helpful, if you search for "procman" or "procmon. with those programs you can monitor the system and see waht goes wrong. also if your program uses NI-VISA. you can use NI spy to monitor the system. 
    Thanks and have a great day. 

  • TCP Communication problem in Touch panel device runs on winCE 6.0

    Hi all,
        I am running labview touch pannel application on WINCE 6.0.  In application i am trying to establish the TCP connection.
    As i do that the labview application is getting crashes and closes without updating any error.Can anybody help me out.     

    Hola...
    Yo estoy programando una PDA, iPAQ 214 que soporta USB Host, con tarjeta NI USB-6009 y tengo la misma descripción del error aunque con código de error 30123
    "Error - Unable to run the application on the remote device. CreateProcess failed with error code =30123
    Possible reasons:The application does nor exist on the remote device.Another application with the same name is already running.The application is not compatible with the operating system of the device.Closing connection ...Done"  
    Estoy utilizando Ni-DAQmxBase3.1 con LabVIEW8.5.1  Windows XP. ejecuté el FWUpdate en C:\Archivos de programa\National Instruments\NI-DAQmx Base\bin
    "NI-DAQmxBase List Device" lo reconoce y el MAX también.

  • CVI RT (Real Time) - HOST TCP/IP Communication

    Hi,
    I am using CVI 2012 Real Time with PXI hardware. I am using TCP/IP communication b/n RT and Host. RT is server and Host is client. In my application, after TCP connection is established between client and server, client will send a command , take for example "GET_DATA" to RT, RT has to respond to that by sending that data.
    I am successful in
    Establishing RT-Host TCP communication ( I am able to see that host is reading the welcome message sent by RT).
    Host is sending the command "GET_DATA" to RT.
    RT is receiving the "GET_DATA" command from Host.
    In TCP server call back function, in TCP_DATAREADY event, i am using ServerTCPRead() to read data from Host. After reading the data, i am comparing the data with expected command and based on that i will be sending the data using ServerTCPWrite().
    RT is reading the command from Host, but it is not writing the data to client. I am not sure whether I can use ServerTCPWrite() in TCP Server call back function.
    I also tried using multithreaded concept, but not getting success.
    Please suggest any solution for this.
    Thanks,
    Haari

    Hey Rashid,
    Check out this tutorial with examples and let me know if it helps.
    Stephanie O.
    DIAdem Product Manager
    National Instruments

  • TCP/IP Communication - 2 applications meant for separate clients - not working on single computer

    Hi,
    I have developed 2 applications (will ultimately operate on two different machines, but for development I want to run them on the same computer) that work in a similar manner to the TCP Communicator examples in LabVIEW 8.20.  What I can't understand is why the examples do not catch their own send commands.
    Each of my applications has a send and recieve while loop - one app. listens for a connection and the other creates the connection.  That is working fine, but when I send information (which is intended to go from one application to the other) - it will get often "get caught" by the recieve loop that is operating with the same TCP/IP connection.  This makes sense because both loops are looking at the same port, but there should be a way around this because it does not occur in the examples provided by NI.
    Any help is greatly appreciated! 
    Thank you,
    Travis

    I'm surprised you can get that far.
    I currently have 4 loops on two computers.
    Loop1 (on PC #1) uses port 2702 to talk to Loop2 (on PC#2)
    Loop3 (on PC #1) uses port 2701 to recieved data from Loop4( on PC#2)
    I'm using TCP Listen.vi, TCP Open Connection, and TCP Read/Write.
    I intended for this to allow simultainous communication betwen the PCs using two different ports (I know TCP IP supports this, I can surf the web and download something via ftp at the same time) but LabVIEW says "The specified network address is currently in use." When I run the VI on PC1.
    I agree the address might be in use but not that port number (I know they are wired correctly to 2701 one way and 2702 the other way).
    Any suggestions?

  • Tcp/ip communication problem

    hello,
    what i have is a tcp/ip communication problem.   the server needs to see the connection on the client side terminate before it can reply with data.  so i'm not sure the best way to
    solve this.  i tried to use a sequence structure to have the client open a connection  and then send data across the port and then terminate the connection.  the next part in the sequence would then open a connection and wait for the reply form the server.  i had this in a while loop. an example vi would be very appreciated

    Hi,
    You can search for TCP Communicator -Passive.vi and TCP Communicator -Active.vi examples in the example finder by selecting Help->Find Examples.
    Tunde A.

Maybe you are looking for