LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

usbxpress and mcu library

For reference, here are the last two links that RyanPoPo posted in his message. It appears that the original links were for internal versions of the documents.

 

How Do I Provide a Callback Function Pointer to My DLL Using LabVIEW?

http://digital.ni.com/public.nsf/allkb/89165EDE5031C68686257B2E0006FE99?OpenDocument

 

What is a Wrapper DLL and When Do I Need One?

http://digital.ni.com/public.nsf/allkb/06ECDC689DDA0F3D862574440074CD95?OpenDocument

Applications Engineer
National Instruments
0 Kudos
Message 11 of 14
(644 Views)

@bjlv wrote:

Hi Ryan:

I had read the an169 document when I started this project, but I have to say my C is rusty enough that I don't understand everything it describes.  The biggest mystery to me is why in SI_GetProductString the type LPVOID works just fine when configured for a LabVIEW string, but in the SI_Read function the same type configured the same way crashes LabVIEW.  The SI_GetProductString function has no byte count and no "o" pointer, features of the SI_Read function that are different.  I successfully get a string back from SI_GetProductString but I don't from SI_Read.  I have also tried using byte arrays in the CLF configuration, since it seems likely to me that I will have NULLs in my binary data stream from the device I am trying to talk with, and not all of those tries have led to crashes, but I still have never seen data returned.  I will look into getting some C help to try to map a LabVIEW string to a "void far" in a wrapper dll but am curious about the * that is added on page 28 of an169.  Doesn't that change it from LPVOID to pointer to LPVOID?

bj


First: LPVOID is simply a pointer to anything typically used in C as polymorphic datatype that can either be a string, or a single skalar value.

 

Are you sure you preallocate a long enough byte array (or string) to pass to the S_Read() function? This should be best done with the Initialize Array function and the number of elements that you also pass as parameter to the NumToRead parameter of the Call Library Node. Also make sure the buffer paramter is configured to be an Array of (your datatype, most likely an uInt8), passed as C Array pointer. Anything else will pass memory pointers that normal C code will certainly misinterpret.

 

The S_Write() function should be analogues expect in fact even more trivial since you do not have to preallocate any memory here, but simply pass in the buffer you want to write to the device (and also pass the number of elements of that buffer to the NumToWrite parameter of the function of course as that is the only way for the function to know how many elements it should read from the buffer and send to the device).

 

As far as I understand the USBExpress API there should be no need for a wrapper DLL in any way, and definitely no Callback Pointer.

Rolf Kalbermatter
My Blog
0 Kudos
Message 12 of 14
(627 Views)

Hi Ryan

I am using the same library and Getnumdevices function is working, get part number is working, Si open is working but when I am using Write function firstly it was giving me the error code 6 which is SI_Invalid_Parameter.
> Then I changed the buffer data type to string then that error code is not appearing but now SI_Status is giving me 12 code which is SI_SYSTEM_ERROR_CODE.
> I have gone through the AN169 document but it only says: Call GetLastError (Win32 Base) to retrieve Windows System Error Code.The error codes are defined on MSDN.
> Please help how to solve this...

Thanks

0 Kudos
Message 13 of 14
(431 Views)

Hi,

 

I would recommend creating a new thread to ask your question, as the last activity in this thread was from 2014. A new thread will help you gain visibility and increase the odds of the question being answered. 

Kevin S.
Technical Support Engineering
National Instruments
0 Kudos
Message 14 of 14
(422 Views)