How to pass a struct to a DLL function and accessing it in another VI

Hi friends,
                   I am new to labview. I need to create a demo program in labview ,for displaying image from our own image capturing system. We have a  DLL ( build in VC++) containing functions for capturing image from our system. Now I need to create a VI library for some of functions in DLL and Create a Demo program using those created subvi library . I used "Call Function node" and created some of subvi's.
 Some of our DLL functions need to pass struct pointers.  Our function prototype will be similar to the following function.
__declspec(dllexport) int __stdcall Initialize( unsigned char *imagebuffer,struct config *Configuration);
The passed struct is similar to
struct config
  double                val1[3];
  unsigned short   val2;
  bool                    val3;
  bool                    val4[3];    
  unsigned char    val5;    
  unsigned char   val6[3];
  bool                    val7[26];
For passing "unsigned char *imagebuffer"  I initialized array with "Numeric constant " and set the size of the array and send to the function.
The problem here is, I used this array in one of the subvi. 
How can I use the returned imagebuffer array  in my main demo program. How to connect the image array to subvi "Connecter Pane"
And  which control  can I use to display the image. The image data I get is form of 1-D Array .
The second problem is,
                             For passing the structure,  I used "Bundle " and filled the bundle with all the datatypes as in my struct and passed to the function. Is it correct ?  How to access this bundle after returned from function  in another Vi. ie.) How to connect this bundle to the connter pane ?
Thanks for your valuable suggestions.
aajjf.
Message Edited by aajjf on 04-19-2007 05:34 AM

aajjf wrote:
Hi friends,
                   I am new to labview. I need to create a demo program in labview ,for displaying image from our own image capturing system. We have a  DLL ( build in VC++) containing functions for capturing image from our system. Now I need to create a VI library for some of functions in DLL and Create a Demo program using those created subvi library . I used "Call Function node" and created some of subvi's.
 Some of our DLL functions need to pass struct pointers.  Our function prototype will be similar to the following function.
__declspec(dllexport) int __stdcall Initialize( unsigned char *imagebuffer,struct config *Configuration);
The passed struct is similar to
struct config
  double                val1[3];
  unsigned short   val2;
  bool                    val3;
  bool                    val4[3];    
  unsigned char    val5;    
  unsigned char   val6[3];
  bool                    val7[26];
For passing "unsigned char *imagebuffer"  I initialized array with "Numeric constant " and set the size of the array and send to the function.
The problem here is, I used this array in one of the subvi. 
How can I use the returned imagebuffer array  in my main demo program. How to connect the image array to subvi "Connecter Pane"
And  which control  can I use to display the image. The image data I get is form of 1-D Array .
The second problem is,
                             For passing the structure,  I used "Bundle " and filled the bundle with all the datatypes as in my struct and passed to the function. Is it correct ?  How to access this bundle after returned from function  in another Vi. ie.) How to connect this bundle to the connter pane ?
Thanks for your valuable suggestions.
aajjf.
Message Edited by aajjf on 04-19-2007 05:34 AM
You say nothing about how your cluster looks but I'm afraid you did the standard error here and placed arrays in it. That is not what the C structure is representing for several reasons.
First fixed size arrays in C are inlined inside a structure, so are not a pointer but for the case of your val1 element three doubles.
Second although not relevant here because of above point: LabVIEW arrays are not the same as C arrays. LabVIEW uses a pointer to a pointer and has the size of the array in elements prepended to the array data. C simply uses a pointer and all the rest is the programmers sorrow. The Call Library Node does convert the top level element of variables you pass according to the type configuration of that parameter but does no conversion of internal elements at all. So passing clusters with anything like arrays or strings is always wrong unless the DLL is aware of the specific datatypes LabVIEW uses.
Last but not least you can end up with alignment issues. Elements in structures are aligned by every C compiler to a certain value. This value can be defined by the programmer in the project settings or for Visual C through #pragma pack() statements in the C code. The alignment rule says that an variable is aligned to the smaller of the two values that are either a multiple of the variable element size or the alignment setting. Most 32bit code nowadays uses 8 bit default alignment but LabVIEW always uses 1 byte. In your case there is nothing to observe since the large variables are at the beginning. Otherwise you might have had to insert filler elements in the LabVIEW cluster.
One last thing bool is a C++ type only. Its size is 1 byte and incidentially this is the same LabVIEW uses for Booleans.
Rolf Kalbermatter
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions

