Pass Cluster into LabVIEW Generated DLL using __cdecl

I'm using a DLL generated with LabVIEW 7.1 to calculate IIR filter coefficients in a application I'm writing in C++. The DLL contains several different functions. The function prototype in question looks like this:
long __cdecl ButterworthCoefficients(unsigned long filterType,
double samplingFreqFs, long order, double lowCutoffFreqFl,
double highCutoffFreqFh, TD1 *IIRFilterCluster);
where "TD1" is an output that contains the IIR filter coefficients generated by the function. TD1 looks like this:
typedef struct {
unsigned long filterStructure;
TD2Hdl ReverseCoefficients;
TD2Hdl ForwardCoefficients;
} TD1;
TD2Hdl is a handle to a 1-D array containing doubles.
My question relates to how to pass the TD1* parameter into the function. If I simply declare TD1 and leave it uninitialized and pass it's address to the function I get a windows access violation read error. So I assume I have to create and populate the entire TD1 structure in my C++ source file, allocating memory for the arrays, before passing the TD1 address to the function. When I try to do that I get a LabVIEW error "Fatal Internal Error memory.cpp, line 638".
Any ideas on how to make this work?

Ok, I fixed my problem. I had to set the TD2Hdl elements in the TD1 structure to NULL before passing the TD1 address to the function. I think this makes sense because if you look at the Butterworth Coefficient.vi that I used to generate the DLL, the inputs to the CIN in that VI's block diagram are empty arrays. So I guess by setting the TD2Hdl elements to NULL, it tells LabVIEW that you are giving it an empty array, which is what the CIN was expecting.
Hopefully this helps anyone else who has this same sort of problem.

