USB HID EasyWay !

For issues with communication ports, protocols, etc.
test1234
Posts: 40
Joined: Sep 29, 2006 17:10

USB HID EasyWay !

Postby test1234 » Apr 11, 2009 6:12

Code: Select all

#Include "windows.bi"
Screen 19
Dim hPort As HANDLE,HID_DEVICE As String,VALUE As String,GUID As String
GUID="{4d1e55b2-f16f-11cf-88cb-001111000030}"
VALUE="HID#Vid_04d8&Pid_0033#6&34f879b0&0&0000"
 ' "VALUE=" IS YOUR USB DEVICE USB HID VALUE FROM DEVICE MANAGER
 ' "USB Human Interface Device" -> "details" -> "Bus Relations"  !
 ' "Ctrl+C/V TO COPY AND PASTE , NEXT EXCHANGE "\" WITH "#"
 ' "HID\Vid_04d8&Pid_0033\6&34f879b0&0&000" IN THIS CASE PICKIT2  USB HID VALUE ON MY PC
 '---------------------------------------------------------------- !

HID_DEVICE="\\?\"&VALUE & "#" & GUID
hPort = CreateFile(HID_DEVICE, _
  GENERIC_READ Or GENERIC_WRITE, _
  FILE_SHARE_READ Or FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0)

? HID_DEVICE:if ( hPort = INVALID_HANDLE_VALUE ) Then    ?"ERROR"
 
Sleep


but 'value=' value is different on different computers
Oceano
Posts: 43
Joined: Jun 05, 2009 20:37
Contact:

Re: USB HID EasyWay !

Postby Oceano » Jun 06, 2010 23:18

Your program works correctly.

I have also PICKIT2, but in my case has this value:

VID_04D8&PID_0033#6&2FBF350C&0&0000

Thanks for sharing.
BrianKudsk
Posts: 24
Joined: Sep 08, 2010 20:27
Location: Florida

Postby BrianKudsk » Sep 13, 2010 19:16

I understood the Bus Relations. Where do I find the GUID?
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Postby MichaelW » Sep 13, 2010 20:12

Assuming that hid.dll is present on your system, you can call the HidD_GetHidGuid function:

http://msdn.microsoft.com/en-us/library ... 85%29.aspx

Code: Select all

#include "windows.bi"
#include once "win\setupapi.bi"
#include once "win\ocidl.bi"

extern "windows"
declare sub HidD_GetHidGuid lib "hid"( byval HidGuid as LPGUID )
end extern

dim guid as guid
dim guids as lpolestr

HidD_GetHidGuid( @guid )
StringFromIID( @guid, @guids )
print *guids

sleep

For reference, here is a module definition file for the version 5.0.2195.6655 hid.dll on my system:

Code: Select all

LIBRARY HID.DLL
EXPORTS
HidD_FlushQueue@4
HidD_FreePreparsedData@4
HidD_GetAttributes@8
HidD_GetConfiguration@12
HidD_GetFeature@12
HidD_GetHidGuid@4
HidD_GetIndexedString@16
HidD_GetManufacturerString@12
HidD_GetNumInputBuffers@8
HidD_GetPhysicalDescriptor@12
HidD_GetPreparsedData@8
HidD_GetProductString@12
HidD_GetSerialNumberString@12
HidD_Hello@8
HidD_SetConfiguration@12
HidD_SetFeature@12
HidD_SetNumInputBuffers@8
HidP_GetButtonCaps@16
HidP_GetCaps@8
HidP_GetData@24
HidP_GetExtendedAttributes@20
HidP_GetLinkCollectionNodes@12
HidP_GetScaledUsageValue@32
HidP_GetSpecificButtonCaps@28
HidP_GetSpecificValueCaps@28
HidP_GetUsageValue@32
HidP_GetUsageValueArray@36
HidP_GetUsages@32
HidP_GetUsagesEx@28
HidP_GetValueCaps@16
HidP_InitializeReportForID@20
HidP_MaxDataListLength@8
HidP_MaxUsageListLength@12
HidP_SetData@24
HidP_SetScaledUsageValue@32
HidP_SetUsageValue@32
HidP_SetUsageValueArray@36
HidP_SetUsages@32
HidP_TranslateUsagesToI8042ScanCodes@24
HidP_UnsetUsages@32
HidP_UsageListDifference@20

Return to “Hardware Interfaces / Communication”

Who is online

Users browsing this forum: No registered users and 2 guests