Welcome!
Important information
-- Spectre and Meltdown vulnerabilities
-- Change in MX sources

News
-- MX Linux on social media: here
-- Mepis support still here

Current releases
-- MX-17.1 Final release info here
-- antiX-17 release info here

New users
-- Please read this first, and don't forget to add system and hardware information to posts!
-- Here are the Forum Rules

New inxi feature, /sys based usb data

Message
Author
User avatar
h2-1
Forum Regular
Forum Regular
Posts: 429
Joined: Sat Nov 15, 2008 3:16 pm

Re: New inxi feature, /sys based usb data

#11 Post by h2-1 » Tue Aug 14, 2018 9:19 pm

pinxi 3.0.20-29 now fixes or enhances the following:

1. the case above where type: <vendor defined>,Printer appeared is corrected, now if the number of types > 1, and if 1 or more of the items in the array of types is not <vendor defined>, the vendor defined is removed.
2. Because the /sys based type: is actually working better than the lsusb based one, and is much easier to work with, I've altered the logic to replace at the last step the lsusb based type: with the /sys based type: data. This results in a significantly more accurate, and, better, fixable, type: handler, for example, almost all networking devices are vendor defined, but detecting if it's a network device is trivial using the sys based method. And I can extend those hacks over time to hopefully handle more cases of vendor defined, knowing something is a scanner would be nice, for example, though that's not covered in supported types as far as I know. It's quite easy to add integer based class/subclass/protocol matches too now, and there aren't actually all that many that matter.
The way I did this with lsusb was just a hack in the first place, so I don't have much reason to want to preserve what was really just a fast workaround to resolve some oddities with how type was handled by usb, those are easy to work with and not around if I code it myself.
3. Shows all the device types, not just the first one it found, the initial usb logic, which I literally whipped out during pinxi beta dev testing simply to verify that my block feature printer logic was actually working as expected, so I needed to add a few quick features, which turned out to be --slots and --usb (but I knew usb was very weak, it's far better now). For example, on my system, with a dual interface device that has 1 usb connection, it now correctly notes that there is a mouse and keyboard attached, or that it supports those two types.

New features of this are:
1. now shows hub ports, this is a big win, a major improvement, you will be surprised at what you see on your systems, for example, I have what is supposed to be a high end motherboard, but its bus 1 is a usb 2, and extends to the usb 3, allegedly, board headers, which means, I only get usb 2 out of them, and now I know why. that has 14 ports, I believe 6 or 8 for headers, and the rest in the back of the board as plugs.
2. shows now the real bus id path : device ID, this makes it far more useful, and also showed me during testing a big bug with how I was sorting data based only on the bus id/device ids from lsusb, the bug was that leads to assigning devices to the wrong hub at times. Changing sorting to be an alphabetically sorted modified string based on the true bus/port/port etc ids solved this bug, which nobody had noticed, and which was not fixable using the old method, since you'd never have even realized it was wrong.
3. shows usb drivers, 1 or more

If you want to update to confirm these fixes work for -xxx --usb and -xxx --usb --usb-sys that would be appreciated, but so far I believe I've fixed everything I could see here in terms of making both --usb and --usb --usb-sys better overall.

BSD was also enhanced, and now also shows ports, which it never could do before, for those who follow BSDs. But bsd usbdevs data is to put it midly bad and weak, so there's not a huge amount of work to be done there since there is not much data.

This shows the enhanced lsusb based --usb -xxx output, you'll see the less verbose <vendor defined> replaces the old longer value. Where > 1 device types are found, those show. Where lsusb showed vendor defined for network devices, it now shows type: Network

I suspect for a few other device types I can do similar fixes to get the types better, scanner would be as noted nice to get.

This basically is merging the most reliable parts of /sys parsing with the best parts (really only the device vendor/product name) from lsusb, and I could literally do that myself if I was willing to create the db module for vendor / product matches, doing so would knock literally 300 to 500 milliseconds off the execution time, so I'm obviously going to give that some thought. That db wont' be part of inxi though, that would literally more than double its size.

Code: Select all

pinxi -xxx --usb
USB:       Hub: 1-0:1 usb: 2.0 type: Full speed (or root) hub ports: 14 chip ID: 1d6b:0002 
           Hub: 1-3:85 usb: 1.1 type: Atmel 4-Port Hub ports: 4 chip ID: 03eb:0902 
           Device-1: C-Media Audio Adapter (Planet UP-100 Genius G-Talk) driver: cm109,snd-usb-audio usb: 1.1 
           type: Audio,HID bus ID: 1-3.2:86 chip ID: 0d8c:000e 
           Device-2: ALi M5621 High-Speed IDE Controller driver: usb-storage usb: 2.0 type: Mass Storage 
           bus ID: 1-3.4:113 chip ID: 0402:5621 
           Device-3: Wacom Graphire 2 4x5 driver: usbhid,wacom usb: 1.1 type: Mouse bus ID: 1-4:2 
           chip ID: 056a:0011 
           Device-4: Verbatim driver: usb-storage usb: 2.0 type: Mass Storage bus ID: 1-7:11 chip ID: 18a5:3623 
           Device-5: Tangtop HID Keyboard driver: hid-generic,usbhid usb: 1.1 type: Keyboard,Mouse 
           bus ID: 1-10:3 chip ID: 0d3d:0001 
           Device-6: Canon CanoScan LiDE 110 usb: 2.0 type: <vendor specific> bus ID: 1-13:112 
           chip ID: 04a9:1909 
           Device-7: Apple Ethernet Adapter [A1277] driver: asix usb: 2.0 type: Network bus ID: 1-14:13 
           chip ID: 05ac:1402 
           Hub: 2-0:1 usb: 3.1 type: Full speed (or root) hub ports: 8 chip ID: 1d6b:0003 
           Hub: 3-0:1 usb: 2.0 type: Full speed (or root) hub ports: 2 chip ID: 1d6b:0002 
           Hub: 4-0:1 usb: 3.1 type: Full speed (or root) hub ports: 2 chip ID: 1d6b:0003 
           Hub: 5-0:1 usb: 2.0 type: Full speed (or root) hub ports: 4 chip ID: 1d6b:0002 
           Hub: 6-0:1 usb: 3.0 type: Full speed (or root) hub ports: 4 chip ID: 1d6b:0003 
smxi/sgfxi site (manuals, how-to's, faqs) :: script forums :: Check out inxi sys info script!

sunrat
Forum Regular
Forum Regular
Posts: 223
Joined: Mon Mar 28, 2016 9:54 pm

Re: New inxi feature, /sys based usb data

#12 Post by sunrat » Tue Aug 14, 2018 10:06 pm

Just out of interest:

Code: Select all

$ time pinxi -xxxzAN --usb
...
real    0m0.365s
user    0m0.253s
sys     0m0.060s

Code: Select all

$ time pinxi -xxx --usb --usb-sys
...
real    0m0.229s
user    0m0.169s
sys     0m0.036s

User avatar
h2-1
Forum Regular
Forum Regular
Posts: 429
Joined: Sat Nov 15, 2008 3:16 pm

Re: New inxi feature, /sys based usb data

#13 Post by h2-1 » Tue Aug 14, 2018 10:59 pm

Yes, you have a pretty fast cpu. the more cores and faster it is, the lower the speed difference, I believe that's because subshell commands get handed off to another core when you have spare cores, not sure about that, but I think that's why the speed differences range from 20ms on a 32 core dual cpu epyc, to 80 ms on a 6 core ryzen, to 500 ms on an older amd dual core cpu. The differences would be even more pronounced on an ARM device like rasberry pi.

with ryzen 6 core:

Code: Select all

time pinxi --usb
...
real	0m0.187s
user	0m0.146s
sys	0m0.033s

time pinxi --usb --usb-sys
...
real	0m0.117s
user	0m0.122s
sys	0m0.026s
On AMD SOC PC Engines

Code: Select all

time pinxi --usb
...
real	0m1.476s
user	0m1.336s
sys	0m0.120s

time pinxi --usb --usb-sys
...
real	0m1.100s
user	0m0.944s
sys	0m0.136s
On old amd dual core machine:

Code: Select all

time pinxi --usb
...
real	0m0.454s
user	0m0.459s
sys	0m0.084s

time pinxi --usb --usb-sys
...
real	0m0.311s
user	0m0.281s
sys	0m0.071s
On 8 year old intel core duo machine

Code: Select all

time pinxi --usb
...
real	0m0.695s
user	0m0.316s
sys	0m0.056s

time pinxi --usb --usb-sys
...
real	0m0.249s
user	0m0.216s
sys	0m0.020s
On dual cpu, 32 core server:

Code: Select all

time bin/pinxi --usb
....
real	0m0,232s
user	0m0,154s
sys	0m0,078s

time bin/pinxi --usb --usb-sys
...
real	0m0,212s
user	0m0,153s
sys	0m0,058s
Basically for AntiX users, with older hardware, and without lsusb, they will see a big change, that is, they will see USB data without having to install any further dependencies.

Note that actually now the lsusb parser always runs the /sys parser as well, and then stuff is updated in the parsed lsusb data, and added, so actually lsusb times include most of the /sys parser already, so the comparison really shows the raw time lsusb took to run on the system, since most of the /sys parser always runs anyway.
smxi/sgfxi site (manuals, how-to's, faqs) :: script forums :: Check out inxi sys info script!

User avatar
h2-1
Forum Regular
Forum Regular
Posts: 429
Joined: Sat Nov 15, 2008 3:16 pm

Re: New inxi feature, /sys based usb data

#14 Post by h2-1 » Tue Aug 14, 2018 11:11 pm

But here's the real difference, on a remote server, no root access, can't install lsusb:

Code: Select all

inxi --usb
USB:       Missing: Required tool lsusb not installed. Check --recommends

pinxi --usb
USB:       Hub: 1-0:1 usb: 2.0 type: Full speed (or root) Hub ports: 2 
           Hub: 1-1:2 usb: 2.0 type: Full speed (or root) Hub ports: 6 
           Device-1: Winbond Corp Hermon USB hidmouse Device type: Keyboard,Mouse bus ID: 1-1.3:3 
           Hub: 2-0:1 usb: 2.0 type: Full speed (or root) Hub ports: 2 
           Hub: 2-1:2 usb: 2.0 type: Full speed (or root) Hub ports: 8
smxi/sgfxi site (manuals, how-to's, faqs) :: script forums :: Check out inxi sys info script!

sunrat
Forum Regular
Forum Regular
Posts: 223
Joined: Mon Mar 28, 2016 9:54 pm

Re: New inxi feature, /sys based usb data

#15 Post by sunrat » Tue Aug 14, 2018 11:45 pm

h2-1 wrote:
Tue Aug 14, 2018 10:59 pm
Yes, you have a pretty fast cpu.
Not really.

Code: Select all

$ pinxi -CDm
Memory:    RAM: total: 3.85 GiB used: 1.72 GiB (44.6%)
           RAM Report: permissions: Unable to run dmidecode. Are you root?
CPU:       Topology: Dual Core model: Intel Core2 Duo E8500 bits: 64 type: MCP
           L2 cache: 6144 KiB
           Speed: 2756 MHz min/max: 2000/3166 MHz Core speeds (MHz): 1: 2756 2: 2642
Drives:    Local Storage: total: 1.92 TiB used: 967.92 GiB (49.1%)
           ID-1: /dev/sda vendor: OCZ model: VERTEX2 3.5 size: 107.13 GiB
           ID-2: /dev/sdb vendor: Western Digital model: WD1001FALS-00J7B1
           size: 931.51 GiB
           ID-3: /dev/sdc vendor: Western Digital model: WD1001FALS-00J7B1
           size: 931.51 GiB

User avatar
h2-1
Forum Regular
Forum Regular
Posts: 429
Joined: Sat Nov 15, 2008 3:16 pm

Re: New inxi feature, /sys based usb data

#16 Post by h2-1 » Wed Aug 15, 2018 2:46 am

Reasonably fast, I should have said. it's surprising how revealing this particular test is for overall cpu performance. I figured it was around a core2 type based on the lsusb test speed.
smxi/sgfxi site (manuals, how-to's, faqs) :: script forums :: Check out inxi sys info script!

User avatar
rokytnji.1
Forum Regular
Forum Regular
Posts: 752
Joined: Sun Apr 13, 2014 9:06 pm

Re: New inxi feature, /sys based usb data

#17 Post by rokytnji.1 » Wed Aug 15, 2018 9:36 am

rokytnji.1, I'd need to also see -xxxNA --usb --usb-sys, thanks.
No changes since yesterdays report. Same hardware to stay consistent.

Code: Select all

harry@biker:~
$ pinxi  -xxxNA --usb --usb-sys
Audio:     Device-1: Intel 7 Series/C216 Family High Definition Audio driver: snd_hda_intel v: kernel 
           bus ID: 00:1b.0 chip ID: 8086:1e20 
           Sound Server: ALSA v: k4.15.9-antix.1-amd64-smp 
Network:   Device-1: Qualcomm Atheros AR9462 Wireless Network Adapter driver: ath9k v: kernel bus ID: 01:00 
           chip ID: 168c:0034 
           Device-2: Broadcom Limited NetLink BCM57785 Gigabit Ethernet PCIe driver: tg3 v: 3.137 port: N/A 
           bus ID: 02:00 chip ID: 14e4:16b5 
USB:       Hub: 1-0:1 usb: 2.0 type: Full speed (or root) Hub ports: 3 chip ID: 1d6b:0002 
           Hub: 1-1:2 usb: 2.0 type: Full speed (or root) Hub ports: 4 chip ID: 8087:0024 
           Device-1: N/A driver: btusb usb: 1.1 type: Wireless USB Controller bus ID: 1-1.1:5 
           chip ID: 0489:e04e 
           Device-2: HD WebCam driver: uvcvideo usb: 2.0 type: Video bus ID: 1-1.3:4 chip ID: 04f2:b336 
           Hub: 2-0:1 usb: 2.0 type: Full speed (or root) Hub ports: 3 chip ID: 1d6b:0002 
           Hub: 2-1:2 usb: 2.0 type: Full speed (or root) Hub ports: 4 chip ID: 8087:0024 
           Device-3: PNY USB 2.0 FD driver: usb-storage usb: 2.0 type: Mass Storage bus ID: 2-1.2:3 
           chip ID: 154b:007a serial: AA00000000005495 

User avatar
h2-1
Forum Regular
Forum Regular
Posts: 429
Joined: Sat Nov 15, 2008 3:16 pm

Re: New inxi feature, /sys based usb data

#18 Post by h2-1 » Wed Aug 15, 2018 3:43 pm

All looks good, thanks.

I'm working on removing lsusb -v and replacing it with lsusb plain, I think I have enough from /sys to do that now. that means I'll basically only be using the lsusb database for vendors/products essentially.
smxi/sgfxi site (manuals, how-to's, faqs) :: script forums :: Check out inxi sys info script!

User avatar
h2-1
Forum Regular
Forum Regular
Posts: 429
Joined: Sat Nov 15, 2008 3:16 pm

Re: New inxi feature, /sys based usb data

#19 Post by h2-1 » Thu Aug 16, 2018 1:25 am

Last tests, full internal refactor, now only uses lsusb short form, dumped the entire hack filled lsusb -v processor, and moved all methods to use a very clean array based logic.

Tested this on very old systems, lenny 2008, lenny sid, brought up my old vms, all seems to be working well with old systems, found a few glitches on those, slightly varied syntax, and fixed that.

Basically now the only parts that come from lsusb are the vendor name/product string, although technically I also get the vendor:product ID from there, but I could just as easily get it from /sys.

This method is much easier to work with on the output handlers, -A, -N, and --usb, in fact, i was able to cutoff about 100 lines of code or so while expanding features and options. Devices now support serial number with -xxx if present, hubs tested and seem solid too.

BSD adjusted and works fine now as well, so I'm pretty close to calling this one done.

I'll probably tweak a thing or two more then this will be inxi 3.0.21

If anyone wants to double check and test, feel free, post results, it should all now 'just work'.

There's a bit of a time gain from running only lsusb instead of lsusb -v, but not that much, but the code is far simpler, and now is much more generic and has almost no hacks at all. Debugger data is much cleaner too, as is logging. I lose a few little things but they don't matter since the data that is lost is already used and active, that's the type stuff.
smxi/sgfxi site (manuals, how-to's, faqs) :: script forums :: Check out inxi sys info script!

User avatar
rokytnji.1
Forum Regular
Forum Regular
Posts: 752
Joined: Sun Apr 13, 2014 9:06 pm

Re: New inxi feature, /sys based usb data

#20 Post by rokytnji.1 » Thu Aug 16, 2018 9:30 am

Just throwing this out here before I head outside to do chores. The PNY usb drive is now put away.

Code: Select all

harry@biker:~
$ pinxi  -xxxNA --usb --usb-sys
Audio:     Device-1: Intel 7 Series/C216 Family High Definition Audio driver: snd_hda_intel v: kernel 
           bus ID: 00:1b.0 chip ID: 8086:1e20 
           Sound Server: ALSA v: k4.15.9-antix.1-amd64-smp 
Network:   Device-1: Qualcomm Atheros AR9462 Wireless Network Adapter driver: ath9k v: kernel bus ID: 01:00 
           chip ID: 168c:0034 
           Device-2: Broadcom Limited NetLink BCM57785 Gigabit Ethernet PCIe driver: tg3 v: 3.137 port: N/A 
           bus ID: 02:00 chip ID: 14e4:16b5 
USB:       Hub: 1-0:1 usb: 2.0 type: Full speed (or root) Hub ports: 3 chip ID: 1d6b:0002 
           Hub: 1-1:2 usb: 2.0 type: Full speed (or root) Hub ports: 4 chip ID: 8087:0024 
           Device-1: N/A driver: btusb usb: 1.1 type: Wireless USB Controller bus ID: 1-1.1:5 
           chip ID: 0489:e04e 
           Device-2: HD WebCam driver: uvcvideo usb: 2.0 type: Video bus ID: 1-1.3:4 chip ID: 04f2:b336 
           Hub: 2-0:1 usb: 2.0 type: Full speed (or root) Hub ports: 3 chip ID: 1d6b:0002 
           Hub: 2-1:2 usb: 2.0 type: Full speed (or root) Hub ports: 4 chip ID: 8087:0024 
harry@biker:~
$ inxi -xxxNA --usb --usb-sys
Error 22: Unsupported option: --usb-sys
Check -h for correct parameters.
harry@biker:~
$ inxi -xxxzAN --usb
Audio:     Card-1: Intel 7 Series/C216 Family High Definition Audio driver: snd_hda_intel v: kernel 
           bus ID: 00:1b.0 chip ID: 8086:1e20 
           Sound Server: ALSA v: k4.15.9-antix.1-amd64-smp 
Network:   Card-1: Qualcomm Atheros AR9462 Wireless Network Adapter driver: ath9k v: kernel bus ID: 01:00.0 
           chip ID: 168c:0034 
           Card-2: Broadcom Limited NetLink BCM57785 Gigabit Ethernet PCIe driver: tg3 v: 3.137 port: N/A 
           bus ID: 02:00.0 chip ID: 14e4:16b5 
USB:       Hub: 1:1 usb: 2.0 type: Full speed (or root) hub chip ID: 1d6b:0002 
           Hub: 1:2 usb: 2.0 type: Intel Integrated Rate Matching Hub chip ID: 8087:0024 
           Device-1: Chicony bus ID: 1:4 usb: 2.0 type: Video chip ID: 04f2:b336 
           Device-2: Foxconn / Hon Hai bus ID: 1:5 usb: 1.1 type: Bluetooth chip ID: 0489:e04e 
           Hub: 2:1 usb: 2.0 type: Full speed (or root) hub chip ID: 1d6b:0002 
           Hub: 2:2 usb: 2.0 type: Intel Integrated Rate Matching Hub chip ID: 8087:0024 
harry@biker:~
$ inxi
CPU: Dual Core Intel Celeron 1007U (-MCP-) speed/min/max: 927/800/1500 MHz 
Kernel: 4.15.9-antix.1-amd64-smp x86_64 Up: 37m Mem: 612.6/3883.9 MiB (15.8%) HDD: 14.91 GiB (32.8% used) 
Procs: 132 Shell: bash 4.4.12 inxi: 3.0.10 
harry@biker:~
$ pinxi
CPU: Dual Core Intel Celeron 1007U (-MCP-) speed/min/max: 1248/800/1500 MHz 
Kernel: 4.15.9-antix.1-amd64-smp x86_64 Up: 38m Mem: 615.6/3883.9 MiB (15.8%) Storage: 14.91 GiB (32.8% used) 
Procs: 132 Shell: bash 4.4.12 pinxi: 3.0.20-28 
harry@biker:~
$ 
I really appreciate how easy you make it for me to trouble shoot users problems on line and make me look
smarter than I really am. Thank you . :hug:

Post Reply

Return to “antiX”