USB HID Library
Re: USB HID Library
in the english help and other examples, all text strings are not english, (russian may be) like :
SetGadgetText(1,"Ïîäêëþ÷åíî HID óñòðîéñòâî")
do you have any translation for that??
thanks
SetGadgetText(1,"Ïîäêëþ÷åíî HID óñòðîéñòâî")
do you have any translation for that??
thanks
PureBasic: Surprisingly simple, diabolically powerful
Re: USB HID Library
I only have translated messages into English.
I hope, it will help you.
Device_IO.pb
DeviceInfo.pb
DeviceTest.pb
I hope, it will help you.
Device_IO.pb
Code: Select all
#USB_PID=1
#USB_VID=$1234
Global W_DeviceHandle=0, R_DeviceHandle=0
Procedure FindDevice_Timer()
Static Old_Test
Test=HID_Lib_DeviceTest(#USB_PID, #USB_VID)
If Test<>Old_Test
Old_Test=Test
If Test
HID_Lib_CloseDevice(W_DeviceHandle)
HID_Lib_CloseDevice(R_DeviceHandle)
W_DeviceHandle=HID_Lib_OpenDevice(#USB_PID, #USB_VID)
R_DeviceHandle=HID_Lib_OpenDevice(#USB_PID, #USB_VID)
SetGadgetText(1,"HID device is connected")
Else
HID_Lib_CloseDevice(W_DeviceHandle)
HID_Lib_CloseDevice(R_DeviceHandle)
W_DeviceHandle=0 : R_DeviceHandle=0
SetGadgetText(1,"Device not found ( PID — "+Hex(#USB_PID)+"H; VID — "+Hex(#USB_VID)+"H) ")
SetGadgetText(5,"No")
EndIf
EndIf
EndProcedure
Procedure SendDevice(Command.w)
If W_DeviceHandle
HID_Lib_WriteDevice(W_DeviceHandle, @Command,2)
Else
MessageRequester("", "There is no communication with the device!", #MB_OK|#MB_ICONWARNING)
EndIf
EndProcedure
Procedure Thread(*xx)
Dim InBuffer.b(2)
Repeat
If R_DeviceHandle
HID_Lib_ReadDevice(R_DeviceHandle, @InBuffer(), 2)
If InBuffer(1)=20
SetGadgetText(5,"Да")
ElseIf InBuffer(1)=40
SetGadgetText(5,"Нет")
EndIf
EndIf
Delay(10)
ForEver
EndProcedure
OpenWindow(0,0,0,320,100,"HID example",#PB_Window_MinimizeGadget|#PB_Window_Invisible|#PB_Window_ScreenCentered)
TextGadget(1,10,10,300,16,"The device isn't found ( PID — "+Hex(#USB_PID)+"H; VID — "+Hex(#USB_VID)+"H )",#PB_Text_Center)
ButtonGadget(2,40,70,120,24,"Turn LED On")
ButtonGadget(3,170,70,120,24,"Turn LED Off")
TextGadget(4,50,40,98,16,"Is button pressed?")
StringGadget(5,140,36,40,20,"No",1|#PB_String_ReadOnly)
FindDevice_Timer()
HideWindow(0,0)
SetTimer_(WindowID(0),1,200,@FindDevice_Timer())
CreateThread(@Thread(),0)
Repeat
Event=WaitWindowEvent()
If Event=#PB_Event_Gadget
Select EventGadget()
Case 2
SendDevice($AA00)
Case 3
SendDevice($5500)
EndSelect
EndIf
Until Event=#PB_Event_CloseWindow
Code: Select all
Procedure HID_DeviceInfo()
ClearGadgetItems(0)
Info.HID_Lib_DeviceInfo
If HID_Lib_DeviceInfo(@Info)
If Info\CountDevice>0
For i=0 To Info\CountDevice-1
AddGadgetItem(0,i,Info\DeviceInfo[i]\Manufacturer)
SetGadgetItemText(0,i,Info\DeviceInfo[i]\Product,1)
SetGadgetItemText(0,i,Hex(Info\DeviceInfo[i]\ProductID,#PB_Word)+"H",2)
SetGadgetItemText(0,i,Hex(Info\DeviceInfo[i]\VendorID,#PB_Word)+"H",3)
SetGadgetItemText(0,i,Hex(Info\DeviceInfo[i]\VersionNumber,#PB_Word)+"H",4)
SetGadgetItemText(0,i,Info\DeviceInfo[i]\SerialNumber,5)
SetGadgetItemText(0,i,Str(Info\DeviceInfo[i]\NumInputBuffers),6)
SetGadgetItemText(0,i,Str(Info\DeviceInfo[i]\InputReportByteLength),7)
SetGadgetItemText(0,i,Str(Info\DeviceInfo[i]\OutputReportByteLength),8)
SetGadgetItemText(0,i,Str(Info\DeviceInfo[i]\FeatureReportByteLength),9)
Next i
EndIf
EndIf
EndProcedure
OpenWindow(0,0,0,930,294,"USB HID devices info — HID_Lib Demo",#PB_Window_MinimizeGadget|#PB_Window_Invisible|#PB_Window_ScreenCentered|#PB_Window_SizeGadget)
SmartWindowRefresh(0, 1)
ListIconGadget(0,2,2,924,290,"Manufacturer",100,#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect)
AddGadgetColumn(0,1,"Product",100)
AddGadgetColumn(0,2,"PID",48)
AddGadgetColumn(0,3,"VID",48)
AddGadgetColumn(0,4,"Version #",90)
AddGadgetColumn(0,5,"Serial #",104)
AddGadgetColumn(0,6,"Input buffers number",110)
AddGadgetColumn(0,7,"Input report size",120)
AddGadgetColumn(0,8,"Output report size",124)
AddGadgetColumn(0,9,"FEATURE",70)
HID_DeviceInfo()
HideWindow(0,0)
AddWindowTimer(0, 1, 400)
Repeat
Event=WaitWindowEvent()
If Event=#PB_Event_Timer
If EventTimer()=1
HID_DeviceInfo()
EndIf
ElseIf Event=#PB_Event_SizeWindow
ResizeGadget(0, #PB_Ignore, #PB_Ignore, WindowWidth(0)-4, WindowHeight(0)-4)
EndIf
Until Event = #PB_Event_CloseWindow
Code: Select all
#USB_PID=1
#USB_VID=$1234
Procedure Timer1()
If HID_Lib_DeviceTest(#USB_PID, #USB_VID)=1
SetGadgetText(1,"Device is conected")
SetGadgetColor(1,#PB_Gadget_FrontColor,$92616D)
Else
SetGadgetText(1,"Device not found")
SetGadgetColor(1,#PB_Gadget_FrontColor,$0000FF)
EndIf
EndProcedure
OpenWindow(0,0,0,280,100,"HID_Lib_DeviceTest",#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)
TextGadget(0,40,10,200,16,"PID - "+Hex(#USB_PID)+"H; VID - "+Hex(#USB_VID)+"H",#PB_Text_Center )
TextGadget(1,80,40,200,16,"")
Timer1()
AddWindowTimer(0, 1, 500)
Repeat
Event=WaitWindowEvent()
If Event=#PB_Event_Timer
If EventTimer()=1
Timer1()
EndIf
EndIf
Until Event = #PB_Event_CloseWindow
Re: USB HID Library
Hi,
the HID Library looks great and i would like to use it! Unfortunately my avira antivir reports malware. Things like Rabbit.bcz, Rabbit.bda, Rabbit.bcy. Did anybody make the same experience? Can anybody give a proof that there is no malware inside or is the source code available?
thanks and best regards!
the HID Library looks great and i would like to use it! Unfortunately my avira antivir reports malware. Things like Rabbit.bcz, Rabbit.bda, Rabbit.bcy. Did anybody make the same experience? Can anybody give a proof that there is no malware inside or is the source code available?
thanks and best regards!
Re: USB HID Library
HID_Lib 4.51: http://www.virustotal.com/file-scan/rep ... 1317735830fogmaster wrote:...Unfortunately my avira antivir reports malware...
- DoubleDutch
- Addict
- Posts: 3219
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
Re: USB HID Library
Are you going to do a release of the lib for the latest x86 and x64 versions of PureBasic?
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system
-
- Addict
- Posts: 1443
- Joined: Wed Nov 12, 2008 5:01 pm
- Location: Russia
Re: USB HID Library
Added to first post topics library for PureBasic 4.61 x64.DoubleDutch wrote:Are you going to do a release of the lib for the latest x86 and x64 versions of PureBasic?
- DoubleDutch
- Addict
- Posts: 3219
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
Re: USB HID Library
Thanks.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system
Re: HID_Lib - Library
yes! you can read the code scanned directly using the library very easily.ColBoy wrote:If I have a USB HID device, like a barcode scanner, does that mean I can read the code scanned directly using this library, or is there another hump that needs to be conquered?
Re: USB HID Library
Hi:
I tried to run "device_io.pb", I got library "misc" missing (needed buy usb_hid library).
is there something changed with latest version of PB?
thanks
I tried to run "device_io.pb", I got library "misc" missing (needed buy usb_hid library).
is there something changed with latest version of PB?
thanks
PureBasic: Surprisingly simple, diabolically powerful
-
- Addict
- Posts: 1443
- Joined: Wed Nov 12, 2008 5:01 pm
- Location: Russia
Re: USB HID Library
What version of PB and libraries?
Very similar to what PB version 5.2x, and a library for the previous version.
Library for 5.2x.
x86.
x64.
You can also use HID module ("USB HID Library" is not needed). http://purebasic.mybb.ru/viewtopic.php?id=471
Very similar to what PB version 5.2x, and a library for the previous version.
Library for 5.2x.
x86.
x64.
You can also use HID module ("USB HID Library" is not needed). http://purebasic.mybb.ru/viewtopic.php?id=471
Re: USB HID Library
Thank you so much
I use PB 5.22-x86 under W7-x64
messages are in Russian, it will be great if you can later put the english equivalent in comments aside.
Excellent anyway
Edit: device_io.pb still asking for Misc library, deviceinfo and devicetest are OK
I use PB 5.22-x86 under W7-x64
messages are in Russian, it will be great if you can later put the english equivalent in comments aside.
Excellent anyway
Edit: device_io.pb still asking for Misc library, deviceinfo and devicetest are OK
PureBasic: Surprisingly simple, diabolically powerful
-
- Addict
- Posts: 1443
- Joined: Wed Nov 12, 2008 5:01 pm
- Location: Russia
Re: USB HID Library
Maybe it's because that was installed a previous version of the library.morosh wrote:device_io.pb still asking for Misc library, deviceinfo and devicetest are OK
Delete files HID_Lib, in the folder PureLibraries\UserLibraries and all subfolders in SubSystems.
Then install the library "USB HID Library".
Re: USB HID Library
None of this code works.
Used both HID_Lib_PB_5_21_x86 and HID_Lib_PB_5_21_x64 on Windows 7 64-bit
PureBasic version 5.22 LTS
DeviceInfo.pb -- "Structure not found: HID_Lib_DeviceInfo"
Device_IO.pb -- too many POLINIK errors
DeviceTest.pb -- too many POLINK errors
USB_Termo.pb -- "Icon file not found"
Compiler unable to find UserLibThreadSafe.
None of it compiles and runs.
Used both HID_Lib_PB_5_21_x86 and HID_Lib_PB_5_21_x64 on Windows 7 64-bit
PureBasic version 5.22 LTS
DeviceInfo.pb -- "Structure not found: HID_Lib_DeviceInfo"
Device_IO.pb -- too many POLINIK errors
DeviceTest.pb -- too many POLINK errors
USB_Termo.pb -- "Icon file not found"
Compiler unable to find UserLibThreadSafe.
None of it compiles and runs.