Tcp ip external code

Hello forum. Currently I'm trying to establish a TCP/IP connection between a server and client, in which the client has to be a labview written VI. The server and client communicates via a certain protocol. Can someone "translate' this protocol to Labview?
Description of the communication protocol
1. Introduction
The communication between Client and Server application is based on request – response rule. Client application side requests and server side responses to it.
Request is sent by the Client to the Server side. Type of request (and the response as well) is recognized by command number (field Command in the sent structure). Next, depending on type of request, Server responses to client by sending requested data.
2. General frame structure
The frame structure is like shown below:
FRAME = HEADER + DATA
Header consists of following fields:
 Type of command (public ushort Command) – describes type of request (or response)
 Size of whole data package (header + data) (public int Lenght)
 Number of the next sent frame (public ushort CommandNo)
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct Header
public ushort Command;
public int Lenght;
public ushort CommandNo;
3. Command types and numbers
Command types and numbers are shown below:
a) Commands sent by Client application
 LAN_CODE_GET_GPS_INFORMATION = 0x0005 – requests to calculate and send new position
 INTERNAL_CODE1 = 0x0007 – reserved
 INTERNAL_CODE2 = 0x0008 – reserved
b) Commands sent by Server application
 LAN_CODE_GPS_INFORMATION = 0x0006 – sends calculated position
 INTERNAL_CODE3 = 0x0009 – reserved
/// <summary>
/// Commands sent between client and server.
/// </summary>
public enum Commands
LAN_CODE_GET_GPS_INFORMATION = 0x0005,
LAN_CODE_GPS_INFORMATION = 0x0006,
INTERNAL_CODE4 = 0x0007,
INTERNAL_CODE5 = 0x0008,
INTERNAL_CODE6 = 0x0009,
4. Detail description of the commands
4.1 Requests
4.1.1 Calculate and send new position request
This request is sent by the client in order to calculate and send new position on the track by the server. Server reacts on it by sending calculated data in response described in 4.2.2 paragraph.
a) Header
ushort Command = LAN_CODE_GET_GPS_INFORMATION = 0x0005
int Length = sizeof(Header)
ushort CommandNo – unknown value (next message number)
b) Data
No additional data.
4.2 Responses
4.2.1 Sending calculated GPS position with additional data
This response is reaction to "Calculate and send new position" request (paragprah 4.1.1). The position (and additional data) is sent in packed GPSInfo structure.
a) Header
ushort Command = LAN_CODE_GPS_INFORMATION = 0x0006
int Length = sizeof(Header) + sizeof(GPSInfo)
ushort CommandNo – unknown value (next message number)
b) Data
Data is sent binary in structure shown below packed to byte array.
/// <summary>
/// Structure containing calculated data with additional info.
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct GPSInfo
/// <summary>
/// Calculated position.
/// </summary>
public PositionSt Position;
/// <summary>
/// Section id, on which train is.
/// </summary>
public int IdSection;
/// <summary>
/// USISID, on which train is.
/// </summary>
public double USISID;
/// <summary>
/// Actual mileage (in section).
/// </summary>
public double SectionMileage;
/// <summary>
/// Begin mileage of the section.
/// </summary>
public double SectionBeginMileage;
/// <summary>
/// End mileage of the section.
/// </summary>
public double SectionEndMileage;
/// <summary>
/// Mileage from odometer.
/// </summary>
public double OdometerMileage;
/// <summary>
/// Structure describing batteries status of the GPS.
/// </summary>
public BatteriesSt Batteries;
/// <summary>
/// Actual time.
/// </summary>
public double DateTimeInfo;
/// <summary>
/// Actual speed.
/// </summary>
public double Speed;
/// <summary>
/// Defines if navigation needs choosing leg by the user.
/// </summary>
public int NeedChoosing;
/// <summary>
/// Defines if sent position is unknown (when we don’t know on which leg we are)
/// </summary>
public int PositionUnknown;
/// <summary>
/// Number of the first leg.
/// </summary>
public double Leg1;
/// <summary>
/// Number of the second leg.
/// </summary>
public double Leg2;
/// <summary>
/// Defines if section, on which we are is properly defined in database.
/// </summary>
public int WrongObject;
/// <summary>
/// Defines ‘virtual’ mileage of the non-properly defined section.
/// </summary>
public int WrongMileage;
/// <summary>
/// Non calculated raw gps position.
/// </summary>
public PositionSt RawGPSPosition;
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct BatteriesSt
/// <summary>
/// Percentage of batteries load.
/// </summary>
public double Percentage;
/// <summary>
/// Voltage of the batteries.
/// </summary>
public double Voltage;
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct PositionSt
public double X;
public double Y;
public double Z;

