Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

WinHIDMBS.Close
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method USB MBS USB Plugin 7.5 No Yes No Yes, Windows only No
Function: Closes the active connection.

Feedback, Comments & Corrections

WinHIDMBS.Connect as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method USB MBS USB Plugin 7.5 No Yes No Yes, Windows only No
Function: Creates a connection to the current device.
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
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.

Feedback, Comments & Corrections

WinHIDMBS.DevicePath as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method USB MBS USB Plugin 9.3 No Yes No Yes, Windows only No
Function: The internal path used by Windows to identify the device.
Notes: Only for debugging.

Feedback, Comments & Corrections

WinHIDMBS.Disconnect
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method USB MBS USB Plugin 7.5 No Yes No Yes, Windows only No
Function: Disconnets current USB device.
Notes: Lasterror is set.

Feedback, Comments & Corrections

WinHIDMBS.FindFirstDevice as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method USB MBS USB Plugin 7.5 No Yes No Yes, Windows only No
Function: Finds the first device and loads the properties.
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
Notes:
Returns true on success and false on failure.
On Windows finds only devices which can be opened for Read/Write.

Feedback, Comments & Corrections

WinHIDMBS.FindNextDevice as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method USB MBS USB Plugin 7.5 No Yes No Yes, Windows only No
Function: Finds next device.
Notes: Returns true on success and false on failure.

Feedback, Comments & Corrections

WinHIDMBS.GetInputReport(data as MemoryBlock, Offset as Integer = 0, Length as Integer = 0) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method USB MBS USB Plugin 15.0 No Yes No Yes, Windows only No
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

Feedback, Comments & Corrections

WinHIDMBS.InstallListener(PollSize as Integer) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method USB MBS USB Plugin 7.8 No Yes No Yes, Windows only No
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.
This is an alternative way compared to ReadMessage functions.

Feedback, Comments & Corrections

WinHIDMBS.Manufacturer as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method USB MBS USB Plugin 7.5 No Yes No Yes, Windows only No
Function: The manufacturer name.
Notes:
On any error an empty string is returned.
Lasterror is set.

Feedback, Comments & Corrections

WinHIDMBS.PollMemory as memoryblock
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method USB MBS USB Plugin 7.8 No Yes No Yes, Windows only No
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.

Feedback, Comments & Corrections

WinHIDMBS.PollString as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method USB MBS USB Plugin 7.8 No Yes No Yes, Windows only No
Function: Reads a message from the device.
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
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.

Feedback, Comments & Corrections

WinHIDMBS.Product as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method USB MBS USB Plugin 7.5 No Yes No Yes, Windows only No
Function: The product string of the selected device.
Notes: Lasterror is set.

Feedback, Comments & Corrections

WinHIDMBS.ProductID as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method USB MBS USB Plugin 7.5 No Yes No Yes, Windows only No
Function: The product ID of the selected device.
Notes: Lasterror is set.

Feedback, Comments & Corrections

WinHIDMBS.ReadMessage(length as Integer, timeOut as Integer = 0) as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method USB MBS USB Plugin 13.3 No Yes No Yes, Windows only No
Function: Reads a message from the device.
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
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.

Feedback, Comments & Corrections

WinHIDMBS.ReadMessageMemory(length as Integer, timeOut as Integer = 0) as memoryblock
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method USB MBS USB Plugin 13.3 No Yes No Yes, Windows only No
Function: Reads a message from the device.
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
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.

Feedback, Comments & Corrections

WinHIDMBS.SendMessage(data as string) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method USB MBS USB Plugin 7.5 No Yes No Yes, Windows only No
Function: Sends a message to the USB device.
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))
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.

Feedback, Comments & Corrections

WinHIDMBS.SendMessageMemory(data as memoryblock, Offset as Integer = 0, length as Integer = 0) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method USB MBS USB Plugin 7.5 No Yes No Yes, Windows only No
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.

Feedback, Comments & Corrections

WinHIDMBS.SerialNumber as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method USB MBS USB Plugin 7.5 No Yes No Yes, Windows only No
Function: The serial number of the current selected device.
Notes: Lasterror is set.

Feedback, Comments & Corrections

WinHIDMBS.SetOutputReport(data as MemoryBlock, Offset as Integer = 0, Length as Integer = 0) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method USB MBS USB Plugin 15.0 No Yes No Yes, Windows only No
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

Feedback, Comments & Corrections

WinHIDMBS.VendorID as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method USB MBS USB Plugin 7.5 No Yes No Yes, Windows only No
Function: The vendor ID of the selected device.
Notes: Lasterror is set.

Feedback, Comments & Corrections

WinHIDMBS.VersionNumber as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method USB MBS USB Plugin 7.5 No Yes No Yes, Windows only No
Function: The device specific version number.
Notes:
Value can be anything.
On any error, 0 is returned.
Lasterror is set.

Feedback, Comments & Corrections

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




Links
MBS FileMaker Plugins