05-09-2017 02:08 PM
I'm using LabVIEW 2013 and I'm trying to use a .net assembly to send command to our hardware through USB port. I couldn't following the path provided by software developer because I couldn't see all the object he sees. Any suggestion? Thanks.
05-09-2017 02:38 PM
Is this a custom DLL provided, or a Microsoft system assembly? Sometimes the Microsoft system .NET assemblies are in subcategories you wouldn't anticipate.
Can you tell us the path in question?
05-09-2017 03:33 PM
This is not a MicroSoft system assembly, this is an open source program called USBLibrary.
05-09-2017 03:45 PM
If it's open source, can you link to the download page where you got the DLL as well as the path(s) you think you should be able to find inside of it?
Also, are you certain it's a constructor you need? It may actually be a static method or property, so instead of a constructor node you may need to use a property or invoke node, then right click, Select Class -> .NET -> Browse..., go to the DLL, and look again for static options (they start with [S]).
05-09-2017 04:57 PM
The attached is the library, it has some source code in it. It's an awkward situation, because I don't know the .net and the software guys don't know LabVIEW, so it's hard to navigate through.
05-09-2017 05:24 PM
Still need to know which object it is you think you should see, but don't.
Many of the functions appear to have inputs from the mscorlib library, maybe you need to look there?
05-09-2017 06:03 PM
Kyle,
Thanks for pointing out the mscorlib, I think I need something from the library to get started, like the EventHandler. But the EventHandler needs two inputs, object and method, could you explain how I can generate these two items? I can wire the UsbHidPort constructor to the object, there's a red conversion dot, do you think it matters?
05-09-2017 07:26 PM
At this point I think we really need to see a code snippet showing the C# code that you're trying to duplicate.
Any reference wire from a .NET node can be cast as an Object, so you really need to make sure you're using the correct one. Just because the wire connects doesn't mean it's going to work.
05-10-2017 03:26 AM - edited 05-10-2017 03:27 AM
The .NET library as is, has likely a problem if you happen to have two or more of the same devices connected to your computer as it does not offer a way to distinguish them and you only identify a device by vendor_id and product_id.
The Event Handler you want to have is in LabVIEW implemented as a callback VI and then registered for the .Net reference as event. I attached a very rough, totally untested and in many ways completely insufficient VI that should show you the principles of accessing this library from LabVIEW. You will surely have to modify it heavily to get a useful library of functions, but it gives you an idea how the library can be accessed.
05-10-2017 10:00 AM
rolfk,
Thank you very much for the detailed help, looks it's what I need. I'm installing the latest LabVIEW so I can open your example, in the mean time, may I ask you a question? What are the object type of the two .NET constants in the callback vi? Do I need to change them to the appropriate types?