Linux узнать pid vid

Linux узнать pid vid

Linux users can, of course, just use lsusb or usbview. Run as root because on some systems, this doesn’t show all the information otherwise.

Bus 002 Device 049: ID eb1a:1760 eMPIA Technology, Inc.

Bus 002 Device 007: ID 04e8:323a Samsung Electronics Co., Ltd ML-1710 Printer

Bus 002 Device 005: ID 055f:0006 Mustek Systems, Inc. ScanExpress 1200 UB

Bus 002 Device 003: ID 0409:0058 NEC Corp. HighSpeed Hub

Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 001 Device 028: ID 0518:0001 EzKEY Corp. USB to PS2 Adaptor v1.09

Bus 001 Device 003: ID 046d:c03f Logitech, Inc. UltraX Optical Mouse

Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

The “sudo” command is used to run the command as root (Adminstrative User) and is needed on systems where you don’t normally log in as root. If you are already root, you can just run lsusb without the sudo. The “$” is just the command prompt and will vary depending on system configuration. It is normally a “$” if you are an ordinary user or “#” if you are root and is often preceeded by the name of the current directory and sometimes the machine name and username.

If you can’t tell which device is the device you are interested in, unplug the device and repeat the listing then plug it back in and do the listing again. Compare the listings; the device which disappears and then reappears from the listing is the device you want.

For this, you need the VID/PID obtained using the short form of lsusb. In this example, it was “eb1a:1760”. If you use lsusb -v without this, you get the long form listing for all devices which can be very long indeed and include a lot of irrelevant information.

To save the information above to a file use:

# lsusb -v eb1a:1760 > output.txt

The verbose listing not only decodes the USB device descriptor, it also decodes the class descriptors for hub, audio, HID, communications, chipcard, and video classes.

If you are using a Knoppix or Ubunto Live CD, you need a way to share this information with the outside world. You can run the firefox web browser (if your network adapter is working) and paste the information into a web form if that is all you need. Or you can save the info on a usb flash drive or to a windows hard disk partition.

Читайте также:  Подключить сетевой принтер линукс виндовс

If you create a USB flash drive to boot Knoppix or ubunto (directions on the net), create a small FAT32 partition on the flash drive so windows can easily see it.

usbview should not be mistaken for the similarly named utility on windows, although the names are the same and their purpose is similar. Usbview is a GUI application. It does not provide as much detail as lsusb -v but it provides it in a nice tree format.

Incidently, usbview also give you hints as to whether your device is plugged into a slow USB full speed port or a fast USB 2.0 high speed port. Some devices don’t work reliably or run slower when not plugged into a high speed port. On my system the same device shows up under EHCI Host controller on a slow port but under USB 2.0 Hub Controller under EHCI host controller on a fast port. If it shows up under an OHCI Host Controller or UHCI Host Controller, it is connected to a slow port. Oddly, when plugged into the same port a webcam showed up under the EHCI Host Controller/USB2.0 Hub Controller but the keyboard shows up under OHCI Host Controller; this probably has something to do with emulation as the keyboard and mouse are used prior to booting.

usbview also reports the driver associated with each device, using the less than clear format “Name: uvcvideo”

cat /proc/bus/usb/devices will give a listing for all usb devices. It is more detailed than a plain lsusb and more succinct than a lsusb -v. You have to pick the approprate block of information (separated by blank lines) from the output. This is the form that it submitted to www.linux-usb.org and is suitable for posting where you can’t post the full lsusb -v output. For a USB Video Class Device, it doesn’t list supported resolutions, bitrates, encoding formats, or user controls which the lsusb -v listing does.

T: Bus=02 Lev=02 Prnt=03 Port=01 Cnt=02 Dev#= 12 Spd=480 MxCh= 0

D: Ver= 2.00 Cls=ef(unk. ) Sub=02 Prot=01 MxPS=64 #Cfgs= 1

P: Vendor=eb1a “ProdID” =1760 Rev= 6.08

S: Product=Digital Microscope

C:* #Ifs= 2 Cfg#= 1 Atr=80 MxPwr=500mA

A: FirstIf#= 0 IfCount= 2 Cls=0e(video) Sub=03 Prot=00

I:* If#= 0 Alt= 0 #EPs= 1 Cls=0e(video) Sub=01 Prot=00 Driver=uvcvideo

E: Ad=81(I) Atr=03(Int.) MxPS= 8 Ivl=32ms

