Allocate memory and call dll function which writes to the pointer

Hi!
I have a DLL wich has a function like the following example, wich i need to call from labview. In C I need to allocate some memory for the data and of course the struct. I add the pointer and the lengh of the data to the stuct and call the function with the struct. The function itself inserts some values to the stuct and to allocated memory. Has someone a working solution how this can be done with Labview?
typedef struct Thestruct
 UINT16 val1;
 UINT8 val2;
 UINT8 val3;
 UINT16 dataLength;
 UINT8 *data;
} T_Thestruct;
MY_API Status MY_API_CALL udaReceive(Handle handle, T_Thestruct *args);
I tried in labview (see picture), but I only got values inside the struct as well as the error 1097, the reserved memory inclues the same values as before.
Solved!
Go to Solution.
Attachments:
CallDll.PNG ‏21 KB

Tobias_BSH wrote:
OK, I found the soluton to my own Problem. The alignment on the struct must be corrected in Labview. There must be a 2Bytes dummy value between dataLength and the pointer.
And please not that your solution only works in LabVIEW 32 bit. In LabVIEW 64 Bit your DLL has to be 64 bit compiled as well in order to be loadable and the pointer then is a 64 bit integer and is usually aligned to 64 bit addresses too. In this particular case since the pointer is already aligned to a multiple of 64 bit (when the additional 2 alignment bytes are added) you won't have to modify the alignment for the 64 bit case, but you have to define a different cluster with the 64 bit integer for the pointer anyhow.
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions

Similar Messages

  • Session method and call transaction methos which one is the sap recomonded

    hi
    PLease give me the answer to these questions.
    session method and call transaction methos which one is the sap recomonded why .
    2) if we want to maintain BDC program in all the systems.wt to d0

    Hi Revethi,
    Here is the difference between the Session and Call Transaction method.
         Session
    Session method supports both small amount of data aswell as large amount of data
    2) data processing is asynchronus and data updation is synchronus.
    3) it process multiple apllication while perfomaning validations.
    4) in session method data will be updated in data base only after processing session only.
    5) system provide by default logfile for handling error records.
    6) it supports both foreground aswell as background process
    in bdc we use FM ... bdc_open_group " for creating Session
    bdc_insert " adding transaction and bdcdata table for updating database
    bdc_close_group " for closing Session
          Call Transaction
    Call transaction exclusively for small amout of data
    2) it supports only one apllication while perfoming validations
    3) there is no default logfile, We can explicitly provide logic for creating logfile for handling error records.
    we can create logfile by using structure....BDCMSGCOLL
    4) it doesn't support background processing.
    5) data processing is synchronous and Data updation is Synchronous( default), in
    this method also supports daya updation in asynchronus process also.
    Syntax:
    Call transaction <transaction-name> using BDCDATA
    mode <A/N/E> update <L/A/S>
    messages into BDCMSGCOLL.

  • Error 1097 after calling dll function which allocates memory inside

    Hello!
    When a call one my functions in my dll from LabView, i get an error 1097. My function takes a few arguments and then allocates some memory for measurement.
    It's not returning any pointers to that memory area, it is just allocates that memory for itself. I don't know what could be the problem, probably i am missing something.
    Could you help please?
    Best regards,
    Tamas
    Solved!
    Go to Solution.

    Are you sure that the allocate function is the problem?
    Error 1097 simply means something inside the external code wrote into memory locations that it was not meant to write. That is usually because of output buffer parameters that are not allocated (large enough) in LabVIEW when passed to the external code fucntion, so the function assuming it received a buffer of a certain size happily writes into that buffer but overwriting other information it should not have.
    But that is by far not the only possibility to cause this error. A simple bug in the external code can cause the same problem when a pointer goes astray or such. The fact that you used that library elsewhere already without seeing any problem is unfortunately no guarantee that the function is not buggy. The LabVIEW exeception handling around the Call Library Node has gotten rather picky and can detect violations that do not have to cause visible problems at all. But the violations it detects are real violations so just silencing them is not a good idea, as they could cause all kinds of problems including overwriting vital data structures in your program that either cause a crash later on or simply wrong results in other parts of your program. Especially the last one is a total bummer to debug.
    Without seeing much more of your code it is basically impossible to point out where the problem could lie. The particular Allocate function doesn't look like there is much that could be done wrong, but I would assume that you call several other functions too somewhere, which could cause the problem. If you can absolutely positively say that you never ever call any library function with a to short (or unallocated) buffer parameter, then you will have to take it up with the manufacturer of your lib, as it would seem very likely that there is some problem in there.
    Also you pass a handle to the library function but your Allocate function does not have this as a parameter! Where does this handle come from? Are you sure you have allocated and prepared it properly before calling this function? A handle is quite often a pointer, although usually a so called opaque pointer meaning the user of the library does not and should not know anything about the structure this pointer points to. It is only known internal to the library.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • When started, the Forefox process starts but halts around 5K of memory and doesn't got past this to the point that it will not bring up a window.

    A few weeks ago, Firefox messed up on an update and now it refuses to actually start short of working once per system boot. I have tried reinstalling and stuff like profile manager is also stopped by this lock-up. I feel it may have to do with my profile but I don't want to get rid of it. If there is a way to back up the profile manually so I can do a full reinstall or if there is a fix for this problem, it would be appreciated.

    A few weeks ago, Firefox messed up on an update and now it refuses to actually start short of working once per system boot. I have tried reinstalling and stuff like profile manager is also stopped by this lock-up. I feel it may have to do with my profile but I don't want to get rid of it. If there is a way to back up the profile manually so I can do a full reinstall or if there is a fix for this problem, it would be appreciated.

  • How to call a function which has a cursor

    hey folks I have a function which has a cursor,,like this
    CREATE OR REPLACE FUNCTION EMPCU RETURN VARCHAR
    AS
    CURSOR EMPC IS
    SELECT LNAME,SALARY,SSN
    FROM EMPLOYEE
    WHERE DNO IN(4,5);
    EMPV EMPC%ROWTYPE;
    BEGIN
    OPEN EMPC;
    LOOP
    FETCH EMPC INTO EMPV;
    EXIT WHEN EMPC%NOTFOUND;
    /*DBMS_OUTPUT.PUT_LINE(EMPV.LNAME||' '||EMPV.SALARY||' '||EMPV.SSN);*/
    RETURN EMPV. LNAME ||' '|| EMPV.SALARY||' '||EMPV.SSN;
    END LOOP;
    CLOSE EMPC;
    END EMPCU;
    Above function created successfully. I called above function like this
    DECLARE
    ENAMESAL VARCHAR2(70);
    BEGIN
    ENAMESAL:=EMPCU();
    DBMS_OUTPUT.PUT_LINE(ENAMESAL);
    END;
    Function is called and function is returning only one row instead of 7 rows. Actually cursor is supposed to return 7 rows but it is returning only one row. Is there any snytax to call a function which has a cursor. So experts please tell me where I have to make changes. I would be very thankful to you

    Well, you've told the function to RETURN within the loop, so after the first record in the loop, the function returns as you've instructed it.
    You would need to change your function to accept a specific input from the EMP table and then do a look up for that specific record and return the values you wanted, and wrap the function call in a loop in your anonymous block.
    Or you could just have the anonymous block like this....
    BEGIN
       FOR X IN
          SELECT EMPV. LNAME ||' '|| EMPV.SALARY||' '||EMPV.SSN AS Line_Data
          FROM EMPLOYEE
          WHERE DNO IN(4,5)
       LOOP 
          DBMS_OUTPUT.PUT_LINE(x.Line_Data);
       END LOOP;     
    END;
    /

  • Call function and call customer function

    Hi
    Can anybody let me know what is the difference between CALL FUNCTION AND CALL CUSTOMER- FUNCTION .
    i know call customer- function is used while we r working on user exits .
    but is their any specific reason of difference ...
    Thanks

    CALL CUSTOMER-FUNCTION function_exit parameter_list.
    Effect
    This statement can be used in programs delivered by SAP. It includes the function module exit specified in function_exit . The function module exit is a customer exit. In an SAP program, it enables you to call a function module provided by SAP and implemented by the customer.
    The indicator function_exit must be a three-digit text field literal. A function module exit is specified by SAP using the transaction SMOD and can be activated using the transaction CMOD in customer systems.
    Specifications by SAP
    An empty or partly implemented function module must be assigned to the function module exit using the transaction SMOD. The name of the function module consists of EXIT_, the program name, which contains the statement CALL CUSTOMER-FUNCTION, and the three-digit indicator in function_exit. The interface of the function module is completely defined by SAP.
    Activation in the customer system
    The transaction CMOD enables the customer to implement the source code of the function module within an enhancement project and to activate the function module exit. If the function module exit is not activated, the statement CALL CUSTOMER-FUNCTION is ignored. If the function module is activated, the corresponding function module is called in the same way as the general function module call.
    Syntax and meaning of the parameter_list for the assignment of the actual parameters to formal parameters and for the exception handling are the same as in a general function module call. It is not possible to dynamically fill the interface.
    CALL FUNCTION func
    Syntax
    CALL FUNCTION func { parameter_list
                       | parameter_tables }.
    Effect
    This statement calls the function module specified in func. The identifier func must be a character-type data object, which contains the name of a function module in uppercase letters during the statement execution. Each function module of an SAP system has a unique name, which is why you need not specify the function group.
    Use additions parameter_list or parameter_tables (as of release 6.10) to statically or dynamically assign actual parameters to the formal parameters of the function module and return values to the non-class-based exceptions.
    Note
    If the name of a function module is specified by a constant or as a literal, the extended syntax check can check the statement.
    Exceptions
    Catchable Exceptions
    CX_SY_DYN_CALL_ILLEGAL_FUNC
    Cause: The called function is known but not active.
    Runtime Error: CALL_FUNCTION_NOT_ACTIVE
    Cause: The called function is unknown.
    Runtime Error: CALL_FUNCTION_NOT_FOUND
    CX_SY_DYN_CALL_ILLEGAL_TYPE
    Cause: The type of the actual parameter does not fulfill the requirements of the function interface.
    Runtime Error: CALL_FUNCTION_CONFLICT_GEN_TYP
    Cause: The actual parameter does not have the length expected by the function.
    Runtime Error: CALL_FUNCTION_CONFLICT_LENG
    Cause: The actual parameter does not have the type expected by the function.
    Runtime Error: CALL_FUNCTION_CONFLICT_TYPE
    Cause: Only those functions can be called in the update task that are intended for it.
    Runtime Error: CALL_FUNCTION_NO_VB
    Cause: An actual parameter does not fulfill the alignment requirements of the respective formal parameter.
    Runtime Error: CALL_FUNCTION_WRONG_ALIGNMENT
    CX_SY_DYN_CALL_PARAM_MISSING
    Cause: The function expects a parameter, which has not been passed by the caller.
    Runtime Error: CALL_FUNCTION_PARM_MISSING
    CX_SY_DYN_CALL_PARAM_NOT_FOUND
    Cause: The caller has passed a parameter, which is not known to the function.
    Runtime Error: CALL_FUNCTION_PARM_UNKNOWN
    plz reward points if it helps

  • Call DLL function from JAVA

    HI!
    What's the best way (and simple) to call DLL function from JAVA.
    DLL function (developed in C) has two input parameters (string) and return an integer.
    Could you help with an example?
    Thanks a lot.

    Do a google search for 'JNI tutorial' and it will turn up hundreds of examples.

  • In session and call tansaction methods, which is better . why?

    hi
    in session and call tansaction methods, which is better . why?

    see the link:
    <a href="http://www.itcserver.com/blog/2006/06/30/batch-input-vs-call-transaction/">batch inpunt VS call transaction</a>
    "The most important aspects of the session interface are:
    <b>Asynchronous processing</b>
    Transfer data for multiple transactions
    Synchronous database update. During processing, no transaction is started until the previous transaction has been written to the database.
    A batch input processing log is generated for each session
    Sessions cannot be generated in parallel. The batch input program must not open a session until it has closed the preceding session.
    The most important features of CALL TRANSACTION USING are:
    <b>Synchronous processing</b>
    Transfer of data from an individual transaction each time the statement CALL TRANSACTION USING is called
    You can update the database both synchronously and asynchronously. The program specifies the update type.
    Separate LUW (Logical Units of Work) for the transaction. The system executes a database commit immediately before and after the CALL TRANSACTION USING statement.
    No batch input processing log"
    I hope I have been able to help you.
    cordial greetings.

  • Can a loaded SWF call a function that lives in the parent?

    I'm building a pretty simple Flash site in AS3. There is a
    main movie (main.swf) that simply loads different swfs via buttons
    on a main nav bar. The user clicks on a MC in "main.swf" and a
    function is called, loadMyContent("section1.swf"), is called and it
    animates in nicely. Other buttons use the same function, loading
    section2.swf, section3.swf, etc.
    I've defined how "loadMyContent()" works in the the main
    movie's document class file. It's all working fine when I just need
    to load content from a user action from the buttons that live in
    "main.swf". I want to call that same "loadContent" function from
    within "section1.swf" and have "main.swf" run it's "loadContent"
    fuction, but I can't seem to figure out how to make a child call a
    function that lives in the parent.
    Is there any way of having my child do this?
    I have a suspicion I may have to define that "loadContent"
    somewhere else, but I'm a little stumped now. I'm not really
    familiar with design patterns yet, although I want to get an
    understanding of them sometime soon. Can anyone offer some help
    with my immediate need or suggest a route to a solution?
    Thanks.

    kglad,
    Thank you very much! That worked perfectly. My section1 FLA
    is now compiling it's SWF without complaint.
    In case someone else is following this, the exact code I
    ended up using to cast "this.parent.parent" as a MovieClip is:
    MovieClip(this.parent.parent).loadMyContent("section2.swf");
    The discussion I think kglad is referencing is
    this
    discussion. If that's not it, just let me know. Again, kglad,
    thank you!

  • Search if a layersets with a specific name exist and execute a function if it is the case

    Hello,
    How can i write a script that search if a layersets with a specific name exist and execute a function if it is the case?
    Some examples?
    Many thanks.
    Regards.
    Sebastien

    This would check for a LayerSet if a name with DOM code – so it’s fairly slow.
    var check = checkForLayersetNamed(app.activeDocument, false, "thisName");
    alert (check);
    ////// function collect all layers //////
    function checkForLayersetNamed (theParent, theCheck, theName) {
    /* if (!allLayers) {var allLayers = new Array}
      else {};*/
      for (var m = theParent.layers.length - 1; m >= 0;m--) {
      var theLayer = theParent.layers[m];
    // apply the function to layersets;
      if (theLayer.typename == "ArtLayer") {
    // allLayers.push(theLayer)
      else {
      if (theLayer.name == theName) {theCheck = true};
      theCheck = (checkForLayersetNamed(theLayer, theCheck, theName))
    // allLayers.push(theLayer);
      return theCheck
    Below is AM code Paul Riggott posted some time ago in connection with linking Layer Masks.
    Re: Automatically re-link layer masks
    You could add a check for whether the Layer is a LayerSet, but if the name is the sole distinguishing feature this might work as a basis for your operations.
    app.bringToFront();
    main();
    function main(){
    if(!documents.length) return;
    linkLayers();
    function linkLayers(){
       var ref = new ActionReference();
       ref.putEnumerated( charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
       var count = executeActionGet(ref).getInteger(charIDToTypeID('NmbL')) +1;
       var Names=[];
    try{
        activeDocument.backgroundLayer;
    var i = 0; }catch(e){ var i = 1; };
       for(i;i<count;i++){
           if(i == 0) continue;
            ref = new ActionReference();
            ref.putIndex( charIDToTypeID( 'Lyr ' ), i );
            var desc = executeActionGet(ref);
            var layerName = desc.getString(charIDToTypeID( 'Nm  ' ));
            var Id = desc.getInteger(stringIDToTypeID( 'layerID' ));
            if(layerName.match(/^<\/Layer group/) ) continue;
    /* you could insert your operations in an if clause here */

  • I've just purchased a new 2014 15" MacBookPro to replace my much missed 17" MBP. I got the works: OS 10.9.4, 2.8GHz Intel i7, 16GB memory and a 1 TB SSD, but despite the expense, I still don't have a computer that works...  The problem is that every

    I've just purchased a new 2014 15" MacBookPro to replace my much missed 17" MBP. I got the works: OS 10.9.4, 2.8GHz Intel i7, 16GB memory and a 1 TB SSD, but despite the expense, I still don't have a computer that works...
    The problem is that every time I try to open any program from Office 2011, I immediately get the following window, for example for Word: "Microsoft Word has encountered a problem and needs to close. We are sorry for the inconvenience." This happens each and every time I try to open Word or other Office 2011 component.
    Thinking it might be a licensing issue, I purchased and downloaded a new copy of Office 2011 from Amazon and installed it on my new MBP. Same issue once again.
    I tried to remove all copies of Office 2011 from the MBP, but the instructions provided by Microsoft required about three page and seventeen steps and the page was somehow corrupted and would not print in its entirety, nor would it e-mail as anything other than a link to the corrupted page. Not trusting my memory, I decided not to try this without adult supervision.
    I used Disk Utility to repair Disk Permissions, as described on an existing thread regarding the same problem, but to no avail.
    I removed and later replaced the "Microsoft User Data" folder from the Documents folder, but that was no help.
    I have copied the short version of the "Microsoft Error Reporting log version: 2.0," below, for those of you with a deeper knowledge of the internal workings, or non-workings of things Mac when crossed with things MS.
    Error Signature:
    Exception: EXC_BAD_ACCESS
    Date/Time: 2014-08-28 03:31:31 +0000
    Application Name: Microsoft Word
    Application Bundle ID: com.microsoft.Word
    Application Signature: MSWD
    Application Version: 14.4.3.140616
    Crashed Module Name: CoreFoundation
    Crashed Module Version: 855.17
    Crashed Module Offset: 0x00018442
    Blame Module Name: MicrosoftOleo
    Blame Module Version: 14.4.3.140616
    Blame Module Offset: 0x000017f3
    Application LCID: 1033
    Extra app info: Reg=en Loc=0x0409
    Crashed thread: 0
    Surely others have encountered and solved this same problem, and I'm hoping they can help me do the same. I don't know if this is a known issue or simply a matter of my having bumbled naively through a process far more complex than I was led to believe.

    http://www.microsoft.com/mac/support
    http://answers.microsoft.com/en-us/mac/forum/macword?auth=1
    http://answers.microsoft.com/en-us/mac/forum/macoffice2011-macword/microsoft-wor d-for-mac-2011-will-not-open-error/ecc42616-6f49-40bb-b8f5-e21c711ea359

  • I want to upgrade my macbook pro 15-inch i7 2.3GHz memory and I want to know what is the maximum RAM it could take

    I want to upgrade my macbook pro 15-inch i7 2.3GHz memory and I want to know what is the maximum RAM it could take

    Welcome to Apple Support Communities
    It looks like you have got an Early 2011 or newer MacBook Pro, so you can use 16 GB of RAM. You can buy more RAM at OWC or Crucial. Remember that you cannot upgrade RAM in MacBooks Pro with Retina display
    In case you have got a Mid 2010 MacBook Pro, you can only install 8 GB of RAM

  • My Mac Book Pro has just had a new memory and solid state drive installed. After the installation, the Lightroom tools all became grey. There is no longer any color on the screen other than my picture. Even the color sliders are grey.  Can you please help

    My MacBook Pro just had a new memory and solid state drive installed. Since the installation, the Lightroom tools are now all grey. Even the color sliders are grey. Please help!

    My guess is that your operating system got updated to Mavericks and that you are running an old version of Lightroom:
    Sliders are white, look different | Mac OS X 10.9 Mavericks
    Be aware of a Lightroom bug with color management in mavericks that makes shadows too deep in the Develop module: Jao's photo blog: Serious color management bug in Mac OS 10.9 "Mavericks" and Jao's photo blog: Further quantification of the Mavericks color management problem.

  • Why can't I block certain people face timing and imessageing me? I keep receiving random facetime calls every 5 minutes got to the point where I have has to turn facetime off.

    Why can't I block certain people face timing and imessageing me? I keep receiving random facetime calls every 5 minutes got to the point where I have has to turn facetime off.

    I'm having the same problem, but it's also coming through on my computer, through my Apple email address.  I have a very short Apple email, and little kids are trying to facetime their little friends, and then when I tell them I'm not their friend, they FaceTime or iMessage me even more, thinking that I'm still their friend, and I'm just kidding around. 
    I can't block the kids before they call...I don't know who they are.  I want to restrict my FaceTime to only my phone number, and block all FaceTime and iMessage requests that are coming in through my email address.  Can I do that?
    I have another thread:  https://discussions.apple.com/thread/5840011

  • After I exported a PDF to a Word doc and downloaded it, I can't get the pointer tool to work.

    After I exported a PDF to a Word doc and downloaded it, I can't get the pointer tool to work. When I click on the document text, the only tool is the "move" tool. I can't edit or select text. Please advise.

    Version of Adobe: Adobe ExportPDF (not Pro)
    Operating system:  Windows 8.1
    Steps I am taking: When the PDF file is selected and opened, I clicked on Tools menu on right side of the screen; then I clicked on Select PDF file; then under Convert To, I selected Microsoft Word (*.docx); then I hit the box below that; and clicked Convert. I then see the message that says it is Converting to Export PDF Online. Then I see a link below that, that says Download Converted File. This takes me online to Adobe Acrobat .com, where, I see the command, Export PDF, and see a blue box on the same screen that says Select PDF Files to Export. I click on the thumbnail of the file I want to export. This brings up, online, a screen containing the file I wanted to convert to Word. Then, on the same screen, I click on the icon on the right hand of the screen that says Download. then I click on the box on the bottom the screen that contains the Word document I had wanted to convert. This brings up the Word doc. in Compatibility Mode the latest Word version, which I am unfamiliar with and which has a Picture Tools tab that I cannot escape from and I cannot get any selection tool other that the Move pointer, and I cannot find the Select text pointer to select any text on the page. I don't want this Word version and do not know how to return to the old version of Word that I am familiar with.
    Can you help me, please?
    Theresa Julia Schuer

Maybe you are looking for

  • Saving e-mails from Safari 2.0.3 to Appleworks 6.0

    We use Safari & Appleworks in our company. We often need to save e-mails we receive. Our ISP is AOL. We follow the following procedure: open AOL e-mail in Safari, select an e-mail, click print, copy the resulting window and paste it in a new Applewor

  • POI Set up E-Commerce Gateway with OM Automatic Account Creation

    Hello We currently use e-Commerce Gateway for outbound 810. Purchase orders are entered manually. Customers are defined in order management and an EDI location code is established for the Store location and their Bill To (Accounts Payable address) We

  • Sequence Settings: 1920 footage is changed to 1440

    I'm importing footage from my Canon T2i shot at 1920x1080 24fps. There are no other sources for the sequence. I dragged clips into the timeline and now the sequence is set to 1440x1080. Furthermore, I don't see any options to change it to 1920x1080 i

  • How can i download Lightroom 5 and instal into win 7

    They do not allow download after 10 times and load the trial version it can not instal also adobe provide no email to help on this matter what company is this

  • How I can burn a Blu ray disc in my mac?

    Hello, I´m worried cause I don´t know how burn a Bluy ray But before, how can I do the menus? nickeditor