Some more very general info, not so much the TCP itself, but how to deal with those data structures.
The TCP interface in LabVIEW takes strings.  So you'll have to convert the packets into the right kind of data structure.
1. You'll probably want to define LabVIEW datatypes corresponding to the various structs defined in the header.  A LabVIEW cluster is the element that is most like a struct.
2. As you populate the cluster with native datatypes, be careful to use the correct ones.  When you drop a numeric control, LabVIEW treats it as a double by default.  You can then right click and change the representation to the right kind.  Be careful about the size of your integers too!  You'll need to know whether a ushort means 16 or 32 bits for example.
3. The memory layout order for a LabVIEW cluster is not necessarily the same as the visual order.  You'll need to right-click the cluster border in order to define the correct order of all the items within the cluster.
4. Back on the cluster border, right-click and choose Advanced->Customize...  This brings up the custom control editor.  Make your custom data type into a typedef.
5. The LabVIEW function Unflatten from String is probably the best way to convert the received TCP string into the typedef'ed cluster's datatype.
6. For debug and troubleshooting of this conversion, be sure you have a way for your server to send a known non-default struct so you can validate what you receive and interpret.
-Kevin P.

Similar Messages

  • How can I include external code in an Installer?

    My LabVIEW program calls some external code using a Call Library Function Node. The external code takes the form of a DLL, and it needs to be located in the same directory with the executable that LabVIEW builds. However, when I look in the installer properties under Source Files, it won't let me, even under My Computer, except .vi files and a few related types that LabVIEW knows about. I can't select my DLL! And if that's true, this installer spec can't build a complete installer for my program. Is there anyway around this, to get my DLL included?
    Thanks,
    Ken

    To elaborate on smercurio's answer:
    If you only specify the DLL name in the Call Library Node configuration, LabVIEW (actually really Windows) will search through the Windows standard locations to find the DLL. LabVIEW will update the path to show the actual location Windows has found the DLL at, but it will assume that it is a standard DLL that either comes with Windwos itself or its own installer.
    If you enter the entire path to the DLL LabVIEW will include that DLL in the built automaticaly and copy it into the data folder by default.
    If you specify the DLL name on the diagram with the path parameter to the DLL Node, the LabVIEW compiler can not know at compile time what DLL will be used (even if you use a fixed path constant which would be a bad idea anyhow). It is then your responsibility to make sure that the DLL is installed on the target computer at that location.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Error message: Exception error within external code

    Hi
    I am getting an error message on running one of my vi's that uses DAQ.mx that causes labview to close it reads:
    An exception occurred within the external code called by call library node.  This might have corrupted LabVIEW's memory.  Save any work to a new location and restart LabVIEW.  "VI ......." was stopped at node OX19E4 DAQmx Start Task.vi.
    The odd thing is if I put execution highlighting on the vi runs ok and then continues to run OK untill I close Labview and restart it.
    Is anybody familiar with this error.
    Many Thanks.
    Ashley

    I've never come across this error before but looks to be a problem with the NI-DAQmx driver. As a first step, I would recommend unisntalling the driver and then re-installing (i would also install the latest version 8.0).
    Funny how slowing the code down doesn't present the problem. let me know how you get on with the above.

  • Show external code in general ledger Print Layout Designer

    Hi Experts,
    Is it possible to show external code of the GL account when we generate a ledger report?
    I am figuring out what system variable to use to show this.
    Thanks.

    Hi Manish Kumar,
    Please check this link for PLD guide:
    http://www.pioneerb1.com/wp-content/uploads/2012/04/HowTo_PrintLayouts_PLD_88.pdf
    Hope helpful.
    Thanks & Regards,
    Nagarajan

  • Financial Reports-Summary based on external code

    Hi,
    Is it possible to select different accounts from different drawer to show the summarized report.
    Scenario. in the Chart of Accounts we define different account number and name.The account may be title or active account.If i define an external code which can be duplicated for different accounts in multiple drawers,can i see a report which can group accounts based on these external codes.
    I think it can be done with financial report template but if i choose B/S template i can't group profit/loss account similarly P/L template i can't chose
    Please suggest the solution
    Thanks and Regards
    md.nazeer shaikh

    Thanks Gordon,
    but is it possible in XL reporter to take the accounts from different drawer like in Indian locality 5 drawers are available.from all the five drawer can i pick the accounts or just 3 drawers in case of BS and two drawers in case of PL
    regards
    md.nazeer shaikh

  • Include external code with some protected way ?

    Hello, I would like to know, how it is possible to put C++ code into LabView with secure way.
    I tried it with creating .dll and in LabView call it with Call Library Function Node, but the .dll returns one value True or False and it is possible to crack it. Thats why I am looking for another solution.
    Thanks for answers.

    Well, using a trivial interface makes it trivial to crack it. You should consider some challenge response interface instead. Pass some random value to the DLL and let it execute some calculations on it, then read the value back and check that you get the same value using the same algorithme. Definitely won't help against someone who can disassemble the DLL, but then nothing will really help against disassembly.
    There is no other way to integrate external code into LabVIEW than shared libraries (all platforms) and ActiveX and .Net (Windows only).
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • PDA: How does the VI in the "Calling External Code (Inline C Method)" example link to the called functions?

    The PDA module provides an example of calling external code via an inline C
    The inline source code from the example:
         OSVERSIONINFO info;
         info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
         Err = GetVersionEx(&info);
         MajorVersion = info.dwMajorversion;
         MinorVersion = info.dwMinorversion;
    The PDA build specification includes *no* additional source files of any kind.  The only source file in the build is the top-level VI.  Where are the definitions for the OSVERSIONINFO type, and the GetVersionEx function drawn from?
    The VI builds and runs fine on the PDA, but I don't understand how.

    Donovan B wrote:
    Hi Dan,
    It looks like there is an OSVERSIONINFO struct and GetVersionEx function available in the coredll.lib for the application to call on a PDA running Windows Mobile 5.0.  On both operating systems, it looks like the GetVersionEx function is defined in winbase.h, so I am not sure if there is some kind of linking between the two or if the header file is automatically included when building the executable or not.  Let me do some more research and I'll let you know.
    The information for the function on Windows Mobile can be found here.
    Message Edited by Donovan B on 12-19-2007 06:33 PM
    While the API functions are mostly the same for Windows Mobile and normal Windows the actual implementation and compilation is obviously not and there is no need for that. Windwos Mobile is typically (not sure if there are other versions at all) ARM based, while the desktop version is x86 based. A huge difference.
    And when LabVIEW creates a PDA executable it mostly creates a bunch of hidden C files, invokes the Visual C for Windows CE
    tool chain and lets it create the executable. The Visual C for Windows CE tool chain comes with its own import link libraries for accessing WinAPI functions and those import link libraries reference the functions in the DLLs as they are implemented for Windows Mobile (CE). There is no kernel32.dll in Windows Mobile and why should it? You can't move normal Windows code that would expect that DLL to Windows Mobile anyhow, since it has a completely different CPU and there is always a complete recompile with the Windows CE toolchain necessary anyhow.
    Rolf Kalbermatter   
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • SO Wait causes exception occurred within external code called by call library node

    when trying to run some old code that used to work ok, i now get this error message:
    exception occurred within external code called by call library node
    and the vi flagged as calling the exception is SO Wait. the error occurs with different soundcards. does anyone know what is causing this problem?

    Hi Kreuters
    It sounds as if you have a case of memory corruption. Which version of LabVIEW and DAQ (traditonal or DAQmx) are you running and also on which operating system?
    would it be possible for you to post your VI on this thread? in some cases there are ways to fix the problem
    Regards
    YatinM
    NIUK

  • Can you call external code from XE?

    Hi,
    I have an application that uses external code, called via extproc. During a standard Oracle installation, I need to modify the listener configuration to allow it to do so. This is done by modifying listener.ora like follows:
    SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC =
    (SID_NAME = PLSExtProc)
    (ORACLE_HOME = C:\oracle\ora10_2)
    (PROGRAM = extproc)
    (ENVS = "EXTPROC_DLLS=ANY")
    without the 'ENVS' entry, the listener security prohibits the loading of our code.
    The touble I have on XE is that attempting to restart the listener after this change gives an error:
    TNS-01155: Incorrectly specified SID_LIST_LISTENER parameter in LISTENER.ORA
    NL-00303: syntax error in NV string
    Does this mean that external code cannot be used? or does anyone know a workaround?
    Thanks in advance,
    Jim

    One obvious problem is the missing close paren, seen when you reformat as follows:
    SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC =
    (SID_NAME = PLSExtProc)
    (ORACLE_HOME = C:\oracle\ora10_2)
    (PROGRAM = extproc)
    (ENVS = "EXTPROC_DLLS=ANY")
    ) <--- this is missing

  • Error "An exception occurred within the external code..." when stopping LabView

    I am having an error "An exception occurred within the external code called by a Call Library Node...", see the attached image, when I am trying to stop LabView. As a result of the error, the tag engine doesn't close normally.
    I am using LabView 7.1 with DSC. I read values from a LNS (LON) OPC-server.
    Is this a known issue and is there any way to repair it? I haven't noticed any direct consequences because of the error except that when I re-start LabView and the close it again without having first rebooted the computer, tag engine sometimes starts again when it should stop. This is fixed by always rebooting the computer before restarting LabView. I am getting suspicious that there might be some strange behaviour because the error says "it might have corrupted LabView's memory".
    For example, sometimes when I have made a copy of an input number field to another, they follow each other's value changes even though there is no connections between them.
    Simo Martikainen
    Message Edited by Simo Martikainen on 12-17-2008 03:11 AM
    Attachments:
    LabView stop error.JPG ‏45 KB
    TAGENGINE.JPG ‏16 KB

    Especially in earlier versions of LV these sorts of errors were common if the call wasn't made just right or the parameters were set up incorrectly.
    Where did you get the DLL from? Was it written internally or did it come from another vendor?
    Try building a DLL call into a very small, simple application. Do you see the same issue?
    Are there multiple calls to the same DLL in your code? If so, is there problems with all of them?
    Can you track it down to a specific function that you are trying to access that is causing the problem?
    Is there any indication of a memory leak?
    Finally any additional information you can provide would helpful.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • An exception occured within the external code called by a Call Library function Node

    Good Morning,
    I built a VI that contains Matlab nodes in Labview 8.0.  I made an executable and gave it to a colleage to use who is running Windows XP.  I see in the folder C:\Program Files\National Instruments\Shared\LabVIEW Run-Time that she has 7.1 and 8.0 run time engines installed.
    On Friday the executable ran great on her machine.  Today, when she tried running it I received the following error.  "LabVIEW:  An exception occured within the external code called by a Call Library Function Node.  This might have corrupted LabVIEW's memory.  Save any work to a new location and restart LabVIEW.  'my vi' was stopped at node 0x0 of subVI "NI_AALBase.lvlib:Real A x B.vi:1".  This error occured after part of the program ran properly.  More specifically, two of the matlab nodes ran perfectly.  I am unsure about the third because the program stopped too early.  I do have to multiply two matrices using the subvi Real A x B.  Is this causing the error?
    I also saw this error when I installed it on another computer.  However I do not see this error when I run the executable or the main vi on my machine  I know there are other discussions on this topic, however I do not know why it would affect some machines and not others.  Also, I do not know why it would work on Friday and not on Monday.  Should I have checked the box that said "Enable Debugging" under the advanced section when building the executable?
    If anyone could help, I would be very appreciative.
    Thanks,
    -Richard

    molecularvisions wrote:
    Good Morning,
    I built a VI that contains Matlab nodes in Labview 8.0.  I made an executable and gave it to a colleage to use who is running Windows XP.  I see in the folder C:\Program Files\National Instruments\Shared\LabVIEW Run-Time that she has 7.1 and 8.0 run time engines installed.
    On Friday the executable ran great on her machine.  Today, when she tried running it I received the following error.  "LabVIEW:  An exception occured within the external code called by a Call Library Function Node.  This might have corrupted LabVIEW's memory.  Save any work to a new location and restart LabVIEW.  'my vi' was stopped at node 0x0 of subVI "NI_AALBase.lvlib:Real A x B.vi:1".  This error occured after part of the program ran properly.  More specifically, two of the matlab nodes ran perfectly.  I am unsure about the third because the program stopped too early.  I do have to multiply two matrices using the subvi Real A x B.  Is this causing the error?
    This is most likely an error with the use of the Call Library Node, but not in the Real A x B.vi itself. This is a VI that comes with LabVIEW and has been tried and tested many times and unless your LabVIEW installation is messed up simply shouldn't fail in such a way on its own.
    However you do include Matlab code somewhere and that might be more likely to cause this. Are you using the built in MathScript node or some other way to communicate directly to a Matlab DLL or such?
    Are you using anywhere Call Library Nodes that you have created or that did at least not come standard with LabVIEW?
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Add an external code in Adobe Edge

    I would like to add an external code in Adobe Edge, tried a few options and still having trouble.
    How do I add the following code in Rectangles?
    <div id="cont_2cc55146a3764e86d9f22ec81a15bf4c">
    <span id="h_2cc55146a3764e86d9f22ec81a15bf4c"> Moscow Time </ span> <script type="text/javascript" src="http://www.tempo.com/wid_loader/2cc55146a3764e86d9f22ec81a15bf4c"> </ script>
    </ div>
    * It is a weather forecast.

    Hell0,
    I did this example a long time ago. Maybe this could help you.
    https://www.box.com/s/ygym12tza9s9x2gfrgja

  • External code

    Hallo,
    I a complex program I havo to improve I found a "link" to external code called "lm_fit.lsb". Does anybody know where I can find that code? A file with that name does not exist.
    Arno

    Arno;
    The .lsb refer to a CIN node in one of your VIs. You need to contact the developer of that VI to give you the .lsb file.
    Regards;
    Enrique
    www.vartortech.com

  • Dreamweaver crashes when loading external code or files.

    Dreamwever CC crashes when I paste code retrieved from an external source (hubspot template, html source files, etc).
    If the code contains live links to certain servers (jquery on Google, etc) then Dreamweaver takes a lot to load and often crashes.
    I have a very powerful PC config, so the hardware is NOT responsible for this behavior.
    Here is what I did so far:
    - I applied the register fix (ResolveRemoteURLToIPAddress = FALSE)
    - unchecked "Enable Related Files"
    - unchecked View > Style Rendering > Display Styles
    - unchecked "Automatically Sync Remote Files"
    - blocked Dreamweaver from accessing the net in my firewall
    The damn thing is still crashing and the only solution is to disable / manually remove the internet cable from the PC.
    Any help or advice is highly appreciated.

    Try putting links to external scripts, servers, etc... into a server-side include.  It works for me.
    Nancy O.

  • TCP open connexion (code 87)

    Bonjour à tous,
    j'essaye désespérement d'établir une connexion TCP entre un compact RIO et un Touch Panel (pour le moment j'essaye tout simplement d'établir la connexion entre le PC hôte et le Touch Panel.
    Cependant, je lance les VI des deux côtés et lorsque le VI serveur est lancé, j'ai juste à appuyer sur un bouton sur le VI client pour lancer la connexion. Cependant, l'erreur suivante s'affiche :
    code : 87
    source : TCP open connexion
    Quelqu'un saurait d'où cela vient?
    Je vous joins mes VI serveur et client
    Résolu !
    Accéder à la solution.
    Pièces jointes :
    tcpmsgprotocolhmi.llb ‏137 KB

    C'est boon la connexion se fait sans problème!

Maybe you are looking for