LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

communicating with a USB device using a .net assembly dll

I have a device that uses the PIC18F14K50 micro.  I am trying to communicate with it via USB.  Therer is a problem with the device driver that the device wizard creates, and NI is investigating that.  I also have a dll that I am trying to use.  The dll is used by a VB program and it works well.  It uses the SendPacket method(?) to send the 64 byte packet to the device.  I have included the VI that I tried to do this with, but it doesn't work.  I can't see how to direct the data to the correct port.  Are there any examples of how to do something like this?  I can't find any.

Jim

LV 2020
0 Kudos
Message 1 of 6
(3,656 Views)

Have you looked at the properties in a property node placed after the constructor and before the invoke node? There seem to be a lot of things in there you can modify.

0 Kudos
Message 2 of 6
(3,644 Views)

Hi Kevin,

 

I think my problem is much more basic.  How do I direct the dll to the correct port?  I am running a USB monitoring program, and I don't see any data being directed to the device.  When I run the VB program that I was given (that uses the SendPacket method of the dll) I can see the data with the USB monitor.

Jim

LV 2020
0 Kudos
Message 3 of 6
(3,629 Views)

As far as I know, you cannot simply "direct it to a port." It has to be a configuration within the DLL. DLLs are simply code which can be executed by any application. It has no intrinsic association with any given ports or hardware. It's just compiled code which can be accessed by any process without locking. If you're trying to specify a particular USB port to be used in relation to a DLL, it needs to be a setting in that DLL. Have you looked at the documentation for that DLL? Is there any example code on it's uses?

0 Kudos
Message 4 of 6
(3,623 Views)

This VB code is the example code that they gave me.  It works well.  Unfortunately I cannot get in touch with the developer.  In the picture you can see where it connects to the board (although disconnectdevice is an odd title for a connect method).  When I execute the EnumDevices method in this VI, I get the correct number of devices(1), and the correct descriptor text, and I can see the transactions in my USB monitor.  When I execute the other frame, nothing happens.  I see nothing in the USB monitor.

Jim

LV 2020
Download All
0 Kudos
Message 5 of 6
(3,616 Views)

It looks like you just need to wire up a property node containing the appropriate PID, VID and Device Index and that will select the proper device. You'll want to use that enumation function to make sure you get a valid device. See the following function in that code you linked for the important parts of what need to be set. 

 

Private Sub ButtonConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonConnect.Click
        ' Connect(Button)
        If ComboBox1.SelectedIndex >= 0 Then
            myDevice.VID = VID
            myDevice.PID = PID
            myDevice.DeviceIndex = ComboBox1.SelectedIndex
            'myDevice.USBListen = True'Set True For Multithreaded method only
        End If
    End Sub
0 Kudos
Message 6 of 6
(3,613 Views)