Export typedef struct / typedef enum

Hi,
Is there any way to export typedef struct from a C DLL to LabVIEW (so that it is refered to under 'type' when using the Call Library function?
Also, is there a way to export typedef struct?
Thanks.

Probably not.
Not sure if it's an issue anymore, but at one time the number one issue was the endian-ness. 
On top of that is fundamentally different handling of arrays: C arrays are just pointers, while LabVIEW arrays are smarter, containing the size of the dimension(s) within them.
Strings are likewise.
The configuration panel in CAL LIBRARY can handle some of these issues, but it has to be broken down into fundamental parts.
No way I know of to match an arbitrary structure in both languages. 
Message Edited by CoastalMaineBird on 06-19-2009 05:27 AM
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com
Blog for (mostly LabVIEW) programmers: Tips And Tricks

Similar Messages

  • Programmatically controlling strings in typedef enum

    Hi there,
    on an user interface I want to offer a typedef enum as a pulldown menu to select plugins that are dynamically loaded from a subdirectory. Whenever a new plugin is copied into this directory, the enum menu shall be updated automatically. Yes, I have already searched the forum and found an older thread where they write that enums cannot be altered programmatically. Isn't there really any workaround?
    See the attached example vi. I want to use the enum instead of a ring menu because with the typedef enum the case structures are automatically extended if the enum itself grows.
    Any hint on how to program such "auto update features" most elegantly?
    Thanks,
    Peter
    Attachments:
    autoupdate_of_enum2.zip ‏20 KB

    Hi Peter,
    i think it is not possible in this way. Who should insert the new function into your case structure?
    Use a combobox/ring and an event strucure. If the user change the value of the combobox/ring, build the path to the selected vi.
    See the attached example.
    Mike
    Message Edited by MikeS81 on 06-02-2008 02:03 PM
    Attachments:
    main_LV80.vi ‏16 KB

  • Ring -- typedef enum

    Hi all!
       after years of inactivity on this board.... here I come again!
       I have some "typedef enum", and I'd like to tie them at develop time to Ring controls.  Is it possible?
       Thanks!
    Graziano

    Graziano:
    Welcome back!
    Do you mean that you want to assign enum values to your ring items?
    You can do that if you build the list for your ring in code, not in the UI editor.  In the UI editor, just put down an empty ring, then in your code, before you display the panel, build the ring list using InsertListItem(), specifying an enum as the value.  An enum is basically an int, which is the default data type for items in a ring control.  See the CVI Help topic titled Programming with ring controls for more details.

  • Just checking on another odd feature: Typedef enum Property Node "Value" not reflecting changes in the Typedef?

    Just encountered this odd behavior in LV 2011 which I reduced to the following example:
    - create a new VI and drop an enum control on te FP.
    - make this control a typedef and open the corresponding typedef
    - create a "case 1" item and a "case 2" item
    - save the typedef (I used the name Typedef Control 1) and CLOSE it (this is to allow updating of the original control).
    - drop a case structure on the diagram and connect the enum to it:
    So far so good. Now create a "Value" Property node for the enum and use it instead of the terminal:
    If I now go back to the typedef and add a "case 3" item, save the typedef and close it, the control is updated, but the Property node is not.
    How do I know that? For one, the Case Structure contextual menu does not offer to create a case for every value. Also, if I add a "case 3" case manually, it turns red.
    Luckily, the magic Ctrl-R key stroke actually does solve this problem.
    Tested in LV 2011.

    By Ctrl-R trick do you simply mean running the VI?  That is one way to force a recompile, but if you hold down Ctrl while pressing the run button you can recompile without running.  This should not be "dangerous" in any situation.
    As you have drawn your example, I see no reason not to use a local in that situation (ok, maybe for vanity).  Still, I view the behavior you describe as a bug, and it should certainly be fixed for the benefit of local haters out there.  You have to be a little careful where you draw the line between what gets handled in real time and what gets handled only at compile time.

  • Scripting Crash- "Create from Data Type" on Typedef Enum

    I just encountered a crash that I can duplicate in both LabVIEW 2013 and 2012 (student).
    Attached is a project that contains the code I used on 2012. Run the target VI.
    (I can get the project I had in 2013, if needed, sometime next week)
    Basic steps:
    Create a type def enum
    Place it on a VI
    Use scripting to get ahold of the Control Terminal and get the data type
    "Create from Data Type"

    Haha, I saved your code and ran it while I still had another project open... didn't really think that one through. Thank you, Auto-save.
    So it looks like the crash happens at the Create node. I can get rid of the crash by removing the Type Def link from the enum.
    I'm not at all an expert in scripting and have only used it a few times. Could a workaround be to get a reference to all of the Controls on the FP and copy the Control with the same Label "Enum" (instead of loading the terminal and creaing a new terminal)? Maybe creating a typedef by data type is what's causing the crash, but copying an already existing control will work.

  • Export Typedefs from TestSTand to LabVIEW

    Hi there,
    is there a possibility to simply export a typedef made in TestStand to LabVIEW? I want to prevent making the same definitions twice.
    Cheers
    Oli
    Programming languages don't create bad code, programmers create bad code....

    Hi Andre,
    that's what I feared importing cluster definitions from LabVIEW into TestStand is out normal way, unfortunately this time we have an exception to the habit 
    Thank you very much. Enjoy the public holiday
    Cheers
    Oli
    Programming languages don't create bad code, programmers create bad code....

  • REALLY NEED URGENT HELP with typedef struct char in LabVIEW

    Hi,
    So I am calling a DLL inside my LabVIEW VI.
    Inside the DLL, I have the following structure:
    typedef struct
          char string[21];
    } Geo_Tuple;
    Then I used it here in a function by calling:
    set_Geo_Coordinates(const File_or_Interactive State, const Input_or_Output Direction, const Geo_Tuple coordinates)
    (Note that File_or_Interactive and Input_or_Output are typedef enum.)
    So now, I am trying to implement this function in LV using the Call Function Node.
    However, it's not working --> const Geo_Tuple coordinates does not have the correct structure.
    So my question:
    How do I implement
    typedef struct
          char string[21];
    } Geo_Tuple;
    So that I can use it here: set_Geo_Coordinates(const File_or_Interactive State, const Input_or_Output Direction, const Geo_Tuple coordinates)
    Thanks!

    How have you configured your call library node?  To get a representation in LabVIEW of your Geo_Tuple type you'll need to create a cluster that contains 21 U8 elements, which you can do by creating an empty U8 array and wiring it to "Array to Cluster" set to 21 elements.  Connect this to the input side of the call library node.  On the output side, convert back to an array, and from there convert it to a string.

  • Typedef Error when compiling niScope for DLL using CVI

    I am getting the following error when trying to compile a DLL for the NI 5122 digitizer using CVI:
    Error creating type library:
    All structs, unions, and enums required by exported functions must be typedefs in order to create a type library. The struct/union/enum "niScope_wfmInfo" does not use such a typedef.
    I have created a variable and "typedefed" it as niScope_wfmInfo to try and get rid of this error. This did not work. I have tried making several other changes. Some have eliminated the error but created problems with the DLL.
    Has anyone had a similar error to this? If so, how did you get around it?
    Thanks,
    Heather

    Hi Heather,
    The reason that you are receiving this error is because the niscope.h file (called by niScope.fp) uses a struct which cannot be compiled into a DLL. This means that the niScope.fp file cannot be included in the target settings. Here's a knowledgebase that describes the error.
    http://digital.ni.com/public.nsf/websearch/AC028D9586E947F08625661E006A182F?OpenDocument
    If you do want the niScope.fp file to be included then you will need to make some modifications to the niscope.h file and create a typedef for the niScope_wfmInfo struct. Here's info from the help file that describes the type library section and the use of the .fp file.
    "Type Library—This button lets you choose whether to add a type library resource to your DLL. Also, you can choose to include links in the type library resource to a Windows help file. LabWindows/CVI generates the type library resource from a function panel (.fp) file. You must specify the name of the .fp file. You can generate a Windows help file from the .fp file by using the Generate Windows Help command in the Options menu of the Function Tree Editor window.
    This feature is useful if you intend for your DLL to be used from Visual Basic."
    If you do not include the niScope.fp file then you will be able to compile the DLL.
    Hope this helps! Let me know if you have any questions.
    Erick

  • Exporting ENUM definition to DLL header file

    I have a VI that takes an ENUM as an input to select a command to be performed. This VI is part of a DLL to be called from C.
    I would like to see the ENUM definition in the header file for the DLL so that the C program can use the same symbolic names for the commands that I
    am using in my case selector within the VI.
    Is there a good way to do this?
    When I generate the DLL the parameter is shown simply as a uint32_t (I have the ENUM defined as 32 bit in LV rather than the default 16 bit).
    I would have expected that all ENUMs that are parameters or return values of any function going into a DLL would automatically be defined in the DLL's header...
    They really should be typedef ENUM definitions with the name of the LV control being given to the typedef by default.
    Any help is greatly appreciated.
    Thanks,
    Klaus

    You can export all items from an Enum Control using the "Strings[]" property. The values for enums always begin with zero and increment by one.
    Does this help?
    a.lia-user-name-link[href="/t5/user/viewprofilepage/user-id/88938"] {color: black;} a.lia-user-name-link[href="/t5/user/viewprofilepage/user-id/88938"]:after {content: '';} .jrd-sig {height: 80px; overflow: visible;} .jrd-sig-deploy {float:left; opacity:0.2;} .jrd-sig-img {float:right; opacity:0.2;} .jrd-sig-img:hover {opacity:0.8;} .jrd-sig-deploy:hover {opacity:0.8;}

  • Renaming typedef file caused constants reset

    Hello!
    Here's a short description of the problem I encountered:
    I renamed the filename of the typedef that was used in my state machine for state coding (see for example State Machine template shipped with LV). As result I lost values of ALL constants that coded states in my state machine, i.e. they were reset to value of the first value in state enum.
    Note: when opening state machine that used the typedef
    I got the message something like "VI was changed in memory. Reload from disk or view from the memory?". And 2 buttons: View and Discard. I clicked "View".
    Then after restoring all constants manually, I saved my work to archive and tried to rename typedef file again, the result was the same - all constants reset to first value of enum.
    I restored files from archive, again renamed typedef file,
    then closed my app WITHOUT saving state machine that used typedef. After opening my program I got the message "Searching for my typedef", pressed "Browse..." and loaded typedef from renamed file. Constants were left without any change (uh-r-r-a!).
    Before posting this message to forum I tried to make an example to show the problem, but o-o-ps I failed to do it.
    It didn't repeat even with my program.
    This post can't be considered as bug report, as I can't repeat the problem. But I think the problem exists as I lost values of all constants after renaming typedef file, and this is the fact.
    So my advice (that old as the world) to everybody is to save work even when innocent actions are made such as renaming typedef file names.
    Probably somebody encountered this problem and knows how to repeat it.
    Thanks for attention.
    Any comments appreciated.
    Rashid.
    Using LV 8.0 (LV Run Time Engine 8.0.1) on Win XP with Russian locale, all VIs used in my programs have names in cyrillic sometimes mixed with english letters, e.g. "russian name (typedef).ctl".

    Hello, Charlie,
    I can say absolutely sure that I always used LabView to rename my typedef file. I never use Windows Explorer to rename typedef files (or any other LV files) in my practice.
    Besides, when the values of my constants were reset there wasn't any broken wires. The block diagram wasn't corrupted. Everything was fine except default values of my constants. Due to that I noticed this error a little later - after renaming typedef file I ran my program and couldn't understand why it fails to act as should. When debugging this problem I went down to my state machine and only then I saw that all my state constants are reset to default values.
    I never used "Substitute copy for original". I used only
    "Rename" when renaming my typedef file.
    I didn't add any items to my typedef. The only things I did are:
    - renaming my typedef enum label in the *.ctl file;
    - and "Save as.." -> "Rename..." - renaming my typedef file.
    Besides, when I did try renaming 2nd time to reproduce such behaviour: I left typedef enum label without change and the behaviour was the same.
    So, such behaviour (loosing constant values) I get TWO times.
    But after I worked around this (see 1st post) I couldn't already reproduce this behaviour.
    If I'll succeed in this one more time again, and be able to reproduce this behaviour, I'll certainly post to you my steps.
    Thanks for attention.
    Rashid.
    P.S.
    1. As to broken wires if I get it right - in your case you added new items to typedef but your case structure in state machine was not updated to contain new states handlers. If so, then it's obvious why you got broken wires. But as I didn't change the typedef itself (only renamed it), I didn't get broken wires.
    2. I wouldn't be surprised if I'd have done something in the weird way: I mean renaming by Explorer or saving, closing and so on. I was doing everything from the LabView environment. As far as I remember I didn't rename the state machine vi file at that, only typedef file. And my state machine was always opened. The only file I was opening/renaming/closing was typedef file. And as far as I remember I opened it by "File -> Open..." and not right-clicking at constant and "Open TypeDef..".
    3. I understand that my description is foggy :-) and that it's difficult to find this weird set of steps, but who knows. Anyway I appreciate your help.Message Edited by Rashid on 06-13-2006 12:03 PM

  • Accessing typedefs via JNI

    Hi all,
    I'm working on an interconnection program and have a Java UI running over the top of a C program which controls the sending and receiving.
    In my C file, I have a enum for the return status such as
    typedef enum { Send_Success, Send_Rejected, Send_Timedout} send_status;
    In the Java UI, I would like to be able to do something like this:
    if (send(frame) == Send_Success) {....}
    Any ideas on how to achieve this? I'm not sure how to declare the enum as native or even if it's possible. All thoughts would be gratefully received.

    If I wanted to do that an not maintain it manually I would create a perl script to my build process that would create the enum value for java. Actually as long as I controlled both sources I would start with a text file and have it generate java and C. Then I would add it to my build process (informing everyone how to add new enums.)
    If that is too complex for you then just add some 'final int' member variables to you JNI java class and use them where ever you want.

  • Probel with call library function: I have a dll based on a complicated struct data type. How can I pass this structure?

    The data type is
    typedef enum {false, true} bool;
    typedef float flt4;
    typedef double flt8;
    typedef int i32s;
    typedef unsigned int i32u;
    typedef short int i16s;
    typedef unsigned short i16u;
    typedef signed char i08s;
    typedef unsigned char i08u;
    struct t_UnwrapData {
    struct {
    i08u flags;
    i16u unwrap_m;
    i08u weight_m;
    } status;
    flt4 *ph2pi;
    flt4 *weight;
    flt4 *gamma;
    flt4 *phase;
    i08u *flags;
    i08u *neigh;
    i32s neighOfst[8];
    i32s r,c;
    i32s x0,y0,xSz,ySz;
    flt8 unwTime;
    flt4 binCut;
    Please Could someone help me suggesting how I pass this dat
    a type to call library function?

    Hi Setu,
    Here is a solution that I have been playing to return back an array of clusters
    typedef struct
    int32 dimSize;
    uInt8 array[1];
    } LVU8;
    typedef LVU8 **LVU8Hdl;
    typedef struct
    U32 DeviceId;
    U32 VendorId;
    U32 BusNumber;
    U32 SlotNumber;
    LVU8Hdl SerialNumber;
    } LVDEVICE_LOCATION;
    typedef LVDEVICE_LOCATION **LVDEV_LOC_HANDLE;
    typedef struct
    int32 dimSize;
    LVDEVICE_LOCATION cluster_array[1];
    } LVDEV_LOC_ARRAY;
    typedef LVDEV_LOC_ARRAY **LVDEV_LOC_ARRAY_HANDLE;
    LVPLX_API void GetAllDevices(LVDEV_LOC_ARRAY_HANDLE cluster_array)
    int i,j;
    int numDevices = 3;
    DSSetHandleSize(cluster_array, sizeof(int32)+3*(sizeof(LVDEV_LOC_ARRAY)+(sizeof(int32)+16*sizeof(L
    VU8))));
    (*cluster_array)->dimSize = 3;
    (*((*cluster_array)->cluster_array[0]).SerialNumber)->dimSize =16;
    (*((*cluster_array)->cluster_array[1]).SerialNumber)->dimSize =16;
    (*((*cluster_array)->cluster_array[2]).SerialNumber)->dimSize =16;
    for(i=0; i<3; i++)
    ((*cluster_array)->cluster_array[i]).BusNumber = i;
    ((*cluster_array)->cluster_array[i]).VendorId = i*5;
    for(j=0;j<16;j++)
    (*((*cluster_array)->cluster_array[i]).SerialNumber)->array[j] = (10*j)+i;
    The code doesnt do much but returns back 3*cluster which the array in my cluster is sized for 16. The problem I've been having , was ensuring I have allocated enough memory to handle the complete structure. This works for me, now all I have to do is put the real code in which get my array of data from the instruments.
    Hope it helps
    Regards
    Ray Farmer
    Regards
    Ray Farmer

  • CIN help with a struct argument

    Hi, I am new in LabVIEW and complete newcomer in CIN. Now there is one task in which I have to call a DLL. The function info is as following:
    BOOL WINAPI LKIF_GetCalcData(OUT LKIF_FLOATVALUE *CalcData1,OUT LKIF_FLOATVALUE *CalcData2);
    Here is more about defination:
    typedef enum {
        LKIF_FLOATRESULT_VALID, // valid data
        LKIF_FLOATRESULT_RANGEOVER_N, // over range at negative (-) side
        LKIF_FLOATRESULT_WAITING, // comparator result
    } LKIF_FLOATRESULT;
    typedef struct {
    LKIF_FLOATRESULT FloatResult; // valid or invalid data.
        float Value; // measurement value during LKIF_FLOATRESULT_VALID.
        Any other times will return an invalid value.
    } LKIF_FLOATVALUE;
    I looked through "Labview for everyone" and get me familiar with CIN, but it has a simple example with sinple argument. Can anyone tell me how to setup the input for this DLL? Should I make a cluster? Any help will be appreciated.
    sipher

    Problem solved. I wired a cluster with one I32 and one U16.
    Thanks.
    sipher

  • Can I use multiple type def enums in 1 VI?

    Is it possible to use multiple type def enums each having its own states? In the larger scope of things I want to use it in a QSM.
    Thanks
    mhaque
    Solved!
    Go to Solution.

    Sure you can have multiple type def enums.  I don't know what you mean by "in 1 VI".  Each typedef enum will have its own .ctl file.

  • Performance of state machine with enum vs string?

    I am laying out the groundwork for a very large state machine. It will have about 60 to 100 states. I kind of want to use an enum for selecting the states for convenience. But then if I use a string I can use Jim Carmody's case select tool so that wins out in convenience in one respect.
    One concern about using a string is performance. Since an enum is just an integer wouldn't the selections perform better? I need to squeeze out every ounce of performance and in fact this state machine will be set for subroutine priority. Another concern that I have about a typedef enum is that I have heard something about the possibility of them getting "out of sync" between VIs when you edit them. Is there some way to avoid that, such as making sure all VIs that use this typedef are in memory when editing it?
    =====================
    LabVIEW 2012

    Steve Chandler wrote:
    As for the number of states, I am pretty sure that it has to be one state machine. I'm afraid I cannot give a lot of details.
    I am having trouble figuring out the "has to" part.
    See this thread for designs I have posted previously.
    In this SM
    please look the section that is entered from "Change Request 8 " can take multiple paths but all ends at "Stop Monitoring? 15". I could have implemented that as a sub-SM and it would have reduced the number of state required for that part of the work from five to one.
    Any time I see "single entry, fan out, merge" I think sub-SM.
    This could also help with your shift register as well because (again seea bove) the bulk of the ose states deal with Logging so rather than use a SR, put what would have been in the SR (file path or ref) to be used there OR possibly an AE that can be used in each of those states.
    So I still don't understand why sub-SM aren't a possiblity.
    Trying to help,
    Ben 
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

