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 | LinuxProgramming | Comments | CC BY-NC-SA

 

walker • 3 years ago

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 › 

 

 

  •  

     

    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.

  •  
  • Share › 

 

 

  •  

     

    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

时间: 2024-09-23 14:41:00

usb驱动---What is the difference between /dev/ttyUSB and /dev/ttyACM【转】的相关文章

WinXP下USB驱动开发(八)

3.3.2.8.    即插即用(PNP) 即插即用(Plug and Play -- PnP)管理器使用主功能码为IRP_MJ_PNP的IRP与设备驱动程序交换信息和请求.这种类型的请求是新引入到Windows 2000和WDM中的,在以前版本的Windows NT中,大部分检测和配置设备的工作由设备驱动程序自己做.而WDM驱动程序可以让PnP管理器做这个工作.为了与PnP管理器协同工作,驱动程序开发者需要了解一些相关的IRP. 在WDM中,PnP请求扮演了两个角色.在第一个角色中,这些请求指

AM335x(TQ335x)学习笔记——USB驱动移植

对于AM335x来讲,TI维护的USB驱动已经非常完善了,本文称之为移植,实际上仅仅是配置内核选项使能USB HOST/OTG功能.废话少说,直接动手开启AM335x的USB驱动配置项. Step1. 配置内核支持USB 默认的配置项没有配置USB相关的选项,但是DTS已经配置好了,我们不需要对DTS作任何修改,详细的内核配置项如下: [cpp] view plaincopy Device Drivers  --->       [*] USB support  --->           

LDD3学习笔记(16):USB驱动

  #include <linux/usb.h> 所有和 USB 相关的头文件. 它必须被所有的 USB 设备驱动包含. struct usb_driver; 描述 USB 驱动的结构. struct usb_device_id; 描述这个驱动支持的 USB 设备的结构. int usb_register(struct usb_driver *d); 用来从USB核心注册和注销一个 USB 驱动的函数. struct usb_device *interface_to_usbdev(struct

Linux USB驱动框架分析【转】

转自:http://blog.csdn.net/jeffade/article/details/7701431 Linux USB驱动框架分析(一) 初次接触和OS相关的设备驱动编写,感觉还挺有意思的,为了不至于忘掉看过的东西,笔记跟总结当然不可缺,更何况我决定为嵌入式卖命了.好,言归正传,我说一说这段时间的收获,跟大家分享一下Linux的驱动研发.但这次只先针对Linux的USB子系统作分析,因为周五研讨老板催货.当然,还会顺带提一下其他的驱动程式写法. 事实上,Linux的设备驱动都遵循一个

usb驱动的基本结构和函数简介【转】

转自:http://blog.csdn.net/jeffade/article/details/7698404 几个重要的结构 struct--接口 [plain] view plaincopy     struct usb_interface    {            /* array of alternate settings for this interface,             * stored in no particular order */            st

Linux USB驱动框架分析(2)【转】

转自:http://blog.chinaunix.net/uid-23046336-id-3243543.html   看了http://blog.chinaunix.net/uid-11848011-id-96188.html的驱动框架分析,感觉受益匪浅.对于一些内容,我自己查漏补缺. 首先我们按照顺序,看内核模块的注册以及释放函数如下: 点击(此处)折叠或打开 static int __init usb_skel_init(void) {     int result;     /* reg

【驱动】USB驱动&amp;#183;入门【转】

转自:http://www.cnblogs.com/lcw/p/3159371.html Preface USB是目前最流行的系统总线之一.随着计算机周围硬件的不断扩展,各种设备使用不同的总线接口,导致计算机外部总线种类繁多,管理困难.USB总线正是因此而诞生的. USB总线提供了所有外部设备的统一连接方式,并且支持热插拔,方便了厂商开发设备和用户使用设备. USB遵循原则 USB的设计目标是对现有的PC机体系进行扩充,但是目前不仅是PC机,许多的嵌入式系统都开始支持USB总线和接口标准.USB

【驱动】USB驱动实例&amp;#183;串口驱动&amp;#183;键盘驱动【转】

转自:http://www.cnblogs.com/lcw/p/3159370.html Preface USB体系支持多种类型的设备. 在 Linux内核,所有的USB设备都使用 usb_driver结构描述. 对于不同类型的 USB设备,内核使用传统的设备驱动模型建立设备驱动描述,然后映射到 USB设备驱动,最终完成特定类型的 USB设备驱动 USB驱动·入门:http://infohacker.blog.51cto.com/6751239/1226257 USB串口驱动 USB串口驱动关键

win7电脑如何卸载USB驱动?

  USB驱动出现故障的后果是很严重的,也许很多朋友还没有意识到,USB接口在咱们日常生活中已经扮演了非常重要的角色.例如很多朋友喜欢用电脑直接给手机充电,如果USB接口无法使用的话,那么充电就无法进行;很多朋友工作上都需要使用U盘,使用U盘也需要使用USB接口.当然,还有其他的情况,咱们这里就不一一举例了,下面,小编就来讲述一下,ghost win7电脑如何快速的卸载USB驱动. 1.首先,咱们返回到桌面界面,然后找到桌面的计算机图标,右键点击该图标,选择下滑菜单中的属性选项. 2.在属性窗口