Author Topic: Found on VB HIDmodule BUG  (Read 14781 times)

ivws

  • Member
  • ***
  • Posts: 3
Found on VB HIDmodule BUG
« on: November 09, 2011, 11:28:31 pm »
First of all do not know what I am using the version is not low.

BUG following occurs:

1, only the PC's USB HID device I designed when all of the communication status, disconnected, connected. Communications. No problem!

2, when the PC has multiple HID devices exist, restart the application only to find my USB HID. Communication is no problem! But my USB HID connection is disconnected, the application could not find the HID device

After many days of my test application and found that the problem is DeviceAttributes.VendorID

Because the USB HID devices do not find clear! To procedural errors by the judge-type;

            If (DeviceAttributes.VendorID = MyVendorID) And _
                (DeviceAttributes.ProductID = MyProductID) Then
                   
                    'It's the desired device.
                   
                    'My device detected
                    MyDeviceDetected = True
            Else



************************************************** ******************
Improved code:

Function FindTheHid () As Boolean
    'Makes a series of API calls to locate the desired HID-class device.
    'Returns True if the device is detected, False if not detected.
   
    Dim Count As Integer
    Dim GUIDString As String
    Dim HidGuid As GUID
    Dim MemberIndex As Long
   
    LastDevice = False
    MyDeviceDetected = False
   

    'BUG -> there are multiple computer standard HID device, the device is disconnected, and then not work together with and must restart the program!
    'Improved methods
    'Set each enumeration USB HID device ID must first be cleared before!!
    'Modified: November 10, 2011 Liang Xiliang 310902900@163.com
    DeviceAttributes.VendorID = 0
    DeviceAttributes.ProductID = 0

   
    'Values ​​for SECURITY_ATTRIBUTES structure:
   
    Security.lpSecurityDescriptor = 0
    Security.bInheritHandle = True
    Security.nLength = Len (Security)
   
    '************************************************* *****************************
    'HidD_GetHidGuid
    'Get the GUID for all system HIDs.
    'Returns: the GUID in HidGuid.
    'The routine doesn't return a value in Result
    'But the routine is declared as a function for consistency with the other API calls.
    '************************************************* *****************************
   
    Result = HidD_GetHidGuid (HidGuid)
    Call DisplayResultOfAPICall ("GetHidGuid")
   
    'Display the GUID.
   
    GUIDString = _
        Hex $ (HidGuid.Data1) & "-" & _
        Hex $ (HidGuid.Data2) & "-" & _
        Hex $ (HidGuid.Data3) & "-"
   
    For Count = 0 To 7
   
        'Ensure that each of the 8 bytes in the GUID displays two characters.
       
        If HidGuid.Data4 (Count)> = & H10 Then
            GUIDString = GUIDString & Hex $ (HidGuid.Data4 (Count)) & ""
        Else
            GUIDString = GUIDString & "0" & ​​Hex $ (HidGuid.Data4 (Count)) & ""
        End If
    Next Count
   
    'GUID for system HIDs = GUIDString
   
    '************************************************* *****************************
    'SetupDiGetClassDevs
    'Returns: a handle to a device information set for all installed devices.
    'Requires: the HidGuid returned in GetHidGuid.
    '************************************************* *****************************
   
    DeviceInfoSet = SetupDiGetClassDevs _
        (HidGuid, _
        vbNullString, _
        0, _
        (DIGCF_PRESENT Or DIGCF_DEVICEINTERFACE))
       
    Call DisplayResultOfAPICall ("SetupDiClassDevs")
    DataString = GetDataString (DeviceInfoSet, 32)

ivws

  • Member
  • ***
  • Posts: 3
Re: Found on VB HIDmodule BUG
« Reply #1 on: November 09, 2011, 11:31:51 pm »
关于 VB HIDmodule  BUG 发现

首先不知道我现在使用的版本是不是低的.

BUG 发生以下情况:

1,在PC 只有我设计的USB HID 设备时.所有的通信状态,断开,联接.通信.都没有问题!

2,当PC 有多个HID 设备存在,只能重新启动应用程序才能找到我的USB HID .通信没有问题! 但是我的USB HID 断开联接,应用程序再也找不到HID 设备


我是来自中国

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Found on VB HIDmodule BUG
« Reply #2 on: November 10, 2011, 09:57:37 am »
Thank you for this fix!

Jan

ivws

  • Member
  • ***
  • Posts: 3
USB HID_DS18B20 v1.2
« Reply #3 on: November 11, 2011, 02:31:28 am »
http://pic16.com/bbs/dispbbs.asp?boardid=8&id=62191&page=1&star=1


Not,
 Why not upload pictures, files?

 I do this project: PIC16F73 + PDIUSBD12 + DS18B20
 Thermometer and one output to control LED

 We welcome your comments and access