Similar Messages

  • Question about LabVIEW generated DLL's

    Hello,
    I want to try programming games in either JAVA or FLASH.
    What I want to know is if I can use the LabVIEW generated DDL's for use in my games, without having to need the LabVIEW runtimes installed.
    (in other words, are the LabVIEW generated DLL's, stand alone DLL's as generated in for example C/C++ or other programming languages?) 
    Second, how good is LabVIEW in converting it's code into a DLL. Can I make complicated algorithms, or are just simple functions allowed.
    Hope you guys can spare a few words on this topic.
    Sincerely,
    Heinen  
    The Enrichment Center is required to remind you that you will be baked, and then there will be cake.

    Hello dan_u and thank you for your quick reply.
    If the LabVIEW Runtimes are needed to use the DLL's, that is not a good option for me then. I eventually want to distribute my games over the internet, and having to sent the LabVIEW runtimes with the games is just not an option.
    To bad, I'm better in programming stuff in LabVIEW then in writen C++ like code.
    Sincerely,
    Heinen 
    The Enrichment Center is required to remind you that you will be baked, and then there will be cake.

  • How pass VISA resource string from C++ as uintptr_t* to a LabVIEW generated DLL ?

    My coworker build a DLL from LabVIEW that I am trying to call from C++.
    void__cdeclMeasureDCvolts(uintptr_t*VISAResourceName, int32_tChannelNumber,LVBoolean*MonitorResult,double*MeasuredVoltage, TD1*errorOut);
    Does "extcode.h" define macros or functions for string conversions?  Or should I request my coworker rebuild the VI's to make arguments more C/C++ friendly?
    Thanks in advance for any tips or direction.  Examples are * much * appreciated.
    -Ed
    TestObjectMeasurement* testObjectMeasurement = m_measurementMap[name];
    TestObjectInstrument* testObjectInstrument = m_instrumentMap[selectedInstrumentName];
    int slot = 1;
    int bank = 1;
    int channel = 1;
    int channelNumber = 1000 * slot + channel;
    char * visaResourceName = testObjectInstrument->visaResourceName().toLatin1().data();
    LVBoolean monitorResult = LVBooleanFalse;
    double measuredVoltage = -1.0;
    TD1 errorOut = {0};
    try
    // void __cdecl MeasureDCvolts(uintptr_t *VISAResourceName,
    // int32_t ChannelNumber, LVBoolean *MonitorResult, double *MeasuredVoltage,
    // TD1 *errorOut);
    MeasureDCvolts(reinterpret_cast<uintptr_t*>(visaResourceName), channelNumber, &monitorResult, &measuredVoltage, &errorOut);
    catch(...)
    qDebug() << "Exception thrown by: MeasureDCvolts";
    QString errorSource = QString::fromUtf8(reinterpret_cast<const char*>(LHStrBuf(errorOut.source)), LHStrLen(errorOut.source));
    qDebug() << errorSource;
    LStrHandle errorTextHandle = {0};
    bool foundErrorText = NIGetOneErrorCode(errorOut.code, &errorTextHandle);
    if(foundErrorText)
    QString errorText = QString::fromUtf8(reinterpret_cast<const char*>(LHStrBuf(errorTextHandle)), LHStrLen(errorTextHandle));
    MessageHelper::messageError(errorText, errorSource);

    Why is it not a solution? It was exactly about what you wanted to do and the solution in the last post is how it can be made to work. There is NO way to ddirectly create a LabVIEW native VISA resource in C code that is not called from within LabVIEW, unless you consider hacking the LabVIEW system and using undocumented functions a solution. But that has very good chances of breaking with future LabVIEW versions.
    Your only other option is to export another function from the DLL that accepts a String and uses VISA Open to explicitedly open the VISA session in your LabVIEW DLL and returning that VISA session to your C code. This is functionally equivalent to passing a String to your current function but avoids the lookup and potential recreation of the VISA refnum on each call. Something I would only feel bothered if you intend to call this function many thousend times each second, which for VISA communication seems very unlikely.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Passing files into labview vi by opening the file

    I have a labview exe that is installed on XP that can create/save files with an extension not recognized by windows. The files can be opened from within the exe but what I want is to double click(open) the file from explorer/desktop and have it opened in my vi. I know how to associate the file with windows so opening it will open the exe, but how do I pass this argument into my exe so my app can use it?

    Us the "Application:command line" property, see attached code image.
    When building the application, make sure to check "Pass all command line arguments to application" in the builder.
    When your associated file is double-clicked, the application will open and have the file name of the double-clicked file as second element (#1) in the commandline array. (You can also drop any file on the application in explorer and it will open with the dropped file name in that position.)
    Also check the online help under index: "Command Line Arguments (Application property)"
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    commandline.gif ‏3 KB

  • Pass array to "Labview 7" DLL in Visual Basic

    Hi!
    I would like to pass arrays in Visual Basic to a LV DLL made in Labview 7.
    I've seen the examples of NI to create a dll in Labview for Visual Basic and for passing arrays, but all the examples were made with Labview 6.
    The problem is that in the tutorial they say to define the Pass By of the argument as Array Data Pointer, but in Labview 7 when I add an array as an argument I don't have that option.. It's always defined as TD1Hdl* inArray, and in Labview 6 it was defined as float64 inArray[].
    Can I use the TD1Hdl structure in Visual Basic? How do I use it?
    Thanks!

    Unfortunately, i'm not expert in Visual Basic, i need to investigate in your problem.
    See link below, that explain how you can use LabVIEW DLL in Visual Basic.
    http://venus.ni.com/stage/we/niepd_web_display.DISPLAY_EPD4?p_answer=&p_guid=B45EACE3D9E556A4E034080...
    http://forums.ni.com/ni/board/message?board.id=170&message.id=100151&requireLogin=False
    http://zone.ni.com/devzone/devzoneweb.nsf/Opendoc?openagent&4303F9807BFE234486256906007259EF
    Regards,
    Christophe S.
    FSE East of France І Certified LabVIEW Associate Developer І National Instruments France

  • How to pass variable into lov sql query using like operator

    hi.
    i want to use a lov where i want to pass a variable using like operator.
    my query is
    select empno,name from table where empno like ':ed%';
    my empno is A001 TO A199 AND B001 TO B199 so i want show either A% or B% empno
    how can i do this ?
    reagrds

    kindly press Shift+F1 at a time you face this error to see the exact Oracle error message.
    and provide us with that detail
    and its better if you start new topic for that error... because that will be new error,,,
    -- Aamir Arif
    Edited by: Aamiz on Apr 7, 2010 12:27 PM

  • How to solve these Errors when generating .dll (using JNI) ?

    Hello,
    I am very new about JNI. As I have been trying to generate my dll (sysHook.dll) as I followed this topic http://forums.sun.com/thread.jspa?threadID=632369 (by Jbgohlke ) by putting this command:
    cl -I"C:\Program Files\Java\jdk1.6.07\include" -I"C:\Program Files\Java\jdk1.6.07\include\win32" sysHook.cpp -FesysHook.dll Then many errors are popped up as follows:
    sysHook.obj :error LNK2019: unresolved external symbol __imp__CallNextHookEx@16 referenced in function "long__stdcall HookKeyboardProc(int,unsigned int,long)" (?HookKeyboardProc@@YGHIJ@Z)
    sysHook.obj :error LNK2019: unresolved external symbol __imp__SetWindowsHookExA@16 referenced in function " void__cdecl Init(void)" (?Init@@YAXXZ)
    sysHook.obj :error LNK2019: unresolved external symbol __imp__UnHookWindowsHookEx@4 referenced in function "void__Cleanup(void)" (?Cleanup@@YAXXZ)
    sysHook.dll : fatal error LNK1120: 3 unresolved externals
    If anyone of you know this PLEASE!! point me out!!
    [email protected]
    Thanks in advance

    Specify the appropriate library when linking.
    This is not a JNI question. It is a Windows/C/C++ programming question.
    Locking this thread.

  • Passing parameter into select statement by using function in discoverer

    I have created two functions in database named Period_in and Period_out and a global variable  g_period_name
    I have called Period_out function in VIEW(Select statement where condition).
    I have registered Period_in function in discoverer admin then created calculation (called Period_in(:input parameter))in discoverer plus.
    My expectation is user will enter period name and that will hit Period_in function and returns 1 and stores entered period name in g_period_name at runtime. then VIEW will executed and fetches data.
    But i am getting no data found.
    Problem is 2 functions running at the same time in select statement. Please help me to overcome this. Thanks in advance
    FUNCTION period_in (p_period VARCHAR2)
          RETURN NUMBER
       AS
       BEGIN
          g_period_name := p_period;
          RETURN 1;
       END period_in;
       FUNCTION period_out
          RETURN VARCHAR2
       AS
       BEGIN
          RETURN g_period_name;
       END period_out;

    You can use this code: 
    WITH cte
    AS ( SELECT EmpID ,
    EmpName ,
    [dbo].[udf_testFunction](EmpID) AS testfunctionvalue
    FROM #Temp
    SELECT EmpID ,
    EmpName ,
    testfunctionvalue ,
    testfunctionvalue * EmpID ,
    testfunctionvalue + 2
    FROM cte
    But using scalar functions in select clause can hurt the performance. Please see this link: 
    SQL Server Scalar User Defined Function Performance
    T-SQL Articles
    T-SQL e-book by TechNet Wiki Community
    T-SQL blog

  • Turning a LabVIEW built DLL into an ActiveX server

    Does anyone have a list of the steps you must go thru
    to convert a LabVIEW generated DLL into an ActiveX server. Do the functions become methods?

    Hi James,
    we have a library we deploy in three ways: as a LabVIEW library, as a DLL and as Active-X server.
    In the build file for the DLL we have made each "function to call" a top level VI.
    In the Active-X server each "function to call" is a dynamic VI. We created a new top level VI which will run when the server is started and stops after his window is hidden. In LV 6.x you need the winutil library to hide the window. If you close the window (through FP.Open set to FALSE) the server will stop. The window size is set to 1x1 in the VI Properties to minimize flickering on the screen during start of the Active-X server. You must check the "Enable Active-X Server" box on the "Application Settings" page in the app builder. In your client application yo
    u open a reference to the server and then you can open a reference to the VI. You set/read the controls and run the VI. There is sample code for Visual Basic on the NI web site. I have also sample code for Visual C++ single and multi threaded clients.
    If you are interested in the examples contact me at [email protected] and I will ask my customer to allow me to send it to you.
    Waldemar
    Waldemar
    Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
    Don't forget to give Kudos to good answers and/or questions

  • Importing and displaying DXF files into Labview

    Dear all,
    Building an application for motion control, I want to import a DXF file into labview to be used as a template for the motion. For verification I would also need to display it. I cannot use ActiveX properly bcse I develop on Mac....
    If you have any idea or experience on how I might do this, I will be glad to hear from you !
    Thanks in advance !
    Regards,

    To display (not parse) DXF files and other CAD file formats (PRT, SLDASM, SLDDRW, SLDPRT) I've been using an ActiveX container with the EModelViewControl object from the free SolidWorks eDrawings. Use the OpenDoc method to display the file in the container (see attached snippet).
    - Philip Courtois, Thinkbot Solutions
    Attachments:
    eDrawings snippet.png ‏21 KB

  • How to generate and use Matlab(R2007) .dll's in Labview

    Is there a step-by-step example on how to generate and use Matlab(R2007)  .dll's in Labview.
    Our experimenal hardware is LabView-controlled and we want to pass
    images/2d intensity arrays to a more complex matlab program that will
    return an array of extracted data which we want to use in LabView again.
    Thank you
    Carsten

    I recommend having a wrapper created around the matlab dll that converts the datatypes for you. There is a lot of fooling around with pointers involved which is very difficult in LabVIEW. btw, this got much more complicated after Matlab 7. Essentially, you need to convert your inputs into mxArrays, and then add those mxArrays to an mxArray list that you pass by pointer into the matlab dll. You also need to create a mxArray list for the outputs from the dll which you will need to extract your data out of before converting it back into a LabVIEW supported datatype. It's a big hassle. We do this pretty often, but we have created a c library that handles all the conversions, so it is feasible for us. Unfortunately, I can't share the library, but hopefully this information will help you get where you want to be.
    Like I said, it would be easier if you can just get a c developer to write a wrapper for you to keep it simple in LabVIEW. Alternatively, you might try getting your m-code to work in Mathscript.
    Chris

  • Pass error cluster from labview dll to teststand

    Hello,
    I just want to pass an error cluster from a dll compiled in LV7.1 to TestStand 3.1. I never receive the contents of the LV error cluster in TS. I compiled my function with standard calling convention option, this should work. In my VI I generate only an error and pass to error output.
    LV Settings:
     TS settings:
    regards
    MB

    MB,
    please follow the info in this KB:
    http://digital.ni.com/public.nsf/allkb/22BF02003B4588808625717F003ECD67?OpenDocument
    Please note that using "By Value" will never return any values to TestStand!
    You cannot use the default error-container in TestStand to receive data from the LV error cluster if you compile the VI into a LV DLL.
    So either you choose to follow the KB or you split up the error cluster in your LV VIs to return error.occurred (boolean), error.code (numeric i32) and error.msg (LV String) .
    hope this helps,
    Norbert
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.

  • Can I automate the creation of a cluster in LabView using the data structure created in an autogenerated .CSV, C header, or XML file?

    Can I automate the creation of a cluster in LabView using the data structure created in an auto generated .CSV, C header, or XML file?  I'm trying to take the data structure defined in one or more of those files listed and have LabView automatically create a cluster with identical structure and data types.  (Ideally, I would like to do this with a C header file only.)  Basically, I'm trying to avoid having to create the cluster by hand, as the number of cluster elements could be very large. I've looked into EasyXML and contacted the rep for the add-on.  Unfortunately, this capability has not been created yet.  Has anyone done something like this before? Thanks in advance for the help.  
    Message Edited by PhilipJoeP on 04-29-2009 04:54 PM
    Solved!
    Go to Solution.

    smercurio_fc wrote:
    Is this something you're trying to do at runtime? Clusters are fixed data structures so you can't change them programmatically. Or, are you just trying to create some typedef cluster controls so that you can use them for coding? What would your clusters basically look like? Perhaps another way of holding the information like an array of variants?
    You can try LabVIEW scripting, though be aware that this is not supported by NI. 
     Wow!  Thanks for the quick response!  We would use this cluster as a fixed data structure.  No need to change the structure during runtime.  The cluster would be a cluster of clusters with multiple levels.  There would be not pattern as to how deep these levels would go, or how many elements would be in each.   Here is the application.  I would like to be able to autocode a Simulink model file into a DLL.  The model DLL would accept a Simulink bus object of a certain data structure (bus of buses), pick out which elements of the bus is needed for the model calculation, and then pass the bus object.  I then will take the DLL file and use the DLL VI block to pass a cluster into the DLL block (with identical structure as the bus in Simulink).  To save time, I would like to auto generate the C header file using Simulink to define the bus structure and then have LabView read that header file and create the cluster automatically.   Right now I can do everything but the auto creation of the cluster.  I can manually build the cluster to match the Simulink model bus structure and it runs fine.  But this is only for an example model with a small structure.  Need to make the cluster creation automated so it can handle large structures with minimal brute force. Thanks!  

  • How can I get an unsigned char string with nulls from a dll into LabVIEW 6i?

    The following ethernet packet data is contained in an unsigned char * string returned from my dll (it's formatted on printing):
    Received A 230 Packet On Adapter 0x008F0070
    Ethernet Dest: 01.E0.BB.00.00.15 Src: 00.E0.BB.00.DD.CC Type: 0x8868
    000000: 01 E0 BB 00 00 15 00 E0 : BB 00 DD CC 88 68 48 41 .............hHA
    000010: 00 E0 BB 00 DD CC 80 B3 : 00 00 FF FF 00 02 00 01 ................
    000020: 01 00 F0 18 FF 7F 7F FF : FF 7F 7F FF FF 7F 7F FF ................etc., etc.
    However, when I read this string into LabVIEW 6i, I only get the following:
    01E0 BB
    Which is the data before the first NULL or 00 information. I found a "Remove Unprintable Chars.vi" but it
    just sees more data before the above string, nothing after, as seen here: 5C30 31E0 BB.
    Anybody have any suggestions for how to get the rest of the string? Is there something I can do to further reformat my dll? The dll I'm using is already a wrapper around another dll so I have some flexibility, but the bottom line is, the data I want is in the format of an unsigned char *.

    Excellent advice, this mostly works so I have some further questions:
    I am just reading network traffic off my ethernet card right now, but here is what I get using my C program to test:
    000000: 01 E0 BB 00 00 15 00 E0 : BB 00 DD CC 88 68 48 41 .............hHA
    000010: 00 E0 BB 00 DD CC 80 B3 : 00 00 FF FF 00 02 00 01 ................
    000020: 01 00 38 3C FF 7F 7F 7F : 7F 7F 7F FF FF 7F 7F FF ..8<............
    000030: FF 7F 7F FF FF 7F 7F FF : 7F 7F 7F FF FF FF FF FE ................
    000040: FE FF FF FF FF 7F 7F 7F : 7F 7E 7E 7F 7F 7E 7E FF .........~~..~~.
    000050: 7F 7F 7F 7F FF 7F 7F 7F : 7F 7F 7F FF FF 7F 7E 7F ..............~.
    000060: 7F 7F 7E 7F 7F 7E 7F FF : FF 7F FF FF FE FF FF FE ..~..~..........
    000070: FF FF FF FF FF 7F 7F FF : FF 7F 7F FF FF FF FF FF ................
    000080: FF 7F 7F FF FF 7F 7F FF : FF 7F 7F FF FF 7F 7F FF ................
    000090: FF 7F 7F 7F FF 7F 7F 7F : 7F 7F 7F FF FF 7F 7F FF ................
    0000A0: FF 7F 7F 7F 7F 7E 7E 7F : 7F 7F FF FF FF FF FF FF .....~~.........
    0000B0: FF FF 7F FF FF 7F 7F FF : 7F 7F 7F FF FF 7E 7F FF .............~..
    0000C0: FF FF 7F FF FF 7F 7F FF : 7F 7F 7F FF FF 7F 7F FF ................
    0000D0: FF 7F 7F FF FF 7F 7F 7F : 7F 7F 7F FF FF FF FF FE ................
    0000E0: FE FF FF FF 00 01 : ................
    And here is what I get using LabVIEW to call the dll:
    0015 00E0 BB00 DDCC 8868 4841 00E0 BB00 DDCC 80B3 0000 FFFF 0002 0001 0100 9600 7F7F 7F7E 7F7F 7F7F 7F7F 7F7F 7F7F 7F00 B405 4300 3300 0000 0000 0000 01E0 BB00 0015 00E0 BB00 DDCC 8868 4841 00E0 BB00 DDCC 80B3 0000 FFFF 0002 0001 0100 9600 7F7F 7F7E 7F7F 7F7F 7F7F 7F7F 7F7F 7F00 F405 1B04 0C04 0000 0000 0000 8000 0000 0000 0000 0800 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
    The first thing I notice is that the first 4 bytes are chopped off, and after about 50 bytes, the data is corrupted until the sequence starts to repeat, but this time it starts with the missing 4 bytes and still corrupts after about 55 bytes.
    I am expecting the data in LabVIEW to look very similar to the C data because the network packets I am grabbing are pretty consistant, only a couple bytes will vary between them, not the number I am seeing in LabVIEW.
    Another side effect I'm seeing is that I can only run my labVIEW code once, if I try running it again it crashes with failures such as:
    memory could not be "read"
    For reference, I am opening and closing the network adapter inside the read function of my dll, but the pointer seems like it should be intact...
    Attachments:
    zListAdapters.vi ‏30 KB
    listAdapters.dll ‏201 KB
    Reading.dll ‏213 KB

  • Creating a LabVIEW Shared DLL for use with C# and Strings?

    Hi All,
    I am trying to create a prototype for a LabVIEW Shared DLL that all the VI does is take in a string and return an upper cased string. Needless to say the DLL builds fine but when I try calling the shared DLL from C# the .NET application recieves an exception about "Ansi char arrays can not be marshaled as byref or as an unmanaged-to-managed parameter". Does anyone have an example of how to pass a string to a VI and return a string or an example of a better way of accomplishing this.
    We are using labVIEW 7.1 on Windows 2000.
    I am in quite a bit of a hurry to prove that this type of a LabVIEW Shared DLL VI would work. The eventual system will be passing in a string of XML with a large amount of
    data and returning XML.
    Thanks in advance,
    Jim

    Hello jprucha,
    This occurs because LabVIEW DLLs are not considered managed code. As such, we need to define the C# function as unsafe to be able to call unmanaged DLLs.
    You can find more information about C# and managed code at Microsoft's developer website linked below.
    MSDN Home Page
    Good luck with the development,
    Matt F
    Keep up to date on the latest PXI news at twitter.com/pxi

Maybe you are looking for

  • Structure of our Active Directory

    Hi All, We have following active directory structure in our organization. I am not sure, if this is a flat or deep hierarchy. We have domain(forest)as xyz.com. we have a group created SAP under OU=Applications,DC=xyz,DC=com. All our users accessing P

  • Scam Another Robo-call claiming to be VZW

    Be careful people Phone calls have been going out from a scammer claiming that if you log onto www.my45verizon.com you can get a 45.00 credit on your bill, THIS IS A SCAM A ATTEMPT TO GAIN ACCESS TO YOUR VZW INFORMATION.................... BEWARE ...

  • How do I get Creative Cloud to launch on my Windows 7 Computer?

    I recentley downloaded Adobe Creative Cloud but for some reason it doesn't work. I have tried reinstalling it many times and claimed updated versions on the forum but it still will not open. If anyone knows how to fix this, please help me out. Thanks

  • Snow Leopard for Early Intel iMac 2006 - Worth it?

    I was curious.... I wonder if anyone could tell me if going to Snow Leopard from Tiger on a mid 2006 Intel iMac would be worth the money and trouble. The upgrades on some of my apps are tempting, but would there be a significant difference in perform

  • Value date issue

    hi, can u please tel me where we have to configure the value date in fi ?