usb驱动---What is the difference between /dev/ttyUSB and /dev/ttyACM【转】
转自:http://blog.csdn.net/ppp2006/article/details/25654733
https://www.rfc1149.net/blog/2013/03/05/what-is-the-difference-between-devttyusbx-and-devttyacmx/
理解为何有的USB串口叫ttyUSB而有的叫ttyACM
对于转换桥,功能较单一,归类为ttyUSB。驱动在drivers/usb/serial/usb-serial.c。 比如FDTI转换芯片虚拟出的串口,在ubuntu上都识别为ttyUSB*.
对于带通信规约的接口,实现复杂,归类为ttyACM。驱动在drivers/usb/class/cdc_acm.c。比如arduino uno rev3板子的usb串口是由atmega16u2芯片完成的。本身芯片可以运行usb协议代码。
What is the difference between /dev/ttyUSB and /dev/ttyACM?
Samuel Tardieu, 2013-03-05
Have you ever wondered why some USB devices used/dev/ttyUSB0
(or 1, or n) and others/dev/ttyACM0
(or 1, or n) when they are plugged into the host computer, while they seem to be acting as UART devices (RS-232-like) over USB in both cases? Have you wondered why example USB firmwares for microcontrollers always end up with names such as/dev/ttyACM0
and never as /dev/ttyUSB0
?
Warning: this is a Linux specific post, although it also contains genuine pieces of USB culture.
What does ttyACM
mean?
The USB implementors forum organization has described how devices conforming to the Communications Device Class (CDC) should present themselves to the USB host. The USB implementors forum also specified how CDC subclasses should act, including for those devices intended to talk with each other over the public switched telephone network (PSTN). Those are known as modems because the data goes through a modulation operation on the sending side, which transforms the bits into analog signals that can be carried over phone wires, and then through a demodulation operation on the receiving side to convert the analog signal back into the original bits.
To discuss with the modem, the host USB driver must use one of the existing control models. For example, thedirect line control model controls how data is exchanged between the host and the modem through an audio class interface, with the host taking charge of the modulation, demodulation, data compression (such as V.42bis) and error correction (such as V.42). This model is used by some USB soft modems, which are very cheap because they mostly contain a DSP chip and some amplification and line adaptation layers.
Another control model, aptly named abstract control model or ACM, lets the modem hardware perform the analog functions, and require that it supports the ITU V.250 (also known as Hayes in its former life) command set, either in the data stream or as a separate control stream through the communication class interface. When the commands are multiplexed with the data in the data stream, an escape sequence such as Hayes 302 (also known as “1 sec +++ 1 sec”) or TIES (that nobody remembers) must allow the host to put the modem into command mode.
When developping on a USB-enabled embedded microcontroller that needs to exchange data with a computer over USB, it is tempting to use a standardized way of communication which is well supported by virtually every operating system. This is why most people choose to implement CDC/PSTN with ACM (did you notice that the Linux kernel driver for /dev/ttyACM0
is named cdc_acm
?) because it is the simplest way to exchange raw data.
But what about the mandatory V.250 command set? It is almost never implemented in such devices, but since the host has no reason to spontaneously generate V.250 commands by itself, the device will never have to answer them. Pretending the embedded device is a modem is the simplest way to communicate with it, even though it will probably never perform any modulation or demodulation task. Linux will not know that the device is lying, and will have it show up as /dev/ttyS0
.
What does ttyUSB
mean?
Sometimes, the embedded microcontroller does not come with a hardware USB interface. While it is possible to use a software-only USB stack, the additional constraints put onto the CPU and the usually small storage size often lead board designers to include a dedicated UART to USB bridge. Several vendors, such as FTDIor Prolific sell dedicated chips for a few euros.
Those vendors opted not to lie to the host computer in having the chips announce themselves as USB modems when they were not. Each vendor defined its own (usually proprietary) protocols, with commands allowing to control functions of the chips such as setting the baud rate or controlling additional signals used to implement hardware flow control.
When it is practical to do so, Linux groups devices with similar functionalities under the same default device or interface names. For example, the UARTs present on your computer (if any) will be named /dev/ttyS0
and/dev/ttyS1
even if one of them is a legacy 16550 chip and the other one is a MAX3100 SPI-controlled UART. Similarly, the devices offering UART-over-USB functionalities are named /dev/ttyUSB0
,/dev/ttyUSB1
, and so on, even though they are in fact using distinct device drivers.
Conclusion
So, when you see a /dev/ttyACM0
popping up, you can try to send it the escape sequence followed by AT commands, but there is a good chance that the device only pretends to be a modem and will happily send those characters to the core application without even considering intercepting them. If it is a /dev/ttyS0
, do not try, unless the device behind the USB-UART bridge understands those command by itself (this is the case for the XBee chip).
If you like this post, you can send some bitcoin dust to 1Bo78aNzJvkmeLTw8aptaFipvRWyNQP2WF (or click here).
Samuel Tardieu| 2013-03-05 | Linux, Programming | Comments | CC BY-NC-SA
thanks for the post.. i'm using an avr32 bit chip with USB embedded in it. When i connect to linux (ubuntu 12.10 64bit), the device shows up as ttyACM0 and the PC tries sending AT+ commands for about a minute after my device connects. quite annoying because i'm doing development work and the device is unavailable during this routine. do you know if it is possible to disable this mount routine from the PC? or better yet is it possible to change my device configuration so it shows up as ttyUSB?
- Samuel Tardieu Mod walker • 3 years ago
The article explains precisely why this would not be possible for it to show as ttyUSB. Check the Ubuntu help center and forums if Ubuntu insists on talking to your device.
- walker Samuel Tardieu • 3 years ago
I'm not sure why you are saying that it is not possible for the device to announce itself as ttyUSB? I can set how the usb announces itself using various registers on the device. there is example code that changes my microcontroller from cdc to HID or mass storage etc.. Unfortunately nothing that seems to conform to the ttyUSB spec. When i force this driver my device enumerates successfully as ttyUSB one time, but not again until i reboot. i get the following error message:
[878887.203226] usbserial_generic 5-2:1.0: Generic device with no bulk out, not allowed.
i'm going to spend some more time looking for usbserial documentation but any constructive advice would be welcome! thanks again
usb驱动---What is the difference between /dev/ttyUSB and /dev/ttyACM【转】的更多相关文章
- Linux内核USB驱动【转】
本文转载自:http://www.360doc.com/content/12/0321/14/8363527_196286673.shtml 注意,该文件是2.4的内核的驱动源文件,并不保证在2.6内 ...
- USB驱动开发大全【转】
本文转载自:http://www.360doc.com/content/12/0504/19/8363527_208666082.shtml 编写USB驱动程序步骤:1所有usb驱动都必须创建主要结构 ...
- usb驱动开发22之驱动生命线
我们总是很喜欢高潮,不是吗?那就好好对待她哦.我们来看一下linux中的高潮部分设备是怎么从Address进入Configured的. usb_set_configuration函数的代码就不贴了,可 ...
- usb驱动开发21之驱动生命线
现在开始就沿着usb_generic_driver的生命线继续往下走.设备的生命线你可以为是从你的usb设备连接到hub的某个端口时开始,而驱动的生命线就必须得回溯到usb子系统的初始化函数usb_i ...
- usb驱动开发14之设备生命线
直接看代码吧. /*-------------------------------------------------------------------*/ /** * usb_submit_urb ...
- usb驱动开发12之设备生命线
函数usb_control_msg完成一些初始化后调用了usb_internal_control_msg之后就free urb.剩下的活,全部留给usb_internal_control_msg去做了 ...
- usb驱动开发11之设备生命线
暂时先告别媒人,我们去分析各自的生命旅程,最后还会回到usb_device_match函数. 首先当你将usb设备连接在hub的某个端口上,hub检测到有设备连接了进来,它会为设备分配一个struct ...
- usb驱动开发10之usb_device_match
在第五节我们说过会专门分析函数usb_device_match,以体现模型的重要性.同时,我们还是要守信用的. 再贴一遍代码,看代码就要不厌其烦. static int usb_device_matc ...
- usb驱动开发5之总线设备与接口
Linux设备模型中的总线落实在USB子系统里就是usb_bus_type,它在usb_init的函数bus_register(&usb_bus_type)里注册.usb_bus_type定义 ...
随机推荐
- POJ:2976-Dropping tests(二分平均值)
Dropping tests Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 15508 Accepted: 5418 Descr ...
- GPIO基础知识
STM32 GPIO入门知识 GPIO是什么? 通用输入输出端口,可以做输入,也可以做输出.GPIO端口可通过程序配置成输入或输出. 引脚和GPIO的区别和联系 STM32的引脚中,有部分是做GPIO ...
- Java集合——LinkedHashMap源码详解
个KV.LinkedHashMap不仅像HashMap那样对其进行基于哈希表和单链表的Entry数组+ next链表的存储方式,而且还结合了LinkedList的优点,为每个Entry节点增加了前驱和 ...
- 从键盘输入数,输出它们的平方值&判断是不是2的阶次方数
1.从键盘输入两个整数,然后输出它们的平方值和立方值 在Java中,没有像C语言那样有一个专供接受键盘输入值的scanf函数,所以一般的做法是从键盘输入一行字符,保存到字符串s中,再将字符组成的字符串 ...
- java 解析/读取 种子/bt/torrent 内容
碰到不会的技术问题,我还是先度娘.能中文看懂,为什么非要看英文呢. java 解析/读取 种子/bt/torrent 内容,这个度娘给的满意答案并不是很多.GG之后的搜索结果出现了stackover ...
- Block那些事儿
1.Block底层原理实现 首先我们来看四个函数 void test1() { int a = 10; void (^block)() = ^{ NSLog(@"a is %d", ...
- 从事IT业一个8年老兵转行前的自我总结1——初爻
现在,本人已离开这个呆了8年的软件行业了.回想自己从半路出家,从实施开始做起,最终在一家外企做项目经理PM结束了自己的软件职业生涯.从一张白纸的自学开始,做过项目实施,客户培训,拿过需求,开发,架构设 ...
- 【Python-遇到的Error】AttributeError: 'str' object has no attribute 'input_text'
学习类的实例化的时候遇到了AttributeError: 'str' object has no attribute 'input_text', 以下是报错的代码及修改正确的代码. class shu ...
- python 学习分享-select等
首先列一下,sellect.poll.epoll三者的区别 select select最早于1983年出现在4.2BSD中,它通过一个select()系统调用来监视多个文件描述符的数组(在linux中 ...
- IntelliJ IDEA 注释模版 输入/**后 不显示配置好的模板
简单一句话就是 当你在live templetes里配置好以后,记住abbreviation:输入框里的字母 比如我的是cc ,我要想写注释怎么办? 在方法上输入 /*cc 然后按tab键就出来了