MBS Plugin Documentation

Search:

Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchie

New in Version 7.0 7.1 7.2 7.3 7.4 7.5 7.6 7.7 7.8 8.0 8.1 8.2 8.3 8.4 8.5 8.6 8.7 9.0

The list of the   themes,   classes,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

class WinHIDMBS
class, HID, MBS USB Plugin (WinHID), class WinHIDMBS, Console safe, Plugin version: 7.5, Mac OS X: Does nothing, Windows: Works, Linux x86: Does nothing, Feedback.

Function: A class to work with HID devices on Windows.
Example:
dim m as new WinHIDMBS
dim s as string

#if not TargetWin32
MsgBox "This example requires Windows."
#endif

if m.FindFirstDevice then

do
ListBox1.AddRow ""

ListBox1.Cell(ListBox1.LastIndex,0)=hex(m.ProductID)
ListBox1.Cell(ListBox1.LastIndex,1)=hex(m.VendorID)
ListBox1.cell(ListBox1.LastIndex,2)=m.Product
ListBox1.cell(ListBox1.LastIndex,3)=m.Manufacturer
ListBox1.cell(ListBox1.LastIndex,4)=m.SerialNumber
ListBox1.cell(ListBox1.LastIndex,5)=hex(m.VersionNumber)

if left(m.Product,3)="RF1" then // my test device
m.Connect
if m.Lasterror=0 then
// write 9 bytes report
// first byte is report ID plus 8 byte data
s=chr(0)+"P"+chr(0)+chr(0)+chr(0)+chr(0)+chr(0)+chr(0)+chr(0)

MsgBox "Send bytes: "+str(m.SendMessage(s))

do
s=m.ReadMessage(17)
loop until lenb(s)>0 // until we got something
MsgBox midb(s,2) // shows result. First byte is ReportID again

m.Disconnect
end if
end if

loop until not m.FindNextDevice

end if

Title=str(ListBox1.ListCount)+" devices found."

WinHIDMBS.Close
method, HID, MBS USB Plugin (WinHID), class WinHIDMBS, Console safe, Plugin version: 7.5, Mac OS X: Does nothing, Windows: Works, Linux x86: Does nothing, Feedback.

Function: Closes the active connection.
WinHIDMBS.Connect as boolean
method, HID, MBS USB Plugin (WinHID), class WinHIDMBS, Console safe, Plugin version: 7.5, Mac OS X: Does nothing, Windows: Works, Linux x86: Does nothing, Feedback.

Function: Creates a connection to the current device.
Example:
Function OpenUSBDevice() As boolean
dim i as integer

h=FindDevice // see FindFirst example

if h=nil then
MsgBox "No XYZ device found."
Return false
end if

call h.Connect

if h.Lasterror<>0 then
MsgBox "Failed to connect to USB Device."
Return false
end if

Return true

End Function

Notes:
Lasterror is set.
Returns true on success and false on failure.
WinHIDMBS.Disconnect
method, HID, MBS USB Plugin (WinHID), class WinHIDMBS, Console safe, Plugin version: 7.5, Mac OS X: Does nothing, Windows: Works, Linux x86: Does nothing, Feedback.

Function: Disconnets current USB device.
Notes: Lasterror is set.
WinHIDMBS.FindFirstDevice as boolean
method, HID, MBS USB Plugin (WinHID), class WinHIDMBS, Console safe, Plugin version: 7.5, Mac OS X: Does nothing, Windows: Works, Linux x86: Does nothing, Feedback.

Function: Finds the first device and loads the properties.
Example:
Function FindDevice() As MyHID
dim h as MyHID
dim p as string

h=new MyHID // your own subclass of MacHIDMBS so you can get events

if h.FindFirstDevice then

p=h.Product
if p="MyProduct" then
Return h
end if

while h.FindNextDevice

p=h.Product
if p="MyProduct" then
Return h
end if

wend

end if
End Function

Notes:
Returns true on success and false on failure.
On Windows finds only devices which can be opened for Read/Write.
WinHIDMBS.FindNextDevice as boolean
method, HID, MBS USB Plugin (WinHID), class WinHIDMBS, Console safe, Plugin version: 7.5, Mac OS X: Does nothing, Windows: Works, Linux x86: Does nothing, Feedback.

Function: Finds next device.
Notes: Returns true on success and false on failure.
WinHIDMBS.InstallListener(PollSize as integer) as boolean
method, HID, MBS USB Plugin (WinHID), class WinHIDMBS, Console safe, Plugin version: 7.8, Mac OS X: Does nothing, Windows: Works, Linux x86: Does nothing, Feedback.

Function: Installs a second thread which performs Read.
Example:
dim h as new WinHIDMBS

call h.InstallListener 9 // 8 bytes + Report ID

Notes: Use PollString or PollMemory in a timer or a loop to get the data.
WinHIDMBS.Lasterror as Integer
property, HID, MBS USB Plugin (WinHID), class WinHIDMBS, Console safe, Plugin version: 7.5, Mac OS X: Does nothing, Windows: Works, Linux x86: Does nothing, Feedback.

Function: Last error code.
Notes:
0 is success.
-1 means that the function is not available.
else Windows error codes like 5 for Access Denied.
(Read and Write property)
WinHIDMBS.Manufacturer as string
method, HID, MBS USB Plugin (WinHID), class WinHIDMBS, Console safe, Plugin version: 7.5, Mac OS X: Does nothing, Windows: Works, Linux x86: Does nothing, Feedback.

