GetUSBDeviceInfo example

Can anyone give an example of how to use MacUSBNotificationMSB.GetUSBDeviceInfo? Also, I am confused with how to use the Constructor(vendor as integer = 0, product as integer = 0). Does that means the notification events can be filtered by vendor ID and Product ID? example? Thanks!

For example, if I want to make sure that an Remove Device event is caused by a specific usb device unplug action. How can I do that?

You can setup MacUSBNotificationMBS to watch for any device (zeros) or specific product/vendor IDs.
And than when you got a DeviceAdded event, you can use the function GetUSBDeviceInfo to query the product/vendor ID of the device attached.

see the Mac USB Notification.rbp example project.

@Christian Schmitz

Yes, I just run the project. the further question is how can I tell which exact usb device it is? for example, when I use following code,

to watch the notification caused by vid = 1027, pid = 24577, then how can I query, for example, serial number to identify the exact device? Suppose I have multiple devices with same pid/vid connected, I think, only the serial number to tell which is which. So when I unplug one of them, I hope the notification can also tell exact device is unpluged.

So I added a shared property,
GetUSBDeviceInfo(DeviceHandle As integer, byref Vendor As string, byref Product As string, byref SerialNumber As string, byref Revision As integer)
under MyMacUSBNotificationMBS. when I call it, how can I pass those parameters as byRef? What do I need to do?

[quote=46147:@BO CHEN]@Christian Schmitz

Yes, I just run the project. the further question is how can I tell which exact usb device it is? for example, when I use following code,

to watch the notification caused by vid = 1027, pid = 24577, then how can I query, for example, serial number to identify the exact device? Suppose I have multiple devices with same pid/vid connected, I think, only the serial number to tell which is which. So when I unplug one of them, I hope the notification can also tell exact device is unpluged.

So I added a shared property,
GetUSBDeviceInfo(DeviceHandle As integer, byref Vendor As string, byref Product As string, byref SerialNumber As string, byref Revision As integer)
under MyMacUSBNotificationMBS. when I call it, how can I pass those parameters as byRef? What do I need to do?[/quote]
well, at the last part of my previous reply, I mean, for example, all I know about a usb device is pid/vid/serial number, but I also need to pass devicehandle, revision. Where to find those two parameters? How can I pass the current unplug device info to it?

I also have questions about properties.lookup(“USB Vendor ID”,"") and similar codes, how do I know what is inside of properties? from the example I know there are Vendor ID, Vendor Name, Product ID, Product Name, something else?

Calling byref is not so difficult. Just declare local variables:

dim Vendor As string
dim Product As string
dim SerialNumber As string
dim Revision As integer

and call the method:

if GetUSBDeviceInfo(DeviceHandle, Vendor, Product, SerialNumber, Revision) then
msgbox "got values: "+ SerialNumber
end if

[quote=46159:@Christian Schmitz]Calling byref is not so difficult. Just declare local variables:

dim Vendor As string
dim Product As string
dim SerialNumber As string
dim Revision As integer

and call the method:

if GetUSBDeviceInfo(DeviceHandle, Vendor, Product, SerialNumber, Revision) then
msgbox "got values: "+ SerialNumber
end if[/quote]

properties.lookup(“USB Vendor ID”,"") and similar codes

how do I know what is inside of properties? from the example I know there are Vendor ID(idVendor), Vendor Name(USB Vendor Name), Product ID(idProduct), Product Name(USB Product Name), something else?

[quote=46159:@Christian Schmitz]Calling byref is not so difficult. Just declare local variables:

dim Vendor As string
dim Product As string
dim SerialNumber As string
dim Revision As integer

and call the method:

if GetUSBDeviceInfo(DeviceHandle, Vendor, Product, SerialNumber, Revision) then
msgbox "got values: "+ SerialNumber
end if[/quote]
And the code is not working, I added into example project. No msgbox popup.

did you debug it?
make a breakpoint?

[quote=46165:@Christian Schmitz]did you debug it?
make a breakpoint?[/quote]
yes,
DeviceHandle 32779
NewDevice True
All other variables is null
do I need to do something in the GetUSBDeviceInfo that shared method? because when I debug, it ran into GetUSBDeviceInfo Function is empty, so do I need manually give the value?

Any updates?