开发者社区> sky-heaven> 正文
阿里云
为了无法计算的价值
打开APP
阿里云APP内打开

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。
+关注继续查看

转自: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 | LinuxProgramming | 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?

  • Share › 
 
 
  •  
     
    Avatar

    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.

  •  
 
 
  •  
     
    Avatar

    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

【作者】张昺华
【新浪微博】 张昺华--sky
【twitter】 @sky2030_
【facebook】 张昺华 zhangbinghua
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
QT5在windows下调用OpenCV库出现: undefined reference to `xxxxx' 错误解决办法(适用MinGW编译器)。
QT5在windows下调用OpenCV库出现: undefined reference to `xxxxx' 错误解决办法(适用MinGW编译器)。
362 0
编译OpenJDK8:configure error /usr/lib64/ccache/gcc is a symbolic link to ccache
编译OpenJDK8:configure error /usr/lib64/ccache/gcc is a symbolic link to ccache
46 0
PostgreSQL sharding : citus 系列4 - DDL 操作规范 (新增DB,TABLE,SCHEMA,UDF,OP,用户等)
标签 PostgreSQL , citus , 新增对象 , 新增数据库 , 新增用户 背景 citus是PG的一个插件,插件主要针对普通SQL(非UTILITY)加HOOK进行了一些ROUTE处理,同时使用UDF对表进行新建分区的操作。
1364 0
Dapper:The member of type SeoTKD cannot be used as a parameter Value
异常汇总:http://www.cnblogs.com/dunitian/p/4523006.html#dapper 上次说了一下Dapper的扩展Dapper.Contrib http://www.
803 0
+关注
sky-heaven
我是一个技术爱好者,喜欢分享交流技术心得
1191
文章
0
问答
文章排行榜
最热
最新
相关电子书
更多
低代码开发师(初级)实战教程
立即下载
阿里巴巴DevOps 最佳实践手册
立即下载
冬季实战营第三期:MySQL数据库进阶实战
立即下载