Platforms to show: All Mac Windows Linux Cross-Platform

Back to MacHIDMBS class.

MacHIDMBS.Close

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 6.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Closes the active connection.

MacHIDMBS.Connect

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 6.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Creates a connection to the current device.
Example
Function OpenUSBDevice() As boolean
dim i as Integer
dim h as MacHIDMBS

h=FindDevice // see FindFirst example

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

h.Connect

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

h.InstallCallback

Return true

End Function

Lasterror is set.

Lasterror values for this function:
-1Not supported (Windows and Linux).
0Everything okay.
1Failed to get IOKit Plugin Interface for this IO object.
2Failed to query interface
3Failed to open interface
4Failed to create async port
5Failed to create async event source
6no longer used
7Failed to start queue

MacHIDMBS.Disconnect

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 6.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Disconnets current USB device.

Lasterror is set.

MacHIDMBS.FindFirstDevice as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 6.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Finds the first device and loads the properties.
Example
Function FindDevice() As MyMacHIDMBS
dim h as MyMacHIDMBS
dim p as string

h=new MyMacHIDMBS // 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.

MacHIDMBS.FindNextDevice as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 6.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Finds next device.

Returns true on success and false on failure.

MacHIDMBS.HIDProperties as Variant

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 15.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Queries HID properties dictionary.

Value is a CFDictionaryMBS with details about current device. Returned as Variant to reduce plugin dependencies.

The plugin queries this dictionary to return SerialNumber, ProductID, Manufacturer, Product, VendorID and VersionNumber.

MacHIDMBS.InstallCallback

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 6.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Installs the callback used for the event handler.

Lasterror is set.
Please use after connect. For use with ReceivedData event.

Some examples using this method:

MacHIDMBS.Manufacturer as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 7.5 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
The manufacturer name.

On any error an empty string is returned.

MacHIDMBS.Product as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 6.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
The product string of the selected device.

Lasterror is set.

MacHIDMBS.ProductID as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 6.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
The product ID of the selected device.

Lasterror is set.

MacHIDMBS.ReadMessage(ReportID as Integer, reportType as Integer, length as Integer) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 14.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Reads a message from usb device.

This is for synchronously operation without the event/callback.
You can specify report id, report type and the maximum length to read.
Also set timeout property.

Doesn't work if InstallCallback with event is used.

MacHIDMBS.ReadMessageMemory(ReportID as Integer, reportType as Integer, length as Integer) as memoryblock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 14.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Reads a message from usb device.

This is for synchronously operation without the event/callback.
You can specify report id, report type and the maximum length to read.
Also set timeout property.

Doesn't work if InstallCallback with event is used.

MacHIDMBS.SendMessage(data as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 6.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Sends a message to the USB device.

A connection must be open.
Lasterror is set. Lasterror -536854447 is an USB timeout.
Uses kIOHIDReportTypeOutput.

See also:

MacHIDMBS.SendMessage(ReportID as Integer, reportType as Integer, data as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 8.6 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Sends a message to the USB device.

A connection must be open.
Lasterror is set. Lasterror -536854447 is an USB timeout.
ReportType can be kIOHIDReportTypeOutput or kIOHIDReportTypeFeature.

See also:

MacHIDMBS.SendMessageMemory(data as memoryblock, offset as Integer, length as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 6.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Sends a message to the USB device.

A connection must be open.
Lasterror is set. Lasterror -536854447 is an USB timeout.
Internally ReportID=0 is used.

While writing a crossplatform application for one specific device we saw the following thing: The data buffer for the SendMessageMemory call must be 8 bytes long on Mac (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.
Uses kIOHIDReportTypeOutput.

See also:

MacHIDMBS.SendMessageMemory(ReportID as Integer, reportType as Integer, data as memoryblock, offset as Integer, length as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 8.6 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Sends a message to the USB device.

A connection must be open.
Lasterror is set. Lasterror -536854447 is an USB timeout.
ReportType can be kIOHIDReportTypeOutput or kIOHIDReportTypeFeature.

See also:

MacHIDMBS.SerialNumber as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 6.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
The serial number of the current selected device.

Lasterror is set.

MacHIDMBS.VendorID as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 6.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
The vendor ID of the selected device.

Lasterror is set.

MacHIDMBS.VersionNumber as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 7.5 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
The device specific version number.

Value can be anything.
On any error, 0 is returned.

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


The biggest plugin in space...