Platforms to show: All Mac Windows Linux Cross-Platform

/USB/HID Linux/USB Devices Linux


Required plugins for this example: MBS USB Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /USB/HID Linux/USB Devices Linux

This example is the version from Fri, 19th Jun 2014.

Project "USB Devices Linux.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Sub Open() if not TargetLinux then MsgBox "This application requires Linux." quit end if // check platform dim s as new Shell s.Execute "uname -m" if s.Result = "x86_64" then MsgBox "The HID class works only on 32 bit linux systems. It will work on 64 bit Linux once REAL Studio creates true 64 bit applications." quit end if End EventHandler
End Class
Class Window1 Inherits Window
Control Listbox1 Inherits Listbox
ControlInstance Listbox1 Inherits Listbox
End Control
Control BevelButton1 Inherits BevelButton
ControlInstance BevelButton1 Inherits BevelButton
EventHandler Sub Action() dim e as integer = LinuxUSBBusMBS.RescanDevices MsgBox str(e)+" new/removed devices." update End EventHandler
End Control
EventHandler Sub Open() update End EventHandler
Sub Add(d as LinuxUSBBusMBS) while d<>nil dim c as LinuxUSBDeviceMBS = d.Devices if c<>Nil then add c end if d = d.NextBus wend End Sub
Sub Add(d as LinuxUSBDeviceDescriptionMBS) dim l as Listbox = window1.Listbox1 l.AddRow d.ProductName l.cell(l.LastIndex,1)=d.Manufacturer l.cell(l.LastIndex,2)=d.SerialNumber l.cell(l.LastIndex,3)=str(d.Product) l.cell(l.LastIndex,4)=str(d.Vendor) dim s as string dim n as integer = d.DeviceClass Select case n case d.kDeviceClassAudio s = " Audio" case d.kDeviceClassCOMM s = " COMM" case d.kDeviceClassDATA s = " DATA" case d.kDeviceClassHID s = " HID" case d.kDeviceClassHUB s = " HUB" case d.kDeviceClassMassStorage s = " MassStorage" case d.kDeviceClassPrinter s = " Printer" else s = " ?" end Select l.cell(l.LastIndex,5)=str(n)+s l.cell(l.LastIndex,6)=str(d.DeviceSubClass) l.cell(l.LastIndex,7)=str(d.DeviceProtocol) l.cell(l.LastIndex,8)=str(d.MaxPacketSize0) Exception End Sub
Sub Add(d as LinuxUSBDeviceMBS) dim u as LinuxUSBDeviceDescriptionMBS = d.Descriptor if u<>Nil then add u end if dim c as integer = d.ChildrenCount-1 for i as integer = 0 to c dim dd as LinuxUSBDeviceMBS = d.Children(i) if dd<>Nil then add dd end if next End Sub
Sub Update() Listbox1.DeleteAllRows dim u as LinuxUSBBusMBS = LinuxUSBBusMBS.Buses add u End Sub
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
End Project

See also:

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


The biggest plugin in space...