rageworx / listusb

A detailed listing USB device for macOS shell(console).
GNU General Public License v3.0
3 stars 1 forks source link

Multiple port by port #17

Open rageworx opened 3 months ago

rageworx commented 3 months ago

Listusb need to be improved by printing multiple port complex connection.

eg.

BUS 003
 + Port 1
    + Port 1
        +Port 3
        +Port 1
        +Port 2
rageworx commented 3 months ago

Current state:

>  lsusb -t
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=dwc_otg/1p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
        |__ Port 1: Dev 3, If 0, Class=Hub, Driver=hub/3p, 480M
            |__ Port 2: Dev 5, If 1, Class=Video, Driver=uvcvideo, 480M
            |__ Port 2: Dev 5, If 0, Class=Video, Driver=uvcvideo, 480M
            |__ Port 1: Dev 6, If 0, Class=Vendor Specific Class, Driver=lan78xx, 480M
        |__ Port 2: Dev 7, If 0, Class=Mass Storage, Driver=usb-storage, 480M
        |__ Port 3: Dev 4, If 0, Class=Mass Storage, Driver=usb-storage, 480M

and ...

>  bin/listusb -t
WARNING: some linux not able to read correct USB information as normal user. Use `sudo` to run listusb to correct information if some informations are displayed as empty.
listusb, version 0.2.4.29, (C)Copyrighted 2023 Raphael Kim, w/ libusb v1.0.26
Bus 001 : 7 devices
  +-- Port 003 [14CD:1212] USB 2.0, PER, , ,
  +-- Port 002 [043E:70F1] USB 2.0, PER, , ,
  +-- Port 002 [EB1A:2571] USB 2.0, MISC., , ,
  +-- Port 001 [0424:7800] USB 2.1, VSC, , ,
  +-- Port 001 [0424:2514] USB 2.0, HUB, , ,
  +-- Port 001 [0424:2514] USB 2.0, HUB, , ,
  +-- Port 000 [1D6B:0002] USB 2.0, HUB, , ,
total 7 devices found.

HUB -> HUB -> device s...

rageworx commented 3 months ago

Need to use libusb_get_port_numbers https://github.com/libusb/libusb/blob/e678b3fad58a508cbd0a6e6dc777fb48346f948b/examples/listdevs.c#L42

rageworx commented 3 months ago

this issue related in branch 'impl/issue_17'.

rageworx commented 3 months ago

It need to ...

  1. stack printing string to vector
  2. and reordering by port path.
  3. then prints each string to stdout.