LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

error code 1097 in a DLL with a complex parameter

Hi Folks,

 

I have inherited a Mathlab DLL that is causing me a headache and wonder if anyone has a slolution.

labview crashes or gives error code 1097 and I beleive it maybe a call in the DLL called the RFID_RetrieveAttachedRadiosList Vi.

Its prototype is given below

 

RFID_LIBRARY_API RFID_STATUS RFID_RetrieveAttachedRadiosList(
    RFID_RADIO_ENUM*    pBuffer,
    INT32U              flags
    );

where RFID_RADIO_ENUM is
typedef struct {
    /* The length of the structure in bytes.  The application must set this to*/
    /* sizeof(RFID_RADIO_ENUM) before calling                                 */
    /* RFID_RetrieveAttachedRadiosList().                                     */
    INT32U              length;
    /* The total length, in bytes, of radio enumeration structure.  The       */
    /* application must fill in this field with the length of the radio       */
    /* enumeration buffer before calling RFID_RetrieveAttachedRadiosList().   */
    /* If the buffer is not large enough, on return this field contains the   */
    /* required size of the radio-enumeration buffer.  If the buffer is large */
    /* enough, on return this field contains the number of bytes returned     */
    INT32U              totalLength;    
    /* The number of radios that are attached to the system.  This is also the*/
    /* number of radio info structure pointers in the array pointed to by     */
    /* ppRadioInfo.                                                           */
    INT32U              countRadios;    
    /* A pointer to an array of RFID_RADIO_INFO structure pointers.  The array*/
    /* contains countRadios entries.                                          */
    RFID_RADIO_INFO**   ppRadioInfo;
} RFID_RADIO_ENUM;

and RFID_RADIO_INFO is
typedef struct {
    /* The length of the structure in bytes.  This will be                    */
    /* sizeof(RFID_RADIO_INFO).                                               */
    INT32U          length;
     /* The version information for the radio's bus driver.                   */
    RFID_VERSION    driverVersion;
    /* The unique cookie for the radio.  This cookie is passed to             */
    /* RFID_RadioOpen() when the application wishes to take control of the    */
    /* radio.                                                                 */
    INT32U          cookie;
    /* The length, in bytes, of the uniqueId field(aka, serial number)        */
    /* including the null terminator                                          */
    INT32U          idLength;
    /* A pointer to an array of bytes that contain the radio module's unique  */
    /* ID (aka, serial number).                                               */
    INT8U*          pUniqueId;
} RFID_RADIO_INFO;

the DLL builder creates the Vi that seems correct

 

 

RFID_RetrieveAttachedRadiosList.PNG

RFID_RetrieveAttachedRadiosList1.PNG

 

when ran, it give the wrong values with what looks like pointers inserted into the second length and major fields offsetting the data and not having enough room for all of it.

RFID_RetrieveAttachedRadiosList2.PNG

passing the results to the next Vi causes all sorts of mayhem from initially working, crashing, giving error 1097. Its very intermittant (memory issues).

Can anyone help me please?

 

Robert

0 Kudos
Message 1 of 5
(4,033 Views)

Well, this uses pointers to structs, with pointers to structs that contain pointers to structs!!!!

 

To make this work in LabVIEW without external C code requires you to play low level C programmer, C compiler and a few more tricks. It's not worth it. You need to write a wrapper DLL in C(++) to translate this monster of a data struct into something more pallable for LabVIEW.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 2 of 5
(4,015 Views)

Thanks for you reply rolfk.

How exactly do I make such a wrapper?

 

Do I created a C function that calls the the RFID_.. function, containing a simplified parameter list?

Place the new wrapper C function into the same DLL as the RFID (not sure how)?

I then call ther wrapper instead of the function?

 

Robert

0 Kudos
Message 3 of 5
(3,981 Views)

That's basically the idea, except you create a new DLL with the wrapper functions, and those wrappers calls the functions in your original DLL. You don't modify the original DLL.

0 Kudos
Message 4 of 5
(3,971 Views)

Brilliant; That I can do, thank you very much Nathand

 

Robert

0 Kudos
Message 5 of 5
(3,966 Views)