Dear horace1,
At last my problem about this topics has been solve. And I am going to share it. As I think it will be helpful a some one like me. The fact's are -
1. In visual basic source code Each device has to be different VID & PID number. like below -
<Code>
Private Const VendorID1 As Integer = &H1231 'For Device A
Private Const ProductID1 As Integer = &H1 'For Device A
Private Const VendorID2 As Integer = &H1232 'For Device B
Private Const ProductID2 As Integer = &H2 'For Device B
Private Const VendorID3 As Integer = &H1233 'For Device C
Private Const ProductID3 As Integer = &H3 'For Device C
</Code>
2. Also have to modified Onplugged, Onunplugged and Onchange function. like below -
<code>
'*****************************************************************
' a HID device has been plugged in...
'*****************************************************************
Public Sub OnPlugged(ByVal pHandle As Integer)
If hidGetVendorID(pHandle) = VendorID1 And hidGetProductID(pHandle) = ProductID1 Then
Label186.Text = "Status : Device A Plugged"
DeviceAoff.Visible = False
DeviceAon.Visible = True
Label4.Text = "Device A Status: Device is connected"
End If
If hidGetVendorID(pHandle) = VendorID2 And hidGetProductID(pHandle) = ProductID2 Then
Label187.Text = "Status : Device B Plugged"
DeviceBoff.Visible = False
DeviceBon.Visible = True
Label97.Text = "Device B Status: Device is connected"
End If
If hidGetVendorID(pHandle) = VendorID3 And hidGetProductID(pHandle) = ProductID3 Then
Label188.Text = "Status : Device C Plugged"
DeviceCoff.Visible = False
DeviceCon.Visible = True
Label98.Text = "Device C Status: Device is connected"
End If
End Sub
'*****************************************************************
' a HID device has been unplugged...
'*****************************************************************
Public Sub OnUnplugged(ByVal pHandle)
If hidGetVendorID(pHandle) = VendorID1 And hidGetProductID(pHandle) = ProductID1 Then
hidSetReadNotify(hidGetHandle(VendorID1, ProductID1), False)
Label186.Text = "Status : Device A Unplugged"
DeviceAoff.Visible = True
DeviceAon.Visible = False
Label4.Text = "Device A Status: Device is not connected"
End If
If hidGetVendorID(pHandle) = VendorID2 And hidGetProductID(pHandle) = ProductID2 Then
hidSetReadNotify(hidGetHandle(VendorID2, ProductID2), False)
Label187.Text = "Status : Device B Unplugged"
DeviceBoff.Visible = True
DeviceBon.Visible = False
Label97.Text = "Device B Status: Device is not connected"
End If
If hidGetVendorID(pHandle) = VendorID3 And hidGetProductID(pHandle) = ProductID3 Then
hidSetReadNotify(hidGetHandle(VendorID3, ProductID3), False)
Label188.Text = "Status : Device C Unplugged"
DeviceCoff.Visible = True
DeviceCon.Visible = False
Label98.Text = "Device C Status: Device is not connected"
End If
End Sub
'*****************************************************************
' controller changed notification - called
' after ALL HID devices are plugged or unplugged
'*****************************************************************
Public Sub OnChanged()
' get the handle of the device we are interested in, then set
' its read notify flag to true - this ensures you get a read
' notification message when there is some data to read...
Dim pHandle As Integer
pHandle = hidGetHandle(VendorID1, ProductID1)
hidSetReadNotify(hidGetHandle(VendorID1, ProductID1), True)
pHandle = hidGetHandle(VendorID2, ProductID2)
hidSetReadNotify(hidGetHandle(VendorID2, ProductID2), True)
pHandle = hidGetHandle(VendorID3, ProductID3)
hidSetReadNotify(hidGetHandle(VendorID3, ProductID3), True)
End Sub
</code>
And finally
3. Have to modified Onread event, like below-
<code>
'*****************************************************************
' on read event...
'*****************************************************************
Public Sub OnRead(ByVal pHandle As Integer)
Label2.Text = Format(Now, "Long Time")
SamplingTime = TimeOfDay.Minute.ToString
' read the data (don't forget, pass the whole array)...
If pHandle = hidGetHandle(VendorID1, ProductID1) Then
Label4.Text = "Device A Status: Reading Data"
If hidRead(pHandle, BufferIn(0)) Then
' ** YOUR CODE HERE **
' first byte is the report ID, e.g. BufferIn(0)
' the other bytes are the data from the microcontroller...
samaple10 = Chr(BufferIn(1)) & Chr(BufferIn(2)) & Chr(BufferIn(3)) & Chr(BufferIn(4)) & Chr(BufferIn(5)) & Chr(BufferIn(6))
samaple11 = Chr(BufferIn(7)) & Chr(BufferIn(8)) & Chr(BufferIn(9)) & Chr(BufferIn(10)) & Chr(BufferIn(11)) & Chr(BufferIn(12))
samaple12 = Chr(BufferIn(13)) & Chr(BufferIn(14)) & Chr(BufferIn(15)) & Chr(BufferIn(16)) & Chr(BufferIn(17)) & Chr(BufferIn(18))
samaple13 = Chr(BufferIn(19)) & Chr(BufferIn(20)) & Chr(BufferIn(21)) & Chr(BufferIn(22)) & Chr(BufferIn(23)) & Chr(BufferIn(24))
samaple14 = Chr(BufferIn(25)) & Chr(BufferIn(26)) & Chr(BufferIn(27)) & Chr(BufferIn(28)) & Chr(BufferIn(29)) & Chr(BufferIn(30))
samaple15 = Chr(BufferIn(31)) & Chr(BufferIn(32)) & Chr(BufferIn(33)) & Chr(BufferIn(34)) & Chr(BufferIn(35)) & Chr(BufferIn(36))
samaple16 = Chr(BufferIn(37)) & Chr(BufferIn(38)) & Chr(BufferIn(39)) & Chr(BufferIn(40)) & Chr(BufferIn(41)) & Chr(BufferIn(42))
samaple17 = Chr(BufferIn(43)) & Chr(BufferIn(44)) & Chr(BufferIn(45)) & Chr(BufferIn(46)) & Chr(BufferIn(47)) & Chr(BufferIn(48))
samaple18 = Chr(BufferIn(49)) & Chr(BufferIn(50)) & Chr(BufferIn(51)) & Chr(BufferIn(52)) & Chr(BufferIn(53)) & Chr(BufferIn(54))
samaple19 = Chr(BufferIn(55)) & Chr(BufferIn(56)) & Chr(BufferIn(57)) & Chr(BufferIn(58)) & Chr(BufferIn(59)) & Chr(BufferIn(60))
unused1 = Chr(BufferIn(61)) & Chr(BufferIn(62)) & Chr(BufferIn(63)) & Chr(BufferIn(64))
Label16.Text = samaple10
Label17.Text = samaple11
Label18.Text = samaple12
Label19.Text = samaple13
Label20.Text = samaple14
Label21.Text = samaple15
Label22.Text = samaple16
Label23.Text = samaple17
Label24.Text = samaple18
Label25.Text = samaple19
'Label4.Text = "Device A Status: Device Idle"
End If
End If
If pHandle = hidGetHandle(VendorID2, ProductID2) Then
Label97.Text = "Device B Status: Reading Data"
If hidRead(pHandle, BufferIn(0)) Then
' ** YOUR CODE HERE **
' first byte is the report ID, e.g. BufferIn(0)
' the other bytes are the data from the microcontroller...
samaple20 = Chr(BufferIn(1)) & Chr(BufferIn(2)) & Chr(BufferIn(3)) & Chr(BufferIn(4)) & Chr(BufferIn(5)) & Chr(BufferIn(6))
samaple21 = Chr(BufferIn(7)) & Chr(BufferIn(8)) & Chr(BufferIn(9)) & Chr(BufferIn(10)) & Chr(BufferIn(11)) & Chr(BufferIn(12))
samaple22 = Chr(BufferIn(13)) & Chr(BufferIn(14)) & Chr(BufferIn(15)) & Chr(BufferIn(16)) & Chr(BufferIn(17)) & Chr(BufferIn(18))
samaple23 = Chr(BufferIn(19)) & Chr(BufferIn(20)) & Chr(BufferIn(21)) & Chr(BufferIn(22)) & Chr(BufferIn(23)) & Chr(BufferIn(24))
samaple24 = Chr(BufferIn(25)) & Chr(BufferIn(26)) & Chr(BufferIn(27)) & Chr(BufferIn(28)) & Chr(BufferIn(29)) & Chr(BufferIn(30))
samaple25 = Chr(BufferIn(31)) & Chr(BufferIn(32)) & Chr(BufferIn(33)) & Chr(BufferIn(34)) & Chr(BufferIn(35)) & Chr(BufferIn(36))
samaple26 = Chr(BufferIn(37)) & Chr(BufferIn(38)) & Chr(BufferIn(39)) & Chr(BufferIn(40)) & Chr(BufferIn(41)) & Chr(BufferIn(42))
samaple27 = Chr(BufferIn(43)) & Chr(BufferIn(44)) & Chr(BufferIn(45)) & Chr(BufferIn(46)) & Chr(BufferIn(47)) & Chr(BufferIn(48))
samaple28 = Chr(BufferIn(49)) & Chr(BufferIn(50)) & Chr(BufferIn(51)) & Chr(BufferIn(52)) & Chr(BufferIn(53)) & Chr(BufferIn(54))
samaple29 = Chr(BufferIn(55)) & Chr(BufferIn(56)) & Chr(BufferIn(57)) & Chr(BufferIn(58)) & Chr(BufferIn(59)) & Chr(BufferIn(60))
unused2 = Chr(BufferIn(61)) & Chr(BufferIn(62)) & Chr(BufferIn(63)) & Chr(BufferIn(64))
Label55.Text = samaple20
Label54.Text = samaple21
Label53.Text = samaple22
Label52.Text = samaple23
Label51.Text = samaple24
Label50.Text = samaple25
Label49.Text = samaple26
Label48.Text = samaple27
Label47.Text = samaple28
Label46.Text = samaple29
'Label97.Text = "Device B Status: Device Idle"
End If
End If
If pHandle = hidGetHandle(VendorID3, ProductID3) Then
Label98.Text = "Device C Status: Reading Data"
If hidRead(pHandle, BufferIn(0)) Then
' ** YOUR CODE HERE **
' first byte is the report ID, e.g. BufferIn(0)
' the other bytes are the data from the microcontroller...
samaple30 = Chr(BufferIn(1)) & Chr(BufferIn(2)) & Chr(BufferIn(3)) & Chr(BufferIn(4)) & Chr(BufferIn(5)) & Chr(BufferIn(6))
samaple31 = Chr(BufferIn(7)) & Chr(BufferIn(8)) & Chr(BufferIn(9)) & Chr(BufferIn(10)) & Chr(BufferIn(11)) & Chr(BufferIn(12))
samaple32 = Chr(BufferIn(13)) & Chr(BufferIn(14)) & Chr(BufferIn(15)) & Chr(BufferIn(16)) & Chr(BufferIn(17)) & Chr(BufferIn(18))
samaple33 = Chr(BufferIn(19)) & Chr(BufferIn(20)) & Chr(BufferIn(21)) & Chr(BufferIn(22)) & Chr(BufferIn(23)) & Chr(BufferIn(24))
samaple34 = Chr(BufferIn(25)) & Chr(BufferIn(26)) & Chr(BufferIn(27)) & Chr(BufferIn(28)) & Chr(BufferIn(29)) & Chr(BufferIn(30))
samaple35 = Chr(BufferIn(31)) & Chr(BufferIn(32)) & Chr(BufferIn(33)) & Chr(BufferIn(34)) & Chr(BufferIn(35)) & Chr(BufferIn(36))
samaple36 = Chr(BufferIn(37)) & Chr(BufferIn(38)) & Chr(BufferIn(39)) & Chr(BufferIn(40)) & Chr(BufferIn(41)) & Chr(BufferIn(42))
samaple37 = Chr(BufferIn(43)) & Chr(BufferIn(44)) & Chr(BufferIn(45)) & Chr(BufferIn(46)) & Chr(BufferIn(47)) & Chr(BufferIn(48))
samaple38 = Chr(BufferIn(49)) & Chr(BufferIn(50)) & Chr(BufferIn(51)) & Chr(BufferIn(52)) & Chr(BufferIn(53)) & Chr(BufferIn(54))
samaple39 = Chr(BufferIn(55)) & Chr(BufferIn(56)) & Chr(BufferIn(57)) & Chr(BufferIn(58)) & Chr(BufferIn(59)) & Chr(BufferIn(60))
unused3 = Chr(BufferIn(61)) & Chr(BufferIn(62)) & Chr(BufferIn(63)) & Chr(BufferIn(64))
Label85.Text = samaple30
Label84.Text = samaple31
Label83.Text = samaple32
Label82.Text = samaple33
Label81.Text = samaple34
Label80.Text = samaple35
Label79.Text = samaple36
Label78.Text = samaple37
Label77.Text = samaple38
Label76.Text = samaple39
'Label98.Text = "Device C Status: Device Idle"
End If
End If
End Sub
</code>
I am not a very good ex-plainer. I hope you understand what I meant. I share this because this forum helps me a lot .
With this code I am able to get data form the individual 3 devices. I think with this process we can communicate more devices with the PC .
Thank you,
Bahadur Kar
Transcom Electronics
Bangladesh