Function: The manufacturer name.
Notes:
On any error an empty string is returned.
Lasterror is set.
WinHIDMBS.PollMemory as memoryblock
method, HID, MBS USB Plugin (WinHID), class WinHIDMBS, Console safe, Plugin version: 7.8, Mac OS X: Does nothing, Windows: Works, Linux x86: Does nothing, Feedback.

Function: Reads a message from the device.
Notes:
A connection must be open and InstallListener must be used.
Lasterror is set.
You may want to try this function in a loop or a timer till you get data.
WinHIDMBS.PollString as string
method, HID, MBS USB Plugin (WinHID), class WinHIDMBS, Console safe, Plugin version: 7.8, Mac OS X: Does nothing, Windows: Works, Linux x86: Does nothing, Feedback.

Function: Reads a message from the device.
Example:
do
s=m.PollString(17)
loop until lenb(s)>0 // until we got something
MsgBox midb(s,2) // shows result. First byte is ReportID again

Notes:
A connection must be open and InstallListener must be used.
Lasterror is set.
You may want to try this function in a loop or a timer till you get data.
WinHIDMBS.Product as string
method, HID, MBS USB Plugin (WinHID), class WinHIDMBS, Console safe, Plugin version: 7.5, Mac OS X: Does nothing, Windows: Works, Linux x86: Does nothing, Feedback.

Function: The product string of the selected device.
Notes: Lasterror is set.
WinHIDMBS.ProductID as integer
method, HID, MBS USB Plugin (WinHID), class WinHIDMBS, Console safe, Plugin version: 7.5, Mac OS X: Does nothing, Windows: Works, Linux x86: Does nothing, Feedback.

Function: The product ID of the selected device.
Notes: Lasterror is set.
WinHIDMBS.ReadMessage(length as integer) as string
method, HID, MBS USB Plugin (WinHID), class WinHIDMBS, Console safe, Plugin version: 7.5, Mac OS X: Does nothing, Windows: Works, Linux x86: Does nothing, Feedback.

Function: Reads a message from the device.
Example:
do
s=m.ReadMessage(17)
loop until lenb(s)>0 // until we got something
MsgBox midb(s,2) // shows result. First byte is ReportID again

Notes:
Length is the length of the receive buffer you want to use.
The string returned is 0 to length bytes long.
A connection must be open.
Lasterror is set.
You may want to try this function in a loop till you get data.

Read blocks the application until data is found.
Use InstallListener and Poll to get data without waiting.
WinHIDMBS.ReadMessageMemory(length as integer) as memoryblock
method, HID, MBS USB Plugin (WinHID), class WinHIDMBS, Console safe, Plugin version: 7.5, Mac OS X: Does nothing, Windows: Works, Linux x86: Does nothing, Feedback.

Function: Reads a message from the device.
Notes:
Length is the length of the receive buffer you want to use.
The memoryblock returned has a size of 0 to length bytes.
A connection must be open.
Lasterror is set.
You may want to try this function in a loop till you get data.

Read blocks the application until data is found.
Use InstallListener and Poll to get data without waiting.
WinHIDMBS.SendMessage(data as string) as integer
method, HID, MBS USB Plugin (WinHID), class WinHIDMBS, Console safe, Plugin version: 7.5, Mac OS X: Does nothing, Windows: Works, Linux x86: Does nothing, Feedback.

Function: Sends a message to the USB device.
Example:
// write 9 bytes report
// first byte is report ID plus 8 byte data
s=chr(0)+"P"+chr(0)+chr(0)+chr(0)+chr(0)+chr(0)+chr(0)+chr(0)
MsgBox "Send bytes: "+str(m.SendMessage(s))

Notes:
A connection must be open.
Returns number of bytes sent.
WinHIDMBS.SendMessageMemory(data as memoryblock, offset as integer, length as integer) as integer
method, HID, MBS USB Plugin (WinHID), class WinHIDMBS, Console safe, Plugin version: 7.5, Mac OS X: Does nothing, Windows: Works, Linux x86: Does nothing, Feedback.

Function: Sends a message to the USB device.
Notes:
A connection must be open.
Lasterror is set.
Returns number of bytes sent.
WinHIDMBS.SerialNumber as string
method, HID, MBS USB Plugin (WinHID), class WinHIDMBS, Console safe, Plugin version: 7.5, Mac OS X: Does nothing, Windows: Works, Linux x86: Does nothing, Feedback.

Function: The serial number of the current selected device.
Notes: Lasterror is set.
WinHIDMBS.VendorID as integer
method, HID, MBS USB Plugin (WinHID), class WinHIDMBS, Console safe, Plugin version: 7.5, Mac OS X: Does nothing, Windows: Works, Linux x86: Does nothing, Feedback.

Function: The vendor ID of the selected device.
Notes: Lasterror is set.
WinHIDMBS.VersionNumber as integer
method, HID, MBS USB Plugin (WinHID), class WinHIDMBS, Console safe, Plugin version: 7.5, Mac OS X: Does nothing, Windows: Works, Linux x86: Does nothing, Feedback.

Function: The device specific version number.
Notes:
Value can be anything.
On any error, 0 is returned.
Lasterror is set.

The items on this page are in the following plugins: MBS USB Plugin.