TCP connection in labview and C program

Hi there,
I have a server program written in C and running under linux, it
accept connection from client and send series of data to client
through TCP socket. I was using the "simple data client.vi" as the
client.
I tried to send integer number 1, 2,3.. , but the client failed to
correctly decode the data since it read everything as string. I was
wondering if there is a solution to read binary data in labview TCP
connection? I really don't want to encode the double into string and
send it to client through TCP socket in my server program, since it's
not efficient.
thanks !

> I have a server program written in C and running under linux, it
> accept connection from client and send series of data to client
> through TCP socket. I was using the "simple data client.vi" as the
> client.
> I tried to send integer number 1, 2,3.. , but the client failed to
> correctly decode the data since it read everything as string. I was
> wondering if there is a solution to read binary data in labview TCP
> connection? I really don't want to encode the double into string and
> send it to client through TCP socket in my server program, since it's
> not efficient.
> thanks !
>
The string is often used in LV as a general buffer. Type Cast the
string as the appropriate integer and it should be fine. If the integer
has been transmitted in litt
le endian byte order, you will need to use
the Advanced byte and word swapping functions in LV in order to reorder
the integer contents -- LV always assumes big-endian binary format.
Greg McKaskle

Similar Messages

  • Connecting between labVIEW and PLC S7-1200 using EPICS

    Hello everyone,
    I'm trying to connect between LabVIEW and PLC S7-1200 using EPICS. I did it using OPC and it succeeded and the communication was done, so right now i'm trying to do it using EPICS. so Can anyone help me with that?
    Thanks in advance.
    Ahmed

    Hello,Ahmed:
    Now I'm trying to conect S7-1200 to Labview by OPC server 2012, I'm newer for both PLC S7-1200 and OPC server. by the help file of NI's OPC I tested many times, but lost totally.
    You mentioned that you have succeeded making the connection between them, could you please help me :
    1) How to set in Simense TIA software? I can set the PLC's IP address now, that's all;
    2) OPC server setting.
    if there is a video, that will be great.
    thanks a lot.
    Delphi77.

  • Establish connection between labview and Lantronix XPort Pro

    Hi:
    I am pretty new in this field. I just got into grad program, and I have been asked to establish a TCP/IP connection between Lantronix XPort Pro and labview 8.5. The goal is to get data from the server (Lantronix XPort Pro) and put them into labview and modify them, then I need to send modified data back into   server.
    The server has registered into local network wirelessly, it has IP 192.168.5.117 in port 26.
    I would really appreciate your help and comments.
    cheers!
    Kian.

    Which field are you "new" to? Programming in general? Programming in LabVIEW? TCP/IP?
    Have you taken a look at the TCP/IP examples that ship with LabVIEW? There are simple Data Client/Data Server examples that show transfer of data over TCP/IP. You will likely need to do something very similar. Does the XPort Pro have a TCP/IP listener running? Do you have a communication protocol defined?
    Also, if you are new the LabVIEW, have you gone through any of the tutorials? To learn more about LabVIEW it is recommended that you go through the introduction material, tutorial(s), and other material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials. You can also take the online courses for free.

  • Listen if the TCP connection between robot and LV GUI is lost

    Hi
    I'm doing a simple client/server TCP connection between a Labview GUI and a robot controller.
    My robot controller acts as the TCP server that waits for a connection from the Labview GUI, it gets a string as a ready signal and then writes a string back to the LV GUI to tell that the controller is ready, then the LV GUI should be ready to send commands to the robot.
    So now first of all there are two things I want to do;
    1) I want the user to push a button to connect to the robot and then make a red/green light turn on if the connection is established, then the LV GUI also starts a small loop that waits fro whatever is coming from the robotcontroller, this is only for debugging right now
    2) Secondly I want the LV GUI to listen if the connection somehow is lost, like if the robot goes out of range or some other programming error in the script for the robot controller that might make the TCP connection terminate. So if the connection is lost from the serverside, then I want the LV GUI to keep runing but just turn the light red.
    I have tried some of the examples in Labview but I sure could need some help on this.
    LV 8.5
    LabVIEW 8.6 / 2009 / 2010
    Vision Development Module 8.6 / 2009 / 2010
    VBAI 3.6 / 2010
    Attachments:
    11.gif ‏10 KB
    21.gif ‏12 KB

    You really should change your architecture. I assume that your other controls also control the robot, so you will need more complex messaging.
    I suggest you look at some of the examples and templates for queued message handler. Essentially, this will allow you to send message between two loops, which is probably what you want.
    As for what your comm loop should actually look like, you should separate the opening part from the communicating and closing part. That way, you can send the Ready string immediately after connecting. The example code you used already handles the timeout error, which is the indication you want that the connection was lost.
    Here's one (very bad) example of how this could be done:
    You should note that this does not really do any error handling. If you use a queued message handler and actually turn the comm loop into a state machine (with states like Open,Comm and Close), it should be cleaner.
    To learn more about LabVIEW, I suggest you try looking at some of these tutorials.
    Message Edited by tst on 01-19-2008 07:53 PM
    Try to take over the world!
    Attachments:
    Comm.png ‏7 KB

  • Please Help!!! VIPM won't connect to labview and I need to figure out why

    I am trying to download the Arduino package from the VIPM and they won't seem to connect. I have included a picture of the error and two more of my settings. I am using the student evaluation of the Labview software, but I'm not sure that it is what's causing the problems. Any help would be appreciated, as I would like to set up a nice GUI using labview and an arduino as my DAQ device. I need this for a project for my professors so I am rather desperate to get it up and running.
    Attachments:
    Labview Error.jpg ‏352 KB
    Labview Error II.jpg ‏141 KB
    Labview Error III.jpg ‏108 KB

    No, i tried using you settings and stil not working. i went through every combination of the four items I have on the machine and export list. Still nothing, do you think that its that i am using the student version?
    Attachments:
    New Labview settings, not working.jpg ‏123 KB
    New Labview settings, not working.png ‏267 KB

  • Large applications - Labview and other programming languages

    Hello Labview Users,
    as the forum saw this very interesting thread about large applications programmed in Labview
    (see: http://sine.ni.com/niforum/niforum?requireLogin=False&forumDU=http://forums.ni.com/ni/board/message?... ) I would like to ask the community about their experiences with Labview applications in combination with other programming languages.
    In advance: I have several years of experience in programming Labview applications starting from quick-and-dirty solutions which had to run within few hours and complex test solutions. I saw Labview growing and becoming better with the released versions and lot of things I missed in former times got implemented in the meantime. Actually I have to develop a complexe ATE solution with numerous equipment to control and numerous data to be captured and archived. Despite the Verison 8 I still feel still some drawbacks of the LV concept which let me hestitate to setup the solution completly in Labview:
    1) It is alway hard to re-use code of complex applications since it is not possible to do some kind of global search an replace of functions
    variables etc. It nearly impossible to re-use approved code structures (e.g a state machine) if the "inner part" is changing more the a little bit.
    2) If the application requires a certain flexibility (e.g. exchangeable test equipment of varying vendors) this is hard to implement since you have to define a lot of parameters through your hierarchy if you dont want use global variables which slow down your application and hide
    the code functionality.
    3) Despite modern PCs the look and feel of LV applications appears somewhat slow compared to other applications. For complex user interfaces the polling methode generates a lot of complex code. (I dont have expierence with the event-structure).
    Now my questions:
    Do you have experience of implemention of complex solutions dividingthe code modules using Labview and other languages? Which other
    languages did you use? Why did you use these languages (speed, flexibility of text based code, available library functions)? Did you found out this to improve your development time and code maintainibility?
    (I concider a solution where I do the single tests with Labview-VIs but delegate all the test sequencing and data collection stuff written in PERL which allows really very compact code)
    I'm curious what your experiences are.
    rainercats

    Given that you're asking these questions in a forum for LabVIEW users the opinions given are going to be somewhat slanted towards the general like of LabVIEW. I've been working with LabVIEW for a long time, ever since 2.something on a Mac. I've written numerous large-scale applications as well as "mundane" instrument drivers. As you've noted you're experienced with LabVIEW, so you know some of its strengths and weaknesses.
    To address your specific questions:
    (1) Yes, that has always been a limitation in LabVIEW, but I don't believe it is an overriding one to choose C over LabVIEW. Putnam provided one workaround for the search and replace of VIs. Once you've programmed in LabVIEW long enough you get used to doing it this way. Is it clumsy? Yes. As for the re-use of code structures, that's not entirely true. You can create a "template" VI (a regular VI, not a .vit) that contains the code you want to re-use and place in your palette with the "Merge VI" option set. That way you can select it from your functions palette, plop it down on your diagram, and you get the "template" VI's diagram placed right into your new VI.
    (2) This is not something that is specific to LabVIEW, as this exists with any programming language. It's not the language that limits you here, it's how you've designed your code. In a language like C++ you would go with classes. You can do the same thing in LabVIEW. IVI is another option (though not preferred by me).
    (3) As Putnam mentioned, you should be using the event structure.
    Other thoughts:
    The biggest strength I see with LabVIEW is that each VI is a miniature program, which allows development and debugging of functions a snap. With a language like C you have to write another program to call that function in order to debug it. The biggest weakness? I would say user interface. Yes, even with the event structure. Don't get me wrong, the event structure has vastly improved the way user interfaces and event handling in general are done with LabVIEW, but it simply doesn't hold muster to a program written in C or VB. ActiveX anyone? LabVIEW still doesn't do ActiveX properly in terms of actually getting the controls to work. Programming ActiveX controls is just plain aggravating what with all the property nodes taking up so much diagram space.
    It certainly makes sense to use the best tools available to you to get the job done. In my recent projects I had to write software to run automated tests on some products my company made. The test modules were written in LabVIEW. The tests executive was a proprietary engine driven by a SQL Server database. I had to write a "wrapper" DLL that interfaced between the LabVIEW code and the executive since the executive hadn't been designed to call LabVIEW DLLs directly. This allowed us to use LabVIEW as the preferred language for developing the test modules and let the guys who were fiddling with the test executive do their bit. Of course, TestStand's premise is basically that.

  • Is there any crush between LabView and other program ?

    my system is win98 with LV 6.1. After installing this software (ACDSee 5), my program got error -10800, trigger timeout (my program is developped DSA.vi example) everytime i ran the program, it never happens before. Then after i uninstall the software, my program work just like before, no problemo.
    Can Labview crush with other program ? How ?

    I don't think it's actually LabVIEW that's causing this problem but a hardware driver issue. Error -10800 is an NI-DAQ error. If you installed ACDSee (I like that name) it appears that they supply drivers also, so you're probably getting some problems with these two drivers being installed. Make sure that any other LabVIEW programs still run or if they generate this same error. If they do, then it's certainly the driver. Otherwise, it's a particular operation that's interfering with the ACDSee software.
    J.R. Allen

  • Tcp data b/w labview and c++

    Hi
     i am trying to establish TCP connection b/w LABVIEW and C++ program. Server is established in C++ while client is implemented in labview.Although connection is successfully establish b/w server and client, both are unable to correctly understand data send/receive among them. Forexample if i want to send an int type send_array from server, i use standard WINSOCK function "send" like that:
    send(AcceptSocket,(char*)send_array,129*4,0);
    but when client in labview receive this array, it shows unexpected values.As a client, I used "simple data client.vi"  with one modification i.e. as sent data size(129*4 bytes) was fixed, only one TCP read was used . 
    Same problem exists if i send data from client to server.
    Kindly help me
    Best Regards
    Solved!
    Go to Solution.

    It's probably an big/little edian problem. If you are using the Flatten/Unflatten from String functions, you can specify which to use.

  • Tcp connection to Processing not working

    Hello,
    I had a processing code designed for me to generate 8 different types of an audio signal - labeled as 8 conditions for an experiment i am running. I can use processing and Supercollider to play the audio signals no problem but when I try to set up an TCP connection between Processing and labview (2009 version) to run my experiment it does not execute the commands that have already been embedded into the processing code. I am using the correct port and IP address, as specified in the processing code but for some reason the commands that I set in labview, to generate the audio condition, do not work.
    I can provide the audio code if necessary. When I 'run' the TCP connection in labview no errors are reported so it is making a connection but for some reason the command (e.g. 'C1' for condition 1) does not execute and I hear no audio.
    any help would be greatly appreciated,

    Apologies i may not have been clear before. The processing software is listening for a connection from labview. I am using the TCP connection to send a command (i.e. 'C1') to processing so that it will be executed. The reason I am using the TCP connection is because for my experiment I require subjects to follow this audio signal which is connected to the DAQ. I am basically assessing how well subjects can follow the signals. Labview allows me to run the experiment and all its elements at once. 
    I have sample labview work that I am basing everything on which I am told worked fine before but for some reason when i replicate their labview work it doesn't seem to work for me.
    Attached is the 'labview connection patch' code that I run in 'Processing'. This code basically listens at a particular port/Ip address for a connection/command
    Attachments:
    labview connection patch.docx ‏95 KB

  • TCP connections effect in case of waas failure

    i need to know the effect of waas failure on the existing tcp connection.

    Cisco WAAS utilizes standards-based TCP optimizations to remove TCP as a barrier to application performance over the WAN. By initiating a TCP Proxy after autodiscovery, communicating nodes experience LAN-like TCP behavior through local acknowledgement and TCP handling. As such, when the network goes down the TCP proxy has the ability to mask the disconnect for a short time, but after that all TCP connection will reset and clients will try to re-establish a connection.
    For CIFS
    -During transient disconnects (up to 95 seconds), the WAAS Edge maintains data in its buffers and retries the transmission to the WAAS Core upon network re-connect.
    - When the WAAS Edge switches to "disconnected mode", its services change to "no service" and the buffered data is lost. Further file operations will fail and the Client will be alerted that the server is disconnected. Open documents can be "saved as" on another drive
    -If the accessed file server was configured for "Disconnected Mode" CIFS clients will be able to continue to browse the cache directory and read fully cached files on an WAAS Edge
    In addition with Windows on WAAS providing local window services (dns, authentication) user can access local file shares on WAVE

  • Opening and closing Multiple TCP connection​s issues

    Hi all I am having an issue with the TCP VI’s and wondering if anyone has experienced this issue.
    My application is required to scan 50-100 IP addresses (statically assigned) and discover if an Ethernet device is connect at that IP address. Currently I am able to achieve this by opening a TCP connection and testing the error cluster to determine if a timeout has occurred (no timeout error  means Ethernet device available at the IP address). I then ensure that the TCP connections are closed.
    The issue I am have is that I require a 1 second delay between the  TCP open and the TCP close which significantly slows down the process. Without the 1 second delay the vi successfully connects to the device once then fails to make any TCP connect regardless of the time delay until the PC is reset.  
    If anyone has any advice I would be very grateful
    David Barr
    P.S. I have attached a simplified section of code showing this issue
    Attachments:
    TCP Open close issue.vi ‏15 KB

    smercurio_fc wrote:
    If I understand you correctly you want the time delay to be 1 second if there's a successful connection....
    While I don't have a specific answer for this problem. I want to clarify for him. I believe the issue is, what if all connections ARE there? That means you keep returning a wait of 1 second 50-100 times so It takes 50-100 seconds just to initialize. I think the user is looking for a way to check for valid connections, but do so in such a way that eliminates the need for a wait which is greatly slowing things down.
    CLA, LabVIEW Versions 2010-2013

  • TCP/IP communication between labview and microchip board

    Hi
    I have a microchip board which sends out data over the Ethernet. I have to read this data and use for further mathematical computations on it. So I decided to use some available examples on Labview. I find that all examples come as a pair, client-server. But in my case the board will be the server ( providing data continuously) and Computer with Labview will act as a client (Continuous receiving). Is there any readily available example on Labview for this purpose. If not, can you please suggest which example I need to modify for my purpose? Thanks
    Arvind

    arvind3tthiru wrote:
    Hi Greg, thanks for the reply. I am connecting to a PICDEM.NET2 board which is sending data through its ethernet port. I know the port number and the IP address of the board. I want labview to listen to this port and store the incoming packets. I am not sure how LABVIEW disintegrates the TCP packets and takes only the data out. Since I am not seeing anything on the LABVIEW client, so I am starting to think that TCP Client on LABVIEW may have some prescribed packet format which is not the format in which I am sending my data in. Please enlighten me if I am wrong. If you need more information, please tell me what you will need, I will provide you immediately.
    Thanks
    Arvind
    LabVIEW has no "predesribed" packet format, and it doesn't take packets apart. LabVIEW operates at the application level, so the OS is responsible for providing the data that's contained in the packet to LabVIEW. LabVIEW just sees the data in the packets.
    Have you verified that a connection is actually being made? You said that the LabVIEW should listen to this port. Did you create a listener on the LabVIEW side? Does the microchip code indicate a connection? You may want to use Wireshark to capture the packets to see exactly what is going on.

  • HP/Agilent Infiniium 54831B scope - how to connect with LabView 6.0 by LAN (TCP/IP)

    Dear,
    I'm looking inf. how to connect Agilent Infiniium 54831B scope with LabView 6.0 by LAN (TCP/IP).
    Thanks in advance.
    Regards,
    Z.Mrowka
    mailto:[email protected]

    Hello,
    If the instrument is capable of being controlled from its TCP/IP port, it will be possible to communicate with the instrument from LabVIEW using VISA.
    The VISA resource name input will need to be entered manually and is a little different from the normal Serial or GPIB format. The format is as follows:
    For SOCKET connections, this is just like the traditional TCP functionality in LabVIEW. An example string that connects with the NI FTP site is:
    "TCPIP::ftp.ni.com::21:OCKET"
    For INSTR connection, this requires a device that supports the T&M standard LAN instrument protocol. An example of this (that we have tested with) is the Tektronix 3054 Scope. A string that connects with this scope is: "TCPIP::HostnameOrIP::gpib0,1::INSTR"
    I hope this
    helps,
    Anthony Bacak
    National Instruments
    Applications Engineering

  • Using a TCP/IP Connection to REQUEST and RECEIVE data from a iDRX Signal Conditioner through a EIS-2B Server

    First let me say that I am new to labview, please bear with me.  I want to use Labview to querry a iDRX thermocouple signal conditioner using tcp/ip.  The signal conditioner is wired to a EIS-2B server.  The server is at 198.162.10.53 and port 2000.  The data request command is *10x01\r and the expected data to be returned is 01X01+00064.6 (or whatever the actual temperature is).  The conditioner and server are working and testing correctly using the iDRX supplied software.
    My attached vi runs, creates no errors, but returns no data either.  I can find many examples of how to set up a listener, but I need to QUERRY and then RECEIVE the data.
    Thanks in advance.
    Attachments:
    Alyeska 4.vi ‏15 KB

    Hi Alyeska!  Welcome to the forums!
    I took a quick look at the VI, and I have four quick suggestions for
    you that may give us some information about what is happening.
    You may be experiencing an error that just isn't detected by the VI -
    normally we add an error handling VI at the end of program execution to
    report any errors that occurred.  Also, it's helpful to have a way
    to exit the while loop so that the program can finish executing if an
    error occurs.  Third, you may need to introduce a delay between
    the query and the read command to allow the server time to process and
    respond to the request.  Lastly, if you already know how long the
    return message will be, you should wire this length to the Bytes to
    Read input of the TCP Read VI so it knows to return the data once it
    receives that number of bytes.  I've attached a modified version
    of the VI incorporating these - give this a try, and let us know if you
    still see an error, and if so, what error.  Also, if you haven't
    taken a look at it already, there are excellent resources for learning
    LabVIEW at the LabVIEW Fundamentals page - it's a great way to introduce yourself to LabVIEW and get up to speed quickly.
    Cheers,
    Matt Pollock
    National Instruments
    Attachments:
    Alyeska 4.vi ‏19 KB

  • Save data and tcp connection

    Hi,
    I have a connection between a measurement roboter and LabVIEW. I transmit the data above an TCP connection (for example the coordinate plane of the sensor). I have different ports to transmit the data. Is it possible to save the transmitted data and the TCP number of the Port?
    Attachments:
    datasend.vi ‏20 KB

    Hi,
    Just use the:
    >
    Regards, Christian

Maybe you are looking for