Có giao thức truyền thông USB thực tế không?

Mục lục:

Có giao thức truyền thông USB thực tế không?
Có giao thức truyền thông USB thực tế không?

Video: Có giao thức truyền thông USB thực tế không?

Video: Có giao thức truyền thông USB thực tế không?
Video: Tự học HTML và code ra cái web đơn giản trong 15 phút - YouTube 2024, Có thể
Anonim
Hầu hết chúng ta không bao giờ suy nghĩ nhiều về các thiết bị USB của mình, chúng ta chỉ cần cắm chúng vào và quên chúng đi. Nhưng nếu bạn là loại người tò mò muốn biết thêm về cách thức hoạt động của USB? Bài đăng Hỏi & Đáp của SuperUser hôm nay có câu trả lời cho câu hỏi của người đọc tò mò.
Hầu hết chúng ta không bao giờ suy nghĩ nhiều về các thiết bị USB của mình, chúng ta chỉ cần cắm chúng vào và quên chúng đi. Nhưng nếu bạn là loại người tò mò muốn biết thêm về cách thức hoạt động của USB? Bài đăng Hỏi & Đáp của SuperUser hôm nay có câu trả lời cho câu hỏi của người đọc tò mò.

Phiên Hỏi & Đáp hôm nay đến với chúng tôi theo lịch sự của SuperUser - một phân khu của Stack Exchange, một nhóm các trang web Hỏi & Đáp do cộng đồng điều hành.

Ảnh lịch sự của Evilelka Kowalski (Flickr).

Câu hỏi

Trình đọc siêu người dùng smeeb muốn biết liệu có thực sự là một Giao thức truyền thông USB thực tế hay không:

According to Wikipedia, USB:

Defines the cables, connectors, and communications protocols used in a bus for connection, communication, and power supply between computers and electronic devices.

But is there an actual USB Communication Protocol? My understanding is that:

  1. You connect a USB device to a machine (Ubuntu or any kind of Linux for example).
  2. Linux finds the device driver for that device somehow (bonus if you know!) and loads it.
  3. The device is now connected under /dev/theDevice.
  4. User space apps can now read and write to /dev/theDevice and the driver handles the low-level input and output to the underlying device/hardware.

As far as I can tell, a USB Communication Protocol does not appear anywhere in this flow. If my understanding is correct, the USB is just the cable and electrical connection between the PC and the device.

Am I wrong here? Does USB actually implement some kind of low-level protocol that underscores the flow above? If so, what is it and how does it work at a 30,000 foot view?

Có giao thức truyền thông USB thực tế không?

Câu trả lời

Những người đóng góp của SuperUser RedGrittyBrick và projectdp có câu trả lời cho chúng tôi. Đầu tiên, RedGrittyBrick:

Yes (see USB protocols).

As I understand it, the USB spec defines a complex set of layered protocols and device profiles.

For example, USB devices can conform to high-level templates like mass-storage, keyboard, human interface device, etc. and be managed by a generic device driver. Some USB devices can communicate at a lower level such that the operating system’s low level USB support can recognize that device-specific higher level drivers are needed.

Tiếp theo là câu trả lời từ projectdp:

Question

Is there a low-level USB communication protocol in action and what is it?

Answer

Yes, there is. The USB specification includes the USB protocol which defines the way the bus is used on a bit level. This would be the low-level protocol that underlies the higher level protocols (i.e. mass-storage, HID, etc.).

For specifics on how the USB protocol works, this OSDev wiki is helpful. Here is another interesting description using sequence diagrams to describe the various data transactions per the USB protocol.

Bonus Question

How does Linux find and load the device driver for that device?

Bonus Answer

On Linux when using a USB-enabled kernel, a working USB device will be detected via the hardware and kernel due to the USB specification. On the hardware side, the detection is done by the USB Host Controller. Then in the kernel the Host Controller Driver takes over and translates the low-level bits on the wire to USB protocol formatted information. This information then gets populated in the usbcore driver in the kernel.

I paraphrased from this excellent Opensourceforu article, which has much more detail and clarity about your question in the Linux context.

Hãy chắc chắn kiểm tra phần còn lại của cuộc thảo luận sôi nổi thông qua liên kết chuỗi được chia sẻ bên dưới!

Có cái gì để thêm vào lời giải thích? Tắt âm thanh trong các ý kiến. Bạn muốn đọc thêm câu trả lời từ những người dùng Stack Exchange có hiểu biết công nghệ khác? Xem toàn bộ chuỗi thảo luận tại đây.

Đề xuất: