BBC BASIC for Windows
Programming >> Communication and Input/Output >> USB HID
http://bb4w.conforums.com/index.cgi?board=communication&action=display&num=1288113622

USB HID
Post by wyzeowl on Oct 26th, 2010, 5:20pm

Hi Folks
I need to communicate with a usb HID. can anyone point me in the right direction.
Cheers
Re: USB HID
Post by admin on Oct 26th, 2010, 9:53pm

on Oct 26th, 2010, 5:20pm, wyzeowl wrote:
I need to communicate with a usb HID.

The way I know it's been done successfully is by using this DLL:

http://www.kadtronix.com/usbhidapi.htm

Unfortunately it's not free (it costs $39) but I'm reliably informed it makes the task very easy.

In principle you can probably do it directly from BB4W code, but I'm not aware of anybody having achieved it.

Richard.
Re: USB HID / USB Silicon lab
Post by dynamic35 on Mar 30th, 2011, 9:21pm

I have seen VB declaration:
Public Declare Function SI_Open Lib "SiUSBXp.dll" (ByVal dwDevice As UInt32, ByRef cyHandle As UInt32) As Integer

I can use BBC to read serial real time information along COM1...COM19 (thanks to many examples, advices by Richard in many discussions and manuals etc.) However, I am unable to read and write in my BBC4w program any information that moves in or out via my PC's USB port

That Siusbxp.dll ,I have in my pc now. How to change that VB statement into suitable format in BBC4w?
Rgs from Finland





Re: USB HID / USB Silicon lab
Post by admin on Mar 30th, 2011, 9:45pm

on Mar 30th, 2011, 9:21pm, dynamic35 wrote:
I have seen VB declaration:
Public Declare Function SI_Open Lib "SiUSBXp.dll" (ByVal dwDevice As UInt32, ByRef cyHandle As UInt32) As Integer
How to change that VB statement into suitable format in BBC4w?

Code:
      SYS "LoadLibrary", "SiUSBXp.dll" TO siusbxp%
      SYS "GetProcAddress", siusbxp%, "SI_Open" TO SI_Open 

Alternatively you can use Jon Ripley's LoadDLL library to do the same thing more neatly:

Code:
      SI_Open = FN_LoadDLL("SiUSBXp.dll","SI_Open") 

In either case you would call the function as follows:

Code:
      SYS SI_Open, dwDevice%, ^cyHandle% TO result% 

Richard.
Re: USB HID
Post by dynamic35 on Mar 30th, 2011, 9:48pm

THank you again very much..
Re: USB HID
Post by dynamic35 on Apr 4th, 2011, 9:32pm

on Mar 30th, 2011, 9:48pm, dynamic35 wrote:
THank you again very much..

This another finding from internet below is more complicated. How could this be written in BBC Basic?

Private Declare Function SI_Write Lib "SiUSBXp.dll" (ByVal handle As Long, ByVal Buffer As Long, ByVal NumBytesToWrite As Long, ByRef NumBytesWritten As Long) As Long

So I am trying to use an usb port instead of classical COM1 that was opened for random binary input output
19200, 8,N,1 . Silicon Labs driver

Rgs d mic

Ref discussions from
http://www.cygnal.org/ubb/Forum9/HTML/000811.html
Re: USB HID
Post by admin on Apr 4th, 2011, 9:43pm

on Apr 4th, 2011, 9:32pm, dynamic35 wrote:
How could this be written in BBC Basic?
Code:
Private Declare Function  SI_Write Lib "SiUSBXp.dll" (ByVal handle As Long, ByVal Buffer As Long, ByVal NumBytesToWrite As Long, ByRef NumBytesWritten As Long) As Long 


To call that function in BBC BASIC you would do:

Code:
SYS SI_Write, handle%, Buffer%, NumBytesToWrite%, ^NumBytesWritten% TO result% 

(having previously set Buffer% to point to the data to be written).

Richard.
Re: USB HID
Post by dynamic35 on Apr 10th, 2011, 7:40pm

The CP210x USB to UART Bridge Virtual COM Port (VCP) drivers are required for device operation as a Virtual COM Port to facilitate host communication with CP210x products. The command like this
port% = OPENUP("COM3: baud=19200 parity=N data=8 stop=1")
works well then if a serial equipment is pushed into an USB 'hole' in a PC.

In my Xp there must be found then- under device manager /system- COM & LPT port a following driver:
Silicon Labs CP210X USB Uart Bridge (COM 3)

My question is how to put/call into a BBC Basic program that Silicon labs driver?
cp2010x. manufacturing.dll such that the user has no need to install him/herself the driver under his/her system?