Similar Messages

  • How to pass a single character to dll (as a parameter)

    How do pass a single character to dll (as a parameter). This is a third party dll that i am unable to change.
    e.g.: int functionName(char* process, char myChar);

    My apoligies, I am trying to pass a char from Teststand. Passing as a char is not one of the Category
     I tried sending (for example) : Locals.myChar[0].  Which is acceptable in C++, but gives me an error via Teststand.

  • How do i select a clip from one project and enter it into another?

    how do I select a clip from one project and enter it in another?

    This doesn't seem to relate to Adobe Reader. Please let us know the product you are using so we may redirect you or refer to the list of forums at http://forums.adobe.com/

  • How can I take an item from one image and move it to another image?

    How can I take an item from one image and add it to another image, and rotate it to fit?

    Carefully select the objects of interest in one image and then copy, scale and position them into the other image. Then touch up the composite.
    Have to Love Photoshop for Retouching Images!

  • How do you remove a person from a photo and replace her with another person

    How do you remove a person from a photo and repalce her with another person.

    There are many tool and "tricks" to accomplish this manipulation. However, depending on the image one technique might be more appropriate than an other. And then there is the question of how to do it "skillfully". For example, the shadows in the person that is being substituted might be different than in the original image creating the obviously "photoshopped" look.
    Doing an Internet search on your posting title brings up lots of examples.

  • How to pass native struct to java

    Hey guys,
    I've got a legacy C++ prog that outputs structs to a binary file & I've got a header file defining that struct.
    I want to read the file and get the structs via java but I've never used any interface between the languages.
    All I've managed to come up in my searches is "how to pass java objects to c", well how do I do the opposite?
    Help appreciated

    I hear you calling me :)
    If this interests you I'll explain the problem from the beginning-
    I already have a C prog which outputs a HUGE binary file (therefore text is probably not a good idea),
    this file consists of a header followed by some number (defined in the header) of a certain struct (consisting of ~20 fields ints, longs, strings...)
    Another C program exists that reads this file. I am currently building some sort of visual interpretation of the data using java.
    As all C code is quite heavy duty [and works like it should :)], and a few other reasons, I do not want to change it.
    That leaves me with an existing file containing binary data I need to read into the Java UI.
    sztejkat > Why use native code?
    I would have really wished I could do this entirely in Java, as for portability - it doesn't have much consideration, just in terms of "clean" programming.
    As you said struct packing is something unpredictable, therefore I do not see a way of reading one without using C.
    bschauwejava > I suggest you try to be less vague about the results you are getting.
    Sorry :)
    This is the structure: File (package) -> File.java, InsInfo.java (classes)
    I'm using "javac File.java"
    And I'm getting:
    File.java:3: cannot resolve symbol
    symbol : class InsInfo
    location: package File
    import File.InsInfo;
    ^
    File.java:20: cannot resolve symbol
    symbol : class InsInfo
    location: class File.File
    public native InsInfo readIns();
    ^
    2 errors
    (the arrows actually point to the first letter in the class name)
    If I use "Object" instead of "InsInfo" javac compiles the .class without problems.
    I'm using Jbuilder and inside it the import is OK. When I compile it with Jbuilder everything is OK.
    I actually haven't thought of this until now, I'll try to use the .class Jbuilder produces to generate the header.
    btw- Thanks for getting so involved!!

  • How to pass a parameter into execute sql task and later use it into dataflow task?

    i am in a situation, where i have a logging table in which i have a primary key called ETL_log_ID which is an identity column and acts as a foreign key for various fact table and dimension tables which are populated using SSIS packages. Now i wanna use the
    ETL_log_ID as a parameter in the execute sql task which populates the log table and pass the same value in the data flow task which populates the facts and dimension. Can you let me know how to pass the parameter in a step by step procedure.
    Thanks,
    Nikhil
      

    Nikhil,
    You can check the following :
    http://www.programmersedge.com/post/2013/03/05/ssis-execute-sql-task-mapping-parameters-and-result-sets.aspx
    http://stackoverflow.com/questions/7610491/how-to-pass-variable-as-a-parameter-in-execute-sql-task-ssis
    Regarding the usage in Dataflow task, Can you elaborate on that a little?
    Thanks,
    Jay
    <If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>

  • How to pass dynamic parameter to a database function in OBIEE

    Hi,
    I have a requirement like this. I have to create one report in OBIEE which was in Discoverer. Now in discoverer report there are some calculated item in the worksheet based on database pkg.functions. The parameter which user gives at run time that parameters are then passed to the discoverer calculated items dynamically. But I am not able to do this in OBIEE answers.
    Can anyone tell me step by step how I can able to pass the user selected parameter values in OBIEE answer level.
    The example:
    GET_COMM_VALUE_PTD("AFE Cost & Commitment".Afe Id,:"Period Name(AFE)","AFE Cost & Commitment".Data Sel,"AFE Cost & Commitment".Org Id)
    GET_COMM_VALUE_PTD --- Function database
    ("AFE Cost & Commitment".Afe Id,:"Period Name(AFE)","AFE Cost & Commitment".Data Sel,"AFE Cost & Commitment".Org Id --- Parameters... :"Period Name(AFE)" is the dynamic parameter selected run time by user.
    Please help.
    Thanks
    Titas

    Hi,
    I already did that. But the existing discoverer re value report is showing correct value but the OBIEE report with EVALUATE function shows incorrect value.
    The requirement is to create a OBIEE Dashboard from a Discoverer existing report. Now in discoverer report theere are several calculated items in worksheet level where database custom function is used and user selected parameter value is passed run time in that function. But when that is created in OBIEE with EVALUATE function in RPD, the report shows incorrect data. Could not understand how to pass the parameter value runtime.
    Below is the discoverer 'Show SQL' query and EVALUATE function syntax which has been used.
    SELECT APPS.XXBG_PL_PROJ_ANALYSIS_AFE_PKG.GET_COMM_VALUE_PTD(XXBG_PL_PROJ_AFE_V.AFE_ID,
    :"Period Name(AFE)",
    XXBG_PL_PROJ_AFE_V.DATA_SEL,
    XXBG_PL_PROJ_AFE_V.ORG_ID),
    XXBG_PL_PROJ_AFE_V.AFE_DESC,
    XXBG_PL_PROJ_AFE_V.AFE_NUMBER,
    XXBG_PL_PROJ_AFE_V.APPROVED_AFE_AMOUNT
    FROM APPS.PA_PERIODS_ALL PA_PERIODS_ALL,
    APPS.XXBG_PL_PROJ_AFE_V XXBG_PL_PROJ_AFE_V
    WHERE ((XXBG_PL_PROJ_AFE_V.ORG_ID = PA_PERIODS_ALL.ORG_ID))
    AND (XXBG_PL_PROJ_AFE_V.DATA_SEL = :"Data Selection(AFE)")
    AND (PA_PERIODS_ALL.PERIOD_NAME = :"Period Name(AFE)")
    AND (XXBG_PL_PROJ_AFE_V.AFE_NUMBER = :"AFE Number(AFE)")
    AND (XXBG_PL_PROJ_AFE_V.OPERATING_UNIT = :"Operating Unit(AFE)")
    The EVALUATE function syntax is as below:
    EVALUATE('XXBG_PL_PROJ_ANALYSIS_AFE_PKG.GET_COMM_VALUE_PTD(%1,%2,%3,%4)' AS FLOAT , "BG PL Project Analysis Report_1"."AFE Cost & Commitment"."AFE Cost & Commitment.Afe Id", "BG PL Project Analysis Report_1"."Periods 1"."Periods 1.Period Name", "BG PL Project Analysis Report_1"."AFE Cost & Commitment"."AFE Cost & Commitment.Data Sel", "BG PL Project Analysis Report_1"."AFE Cost & Commitment"."AFE Cost & Commitment.Org Id")
    The PERIOD needs to be passed at run time which user will select.
    Please help to solve the issue.

  • How to pass a SELECT-OPTION to a FUNCTION-MODULE

    Hi forum:
              How can i pass a selection-option like an input parameter of a function-module?. Put one example in the answer, please.
              After pass this value i want to put this into an IN select condition.
       But for i only need know how to pass this value
    thnks
    Josué
    Thnks
    Josue Cruz

    Hi Rich.
       this is a little example of my code.
       DATA: wa_bukrs TYPE bkpf-bukrs,
                  wa_budat TYPE bkpf-budat,
                  wa_gjahr TYPE bkpf-gjahr.
       SELECT-OPTIONS: se_bukrs FOR wa_bukrs OBLIGATORY,
                    se_gjahr FOR wa_gjahr OBLIGATORY,
                    se_budat FOR wa_budat OBLIGATORY.
      HERE i can to put the call to the function.
    Thnks

  • How to pass a "object" as a prameter from one java class to another java

    hi experts, I want to know "How to pass and get object as a parameter from one java class to another java class". I tried follwoing code just check it and give suggetions..
    import Budget.src.qrybean;
    public class ConfirmBillPDF extends HttpServlet
    qrybean db = new qrybean();
    SimplePDFTable pdfTable = new SimplePDFTable();
    pdfTable.simplePDFTableShow("2010","2011","1","2","1","131","102");
    }Here i want to pass db with simplePDFTableShow method. simplePDFTableShow is in another java class. So how can i do this.
    And also i want to know, how this obj will get.
    please help me.
    Edited by: andy_surya on Jul 14, 2010 7:51 AM

    Hi andy_surya
    what is this i am not understand
    pdfTable.simplePDFTableShow("2010","2011","1","2","1","131","102");but i am try to solve your problem try this
    qrybean db = new qrybean();
    SimplePDFTable pdfTable = new SimplePDFTable();
    pdfTable.simplePDFTableShow(db);and access like this in SimplePDFtable class update your method
    simplePDFTable(qrybean tempDB)
    // write your code
    }

  • How to pass the property value to getter function

    In jsp, I have a select box,like this:
    <html:select property="chooseType" styleId="chooseType" onchange="javascript:checkType()">
    <html:option value="Type1">Type1</html:option>
    <html:option value="Type2">Type2</html:option>
    <html:option value="Type3">Type3</html:option>
    </html:select>
    javascript, I use document.getElementById("chooseType").value="Type3";
    however, i form.java file, using getChooseType(), I could not get the value "Type3". If I do not set the value by javascript, I just select "Type3" from GUI, value "Type3" is passed properly to the getter.
    How to pass the value,set in javascript to getter?
    Edited by: [email protected] on Nov 17, 2009 4:23 PM

    I just found it is caused by the following code.
    javascript, I use document.getElementById("chooseType").disabled=true;
    So if I disable the select box, the value can not be passed to form. How to disable the select box but still pass the value to form?
    Edited by: [email protected] on Nov 17, 2009 11:56 PM

  • How to pass Application Item value in Javascript function.

    Hi,
    I have the following javascript in the HTML Form Element Attributes properties
    I am on Page1 and passing P1_DEPT_NO page item value. This is working perferctly fine and I am able to get the exact value of the page item
    onchange="javascript:function1($x('P1_DEPT_NO').value);"I am on Page1 and passing Application Item G_DEPT_NO value.
    The problem here is, I am not getting the Application item value inside the javascript function.
    I tried using alert(); and it's giving me value as undefined
    onchange="javascript:function1($x('G_DEPT_NO').value);"Just want to know, how to pass the Application Item value in Javascript.
    Thanks,
    Deepak

    Deepak,
    I am not an expert at Javascript, but the suggestin I made was because javascript is a case-sensitive language.. and therefore onChange is not the same as onchange.
    Not quite sure if that is causing the problem.
    Application items are not associated with a page and therefore have no user interface properties.
    Therefore, as mentioned in another post, the rendering would not work for application items.
    If it is for a single item, used only in this page, you could create a hidden page item and use it fo your purpose
    If you still want to look at application items and AJAX, This page contains examples of using AJAX to solve problems like the one you mentioned.
    http://www.oracle.com/technology/obe/hol08/apexweb20/ajax_otn.htm#t1b
    Thanks,
    Rajesh.

  • Fragment menu -how to pass the current nod to a function

    How can I pass the current node to a function I tried this but it
    didn't work.please advice
    <script language="javascript">
    nvh_mainnavigation_display(g_navNode_Path, Node ,
    "<!--$HttpRelativeFragmentsRoot-->AlfarisMainNavigation", false);
    </script>
    Note:
    I'm trying to create a menu that shows the subnodes of the current
    section or node that im standing on.

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Juan Oropeza ([email protected]):
    http://technet.oracle.com:89/ubb/Forum2/HTML/006279.html <HR></BLOCKQUOTE>
    null

  • How to call a jsp file from an servlet and access the jsp file objects??

    Hi everybody
    I have an jsp file where it contains a vector object with some data and I have a servlet that needs to access this vector object . How can my servlet call for this jsp page and get the vector object. ?
    then an applet will be calling this servlet to get some other object created with the data contained within this vector object...so each time Applet ask the servlet for the object the servlet need to call for this jsp page somehow
    My main question is the communication servlet-jsp
    please if u have any clue I will appreciate it
    thanks

    Hi
    There are several ways to share objects between JSPs/Servlets.
    You can share objects by putting them in the request-in which case the objects lifetime is limited by that of the request, Another way is to store them in the session, againg the lifetime is limited by the lifetime of the session. To have objects that have to persistent over the application life-span use the servletContext to store the objects.
    Any good tutorial should help you get started. Please see the link below for a tutorial on Servlets/JSPs
    Note: Local variables in the JSP cannot be shared with other components as their scope is limited to that particular Page/Servlet.
    Link: http://java.sun.com/docs/books/tutorial/servlets/
    Good Luck!
    Eshwar Rao
    Developer Technical Support
    Sun microsystems inc
    http://www.sun.com/developers/support

  • How can you take a photo from one event and put it in another, without dragging to desktop and dragging back into iPhoto and moving it to the event folder I want it in.

    As the title says I need help on how to take a photo from one event and put it in another, without dragging to desktop and dragging back into iPhoto and moving it to the event folder I want it in. Right now when I want to move a picture from one event to another I drag it to my desktop then delete it from iPhoto then I drag it back into iPhoto and put where I want it.An example would be taking a photo from the Christmas event and add it to a specific person event.  Can I do that within the events section without all the dragging. Also is there anyway I can remove duplicates from iPhoto without going through each and every file. Any help would be greatly appreciated.

    Apple doesn't make it easy to do what you want.  However, here's how I do it. 
    Select the photo you want to move and create a new Event for it via the Event ➙ Create Event menu option.
    In the Event mode select the new Event with the one picture and drag it onto the Event you want to move the photo to.

Maybe you are looking for

  • I lost the App Store on my iPod touch 4th generation, how do I get it back?

    Hi, I lost the App Store on my iPod touch 4th generation, how do I get it back? I wasn't talking about "Apple Store" app, but the one blue icon like where you can update apps... I don't remember how did it get disappears... because I was about to res

  • DRM is BS. Can't play BOUGHT VIDEOS!!!!!!

    Is there any solution to this without the headache of converting everything I buy from iTunes (shows/movies) to a non-drm format? I bought a brand new LG LW5600 TV and it has an app on it called Mediaplex. I installed the server on my iMac 27" so I c

  • How can I save a PDF from yahoo mail app in iphone5?

    Hi everybody!!! I am asking what the title says... I want to save a PDF doc from yahoo mail app in my iphone5! How can I do it? I have ibooks and adobe reader but no luck.... Any suggestions? Thanks a lot!

  • How to release a mac book that I sold

    I have sold a mac book Air and want to release its serial number so that the new owner can fully use it.  How can this be done?

  • Screen brightness resets after every start up

    Hi all, haven't been here in about a year. My imac's brightness has been resetting to the darkest point every time I shut down then subsequently start up (next day, whenever). I always had it set at it's highest point, which is what I preffered, and