labview references

All about Sub-20 Multi Interface USB Adapter USB to I2C, SPI, GPIO, RS232, RS485, Ir, LCD

Moderator: serg

Post Reply
brad
Posts: 23
Joined: Thu Jan 13, 2011 2:51 am

labview references

Post by brad »

Hello,

I am using LabView 7.1.1f2 to communicate with my Sub-20 device. Occasionally the Sub-20 device is not properly closed before the LabView .NET reference is deleted. This can occur if the VI quits prematurely (between the Sub20.Open() and Sub20.Close() methods). When this occurs, the Sub20 device remains open and I cannot find a way to re-open the device without power cycling. Is there a way to resolve this? Is there a method in Sub20Enum that will help?


Also, I noticed the method Sub20.Dispose(), but cant find documentation for it. What does this do?


Thanks,
Brad

serg
Posts: 143
Joined: Mon Aug 31, 2009 9:17 pm

Re: labview references

Post by serg »

Hi Brad,
There is no direct way to do that. We will try to find a workaround for the problem. The sub20 doesn't export the the Dispose method.
I assume it's being added by the .NET or LV.

brad
Posts: 23
Joined: Thu Jan 13, 2011 2:51 am

Re: labview references

Post by brad »

Serg,

In most cases, Labview automatically deletes .NET references when the top-level application stops running. I have tried to store the .NET reference in a global variable but once the top-level app stops running the reference is no longer valid (sub20 device doesn't respond).

The only labview work-around I see is to open & close a .NET reference for each sub20 function call. The first draw back to this approach is it is obviously very inefficient, particularly when collecting ADC data every 100ms. The second problem is that it would be rather difficult to implement in complex applications using multiple features of the sub20. My app is using the SPI bus, ADC, and PWM (all in separate VIs running simultaneously). I would need to use some technique to keep the various sub-VIs from trying to simultaneously open a .NET reference to the sole sub20 device.

A work around at the device level would be greatly appreciated!!

-brad

serg
Posts: 143
Joined: Mon Aug 31, 2009 9:17 pm

Re: labview references

Post by serg »

Hi Brad,

I added two methods into the SUB-20 .NET component(see attachment)

Code: Select all

bool Sub20::GetHandle( UInt32 % Handle )
bool Sub20::CloseHandle( UInt32 Handle )
The GeHandle method returns a low level SUB-20 device handle. You can pass this value to the CloseHandle method at the begining of your vi execution. Please note that the CloseHandle method does nothing if the Handle value is zero. If the Handle value is invalid then exception occurs, so you have to zero out your global variable after the CloseHandle call and at the end of "normal" termination. Also, I have added a code that closes the SUB-20 low-level handle if the sub-20 class destructor gets called. This happens when vi invokes the Dispose method. Unfortunately, the "Dispose" method is not getting called automatically when execution stops.
Attachments
sub20.net_1.4.6.zip
(50.64 KiB) Downloaded 1052 times

brad
Posts: 23
Joined: Thu Jan 13, 2011 2:51 am

Re: labview references

Post by brad »

Is this built for .NET 3.5 or .NET 4.0 ? Does it matter?

serg
Posts: 143
Joined: Mon Aug 31, 2009 9:17 pm

Re: labview references

Post by serg »

This is for .NET 2.x and 3.5. I don't think that the LV 7.1 is using .NET 4.0. Let me know if you need the .NET v4 build.

brad
Posts: 23
Joined: Thu Jan 13, 2011 2:51 am

Re: labview references

Post by brad »

When I try to add the assembly reference to LV 7.1.1f2, 8.0, or 8.2.1 I get an error. LV either crashes or says that the file may not be a .NET assembly.

Specifically in LV 8.2.1:
Add .NET constructor
browse to the x32 version of the 1.4.6 file
The objects box says: "An error occured trying to load the assembly.
sub20dnc146_error.png
sub20dnc146_error.png (17.18 KiB) Viewed 20752 times
Note that although the filenaming suggests the version is 1.4.6, LV shows 1.4.5.0 in the Assembly list box.

I downloaded the ZIP file again and went through the process and same error.

-brad

serg
Posts: 143
Joined: Mon Aug 31, 2009 9:17 pm

Re: labview references

Post by serg »

This is strange. Let me try to do the same with our LV8.5. What version of the SUB-20 do you use? In the meantime could you please try to install the SUB-20-101021, available for download here viewtopic.php?f=2&t=3. Replace the sub20dnc.dll file after successful installation. Let me know.

brad
Posts: 23
Joined: Thu Jan 13, 2011 2:51 am

Re: labview references

Post by brad »

I removed the previous sub20 installation using the installer tool, installed SUB-20-101021. At this point LV 8.2.1 had no problem with the sub20dnc.dll. I copied in the DLL posted in this thread and the error occured.

-brad

serg
Posts: 143
Joined: Mon Aug 31, 2009 9:17 pm

Re: labview references

Post by serg »

Hi Brad,
This was related to an incompatibility of the old sub20 library and new .NET component. Please download and install the SUB-20-110314 RC1 from here viewtopic.php?f=2&t=450&p=1058#p1058. This includes all the latest modules, so you don't need to update anything after installation. We are sorry about any inconvenience.

Post Reply