LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

random crashes talking to dll

I have a vi where I am talking to a dll. This vi will crash LabVIEW at random intervals, usually after I have run the app a number of times and then close out the vi. Can someone with more experience with dlls look at this and let me know where I am not working this right? I have found out the hard way that the timers are required where they are.
 
This dll access some hardware, so I don't expect you to be able to have it run, but maybe somwhere I have the function calls incorrect. The hardware is a Silicon Labs CP2102 USB to UART Bridge Controller chip.
 
Files attached, including the dll documentation.
 
NOTE: you will have to change the "CP210xManufacturing.txt" extension back to "dll". I can't post a dll extension to the forum.
 
Thanks!
 
Tay
Download All
0 Kudos
Message 1 of 5
(3,172 Views)
Well, right off the bat your implementation of the "CP2102_GetPartNumber" does not match the prototype. The return value of that function is an integer, not a C string.

Also, why do you have a Wait Until Next ms Multiple function in the code? Is this VI supposed to be called multiple times? Are you trying to use the "Run Continuously" button in the toolbar? If you are calling this VI multiple times it doesn't make sense to constantly open/close the device.
Message 2 of 5
(3,163 Views)

I'm new to dll work; how did you determine the return type? I did a trial and error to get something that worked. I didn't see anything in the prototype that said what the return should be. That function description cited it as a 1 byte Part Number but 1 byte wasn't an option in the config settings.

The vi is actually a test bed, not real code. I'm using that architecture to learn how to talk to dlls. Opening and closing it seemed the right thing to do, based on my limited work thus far with VISA and the one dll Labview example I found from Silicon Labs.

Tay

0 Kudos
Message 3 of 5
(3,155 Views)
The documentation has for that function:

Return Value: CP210x_STATUS = CP210x_SUCCESS, 
                                                        CP210x_INVALID_PARAMETER,
                                                        CP210x_INVALID_HANDLE,
                                                        CP210x_DEVICE_IO_FAILED

In Appendix A, CP210x_STATUS is defined:
// Type definitions
typedef int CP210x_STATUS;
Thus, the return value is an integer (I32 in LabVIEW).

A "1-byte" value is just a U8/I8 in LabVIEW. Note that this function requires you to pass a pointer to the value. You should wire a constant to that node:
Message 4 of 5
(3,143 Views)

Ah, ye olde light dawns!

I see. I wasn't understanding the documentation fully.

Excellent help!

Tay

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