From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling Silicon Labs CP2112 DLL fron LabVIEW

Solved!
Go to solution

I can read the PDF document too. Smiley Very Happy

 

Attach the VI that you did for this function! And please backsave it to LabVIEW 2016 or earlier format!

Rolf Kalbermatter
My Blog
0 Kudos
Message 11 of 17
(1,816 Views)

Here is the VI. Quite simple what I have done so far

0 Kudos
Message 12 of 17
(1,810 Views)

Very simple but also very wrong!

 

HID_SMBUS_STATUS HidSmbus_GetNumDevices(DWORD *numDevices, WORD vid, WORD pid);

Return value: Type: Numeric, Data Type: Signed 32-bit Integer

1st Parameter: Name: numDevices, Type: Numeric, Data Type: Unsigned 32-bit Integer, Pass: Pointer to Value

2nd parameter: Name: vid, Type: Numeric, Data Type: Unsigned 16-bit Integer, Pass: Value

3rd parameter: Name: pid, Type: Numeric, Data Type: Unsigned 16-bit Integer, Pass: Value

 

HID_SMBUS_STATUS HidSmbus_Open (HID_SMBUS_DEVICE* device, DWORD deviceNum, WORD vid, WORD pid);

Return value: Type: Numeric, Data Type: Signed 32-bit Integer

1st Parameter: Name: device, Type: Numeric, Data Type: Unsigned Pointer-Sized Integer, Pass: Pointer to Value

2nd parameter: Name: deviceNum, Type: Numeric, Data Type: Unsigned 32-bit Integer, Pass: Value

3rd parameter: Name: vid, Type: Numeric, Data Type: Unsigned 16-bit Integer, Pass: Value

4th parameter: Name: pid, Type: Numeric, Data Type: Unsigned 16-bit Integer, Pass: Value

 

You can't just mix and match datatypes as you wish but have to match them exactly with what the DLL function has been declared with. You were lucky that the Adapt to Type configuration for the 1st parameter to the GetNumDevice() function by chance matches the Pass: Pointer to Value that this parameter needs. And also that passing smaller than 32-bit values over the stack always will be extended to 32-bit anyhows.

 

But even more importantly, you can ABSOLUTELY not change the order of parameters!! The "device handle" for the Open() function is returned in the first parameter, not in the 4th as you have written the VI!!

 

And yes all the other functions using that device handle need to receive it in the first parameter too, but here you need to configure the parameter as: 

 

1st Parameter: Name: device, Type: Numeric, Data Type: Unsigned Pointer-Sized Integer, Pass: Value

 

 

Rolf Kalbermatter
My Blog
0 Kudos
Message 13 of 17
(1,804 Views)

Sorry for that, the little I know of using it I learned it alone or online.

You helped me a lot with this. I'm going to do a couple of tests.
Thank you

0 Kudos
Message 14 of 17
(1,794 Views)
Solution
Accepted by rolfk

For the help you gave me, in this VI you can see that there is 1 CP2112 device connected, read the attributes of the device, open the connection and close it. All functions with a successfully status response.

 

If I had found something like that it would have saved me 1 week of tests. I share for the great help received.

Message 15 of 17
(1,788 Views)

That's the spirit. Thanks for sharing your solution.

Rolf Kalbermatter
My Blog
0 Kudos
Message 16 of 17
(1,780 Views)

Hello,

 

I am also working on CP2112 device.

Facing problem in Get attribute and Get string function. My application just crashes off after it executes the Get String function.

I do get Number of Devices as 1, but nothing in Get attribute.

I believe the parameters are all set properly.

Attached the VI and DLL.

Request assistance.

 

Thanks

Shan

Download All
0 Kudos
Message 17 of 17
(1,471 Views)