Maybe you are looking for

  • I've change device Ipone4s to Ipnoe 5 . How to i get the old game for game center

    I've change device Ipone4s to Ipnoe 5 . How to i get the old game for game center

  • Connecting MBP to new Samsung 46" LCD 6300 series

    Hello All, I'm trying to connect my 46" Samsung LCD TV to my MBP through the network but I don't seem to know how. I have a bittorrent client, Vuze, that seems to find the LCD TV through the network but is there something more proprietary? I tried lo

  • Cannot mirror to apple tv 2

    Help me out here guys. I know there are posts out there but none have helped. I have downloaded doubletwist and airsync and allcast but none of them will allow me to mirror to the bigger screen...what am i doing wrong? It should be easy..but it isn't

  • "No receiver is entered" in SWEL when triggered via program.

    Hi WF experts, I'm currently working on a workflow with Z business object. My WF contains a "wait for event" step. When I launch my WF directly from SWDD. It works (I verify in SWEL and i find receiver data in the details, but when i trigger the even

  • [CLOSED] how to install cleanq2 for quake 2

    Hello all, I'm would like to install Quake 2, I know I could use Wine, but I would like to install it natively.  I saw a post here: http://bbs.archlinux.org/viewtopic.php?id=99025 and they mention cleanq2.  I  checked out the link to the code page, b