I:* If#= 1 Alt= 0 #EPs= 1 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo

E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms

If you run lshw with the -numeric option, it will show the vendor device ID t the end of the product: line. Leading zeros are supressed rather than printing as 4 digit hex.

Читайте также:  Linux primary partitions are

The file /var/log/messages contains syslog information including messages printed by device drivers when they recognize a device. To use, unplug the device. Then run:

$ sudo tail -n 0 -f /var/log/messages

$ sudo tail -n 0 -f /var/log/messages | tee /tmp/logmessages

Wait ten seconds or so after you plug in the device and then hit control-C to stop the program. The tail program with these options will just show you the new information as it is added to the file. The tee program saves the output of the tail program in a file (/tmp/logmessages) while simultaneously showing the output to you.

Here is some sample output:

Apr 15 22:11:48 cervantes kernel: [1380806.451378] usb 2-8.2: USB disconnect, address 67

Apr 15 22:11:52 cervantes kernel: [1380812.296497] usb 2-8.2: new high speed USB device using ehci_hcd and address 68

Apr 15 22:11:52 cervantes kernel: [1380812.982274] usb 2-8.2: configuration #1 chosen from 1 choice

Apr 15 22:11:53 cervantes kernel: [1380812.982891] uvcvideo: Found UVC 1.00 device Digital Microscope (eb1a:1760)

Apr 15 22:11:53 cervantes kernel: [1380813.490404] input: Digital Microscope as /class/input/input1430

Apr 15 22:11:53 cervantes kernel: [1380813.490666] usb 2-8.2: New USB device found, idVendor=eb1a, idProduct=1760

Apr 15 22:11:53 cervantes kernel: [1380813.490673] usb 2-8.2: New USB device strings: Mfr=2, Product=1, SerialNumber=3

Apr 15 22:11:53 cervantes kernel: [1380813.490676] usb 2-8.2: Product: Digital Microscope

Apr 15 22:11:53 cervantes kernel: [1380813.490679] usb 2-8.2: Manufacturer: Infoxelle

Apr 15 22:11:53 cervantes kernel: [1380813.490681] usb 2-8.2: SerialNumber: VT1760

Источник

Linux Kernel Check VID / PID Number?

What I am looking for is the command to check the live USB disks serial number from within a kernel module. from within the kernel, lsusb won’t work. TMI Clause: I am developing a live USB device for a client, and this will be a current part of our copy protection.

2 Answers 2

Your program would be querying the serial number via the operating system. And you know what, your client has the ability to alter the operating system, so your program would not be able to completely trust the information provided by the OS.

If you’re willing to trust the client (not to alter the OS), see how the hdparm program in Linux obtains its HDD detail information (including the serial number), or alternatively crawl through the /sys/devices/ hierarchy to find out the hard disks and their detail data (couldn’t find it for the moment, but I think the serial info would be there as well).

If, on the other hand, you would like to expect your clients to cheat, then you would better not let them use your application at all.

Читайте также:  Linux reset all usb devices

After a day of looking I’ve found the answer which can be found on StackOverflow here.

usb_bus_list is declared in #include , which allows for its child functions to be called.

Linked

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.13.43531

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Источник

linux command to list details (like PID, VID) of connected devices to the serial port(s) (like RS232) of a computer

with USB port we can search Product ID (PID) and Vender ID (VID) of connected devices by using lsusb command. Is there a similar way to get PID and VID if the same device is connected to RS232 serial port

RS232 predates Plug’n’Play by several decades. There’s no way detecting what you actually connected to the port.

You would probably have to interface with the device(s) that are connected on the RS232 port themselves directly or use protocol specific discovery functions to see what is living on the other side of the port. But either way you need to go up the network stack to get that info.

1 Answer 1

USB has a standardized method to learn device information including PID and VID. This information is available by the enumeration phase and takes place of the control endpoint. This is possible because there is an additional protocol on top of the raw data signals.

The RS232 serial port is much simpler and does not have similar functionality defined. Data is data, and its interpretation is up to the user/ program using that port. There is no VID nor PID defined for a RS232-connected device such as a printer.

You must log in to answer this question.

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.13.43531

Linux is a registered trademark of Linus Torvalds. UNIX is a registered trademark of The Open Group.
This site is not affiliated with Linus Torvalds or The Open Group in any way.

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Источник

Оцените статью
Adblock
detector