Platforms to show: All Mac Windows Linux Cross-Platform
Back to WinHIDMBS class.
WinHIDMBS.Close
Function:
Closes the active connection.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | USB | MBS USB Plugin | 7.5 | ❌ No | ✅ Yes | ❌ No | ❌ No | Desktop, Console & Web |
WinHIDMBS.Connect as boolean
Function:
Creates a connection to the current device.
Example:
Notes:
Lasterror is set.
Returns true on success and false on failure.
The plugin tries to open a read and a write connection. If both fail, connect returns false. If one is okay, it returns true.
Some devices don't allow read or write because of missing permissions.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | USB | MBS USB Plugin | 7.5 | ❌ No | ✅ Yes | ❌ No | ❌ No | Desktop, Console & Web |
Example:
Function OpenUSBDevice() As boolean
dim i as Integer
dim h as WinHIDMBS
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
Lasterror is set.
Returns true on success and false on failure.
The plugin tries to open a read and a write connection. If both fail, connect returns false. If one is okay, it returns true.
Some devices don't allow read or write because of missing permissions.
WinHIDMBS.DevicePath as string
Function:
The internal path used by Windows to identify the device.
Notes: Only for debugging.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | USB | MBS USB Plugin | 9.3 | ❌ No | ✅ Yes | ❌ No | ❌ No | Desktop, Console & Web |
Notes: Only for debugging.
WinHIDMBS.Disconnect
Function:
Disconnets current USB device.
Notes: Lasterror is set.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | USB | MBS USB Plugin | 7.5 | ❌ No | ✅ Yes | ❌ No | ❌ No | Desktop, Console & Web |
Notes: Lasterror is set.
WinHIDMBS.FindFirstDevice as boolean
Function:
Finds the first device and loads the properties.
Example:
Notes:
Returns true on success and false on failure.
On Windows finds only devices which can be opened for Read/Write.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | USB | MBS USB Plugin | 7.5 | ❌ No | ✅ Yes | ❌ No | ❌ No | Desktop, Console & Web |
Example:
Function FindDevice() As MyWinHIDMBS
dim h as MyWinHIDMBS
dim p as string
h=new MyWinHIDMBS // 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
Returns true on success and false on failure.
On Windows finds only devices which can be opened for Read/Write.
WinHIDMBS.FindNextDevice as boolean
Function:
Finds next device.
Notes: Returns true on success and false on failure.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | USB | MBS USB Plugin | 7.5 | ❌ No | ✅ Yes | ❌ No | ❌ No | Desktop, Console & Web |
Notes: Returns true on success and false on failure.
WinHIDMBS.GetInputReport(data as MemoryBlock, Offset as Integer = 0, Length as Integer = 0) as boolean
Function:
Returns an input reports from a top-level collection.
Notes:
This is very low level.
First byte of data block is report ID.
If Length is 0, we use size of memoryblock.
Returns true on success.
see also:
https://msdn.microsoft.com/en-us/library/windows/hardware/ff538945(v=vs.85).aspx
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | USB | MBS USB Plugin | 15.0 | ❌ No | ✅ Yes | ❌ No | ❌ No | Desktop, Console & Web |
Notes:
This is very low level.
First byte of data block is report ID.
If Length is 0, we use size of memoryblock.
Returns true on success.
see also:
https://msdn.microsoft.com/en-us/library/windows/hardware/ff538945(v=vs.85).aspx
WinHIDMBS.InstallListener(PollSize as Integer) as boolean
Function:
Installs a second thread which performs Read.
Example:
Notes:
Use PollString or PollMemory in a timer or a loop to get the data.
This is an alternative way compared to ReadMessage functions.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | USB | MBS USB Plugin | 7.8 | ❌ No | ✅ Yes | ❌ No | ❌ No | Desktop, Console & Web |
Example:
dim h as new WinHIDMBS
call h.InstallListener 9 // 8 bytes + Report ID
Use PollString or PollMemory in a timer or a loop to get the data.
This is an alternative way compared to ReadMessage functions.
WinHIDMBS.Manufacturer as string
Function:
The manufacturer name.
Notes:
On any error an empty string is returned.
Lasterror is set.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | USB | MBS USB Plugin | 7.5 | ❌ No | ✅ Yes | ❌ No | ❌ No | Desktop, Console & Web |
Notes:
On any error an empty string is returned.
Lasterror is set.
WinHIDMBS.PollMemory as memoryblock
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.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | USB | MBS USB Plugin | 7.8 | ❌ No | ✅ Yes | ❌ No | ❌ No | Desktop, Console & Web |
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
Function:
Reads a message from the device.
Example:
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.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | USB | MBS USB Plugin | 7.8 | ❌ No | ✅ Yes | ❌ No | ❌ No | Desktop, Console & Web |
Example:
dim m as WinHIDMBS // your WinHIDMBS object
dim s as string
do
s=m.PollString
loop until lenb(s)>0 // until we got something
MsgBox midb(s,2) // shows result. First byte is ReportID again
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
Function:
The product string of the selected device.
Notes: Lasterror is set.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | USB | MBS USB Plugin | 7.5 | ❌ No | ✅ Yes | ❌ No | ❌ No | Desktop, Console & Web |
Notes: Lasterror is set.
WinHIDMBS.ProductID as Integer
Function:
The product ID of the selected device.
Notes: Lasterror is set.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | USB | MBS USB Plugin | 7.5 | ❌ No | ✅ Yes | ❌ No | ❌ No | Desktop, Console & Web |
Notes: Lasterror is set.
WinHIDMBS.ReadMessage(length as Integer, timeOut as Integer = 0) as string
Function:
Reads a message from the device.
Example:
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.
Timeout is a timeout value in milliseconds.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | USB | MBS USB Plugin | 13.3 | ❌ No | ✅ Yes | ❌ No | ❌ No | Desktop, Console & Web |
Example:
dim m as WinHIDMBS
dim s as string
do
s=m.ReadMessage(48)
loop until lenb(s)>0 // until we got something
MsgBox midb(s,2) // shows result. First byte is ReportID again
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.
Timeout is a timeout value in milliseconds.
WinHIDMBS.ReadMessageMemory(length as Integer, timeOut as Integer = 0) as memoryblock
Function:
Reads a message from the device.
Example:
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.
Timeout is a timeout value in milliseconds.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | USB | MBS USB Plugin | 13.3 | ❌ No | ✅ Yes | ❌ No | ❌ No | Desktop, Console & Web |
Example:
dim m as WinHIDMBS
dim s as memoryblock
do
s=m.ReadMessageMemory(48)
loop until s<>nil // until we got something
MsgBox midb(s,2) // shows result. First byte is ReportID again
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.
Timeout is a timeout value in milliseconds.
WinHIDMBS.SendMessage(data as string) as Integer
Function:
Sends a message to the USB device.
Example:
Notes:
A connection must be open.
Returns number of bytes sent.
The first byte must be the Report ID which seems to be zero for most devices.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | USB | MBS USB Plugin | 7.5 | ❌ No | ✅ Yes | ❌ No | ❌ No | Desktop, Console & Web |
Example:
dim m as WinHIDMBS // your hid object
dim s as string
// 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))
A connection must be open.
Returns number of bytes sent.
The first byte must be the Report ID which seems to be zero for most devices.
WinHIDMBS.SendMessageMemory(data as memoryblock, Offset as Integer = 0, length as Integer = 0) as Integer
Function:
Sends a message to the USB device.
Notes:
A connection must be open.
Lasterror is set.
Returns number of bytes sent.
While writing a crossplatform application we saw the following thing: The data buffer for the SendMessageMemory call must be 8 bytes long on Mac for our device (with MacHIDMBS) and 61 bytes long for Windows (with WinHIDMBS) for our HID device. We have 1 byte for the ReportID and 60 data bytes where the first 8 are set like on the Mac. So if the calls fail on Windows, try with a higher length and check the WinHIDMBS.OutputReportByteLength property.
The first byte must be the Report ID which seems to be zero for most devices.
If length is zero, we use the length of memoryblock.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | USB | MBS USB Plugin | 7.5 | ❌ No | ✅ Yes | ❌ No | ❌ No | Desktop, Console & Web |
Notes:
A connection must be open.
Lasterror is set.
Returns number of bytes sent.
While writing a crossplatform application we saw the following thing: The data buffer for the SendMessageMemory call must be 8 bytes long on Mac for our device (with MacHIDMBS) and 61 bytes long for Windows (with WinHIDMBS) for our HID device. We have 1 byte for the ReportID and 60 data bytes where the first 8 are set like on the Mac. So if the calls fail on Windows, try with a higher length and check the WinHIDMBS.OutputReportByteLength property.
The first byte must be the Report ID which seems to be zero for most devices.
If length is zero, we use the length of memoryblock.
WinHIDMBS.SerialNumber as string
Function:
The serial number of the current selected device.
Notes: Lasterror is set.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | USB | MBS USB Plugin | 7.5 | ❌ No | ✅ Yes | ❌ No | ❌ No | Desktop, Console & Web |
Notes: Lasterror is set.
WinHIDMBS.SetOutputReport(data as MemoryBlock, Offset as Integer = 0, Length as Integer = 0) as boolean
Function:
Sends an output report.
Notes:
This is very low level.
First byte of data block is report ID.
If Length is 0, we use size of memoryblock.
Returns true on success.
see also
https://msdn.microsoft.com/en-us/library/windows/hardware/ff539690(v=vs.85).aspx
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | USB | MBS USB Plugin | 15.0 | ❌ No | ✅ Yes | ❌ No | ❌ No | Desktop, Console & Web |
Notes:
This is very low level.
First byte of data block is report ID.
If Length is 0, we use size of memoryblock.
Returns true on success.
see also
https://msdn.microsoft.com/en-us/library/windows/hardware/ff539690(v=vs.85).aspx
WinHIDMBS.VendorID as Integer
Function:
The vendor ID of the selected device.
Notes: Lasterror is set.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | USB | MBS USB Plugin | 7.5 | ❌ No | ✅ Yes | ❌ No | ❌ No | Desktop, Console & Web |
Notes: Lasterror is set.
WinHIDMBS.VersionNumber as Integer
Function:
The device specific version number.
Notes:
Value can be anything.
On any error, 0 is returned.
Lasterror is set.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | USB | MBS USB Plugin | 7.5 | ❌ No | ✅ Yes | ❌ No | ❌ No | Desktop, Console & Web |
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.
