Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2918724
  • 博文数量: 401
  • 博客积分: 12926
  • 博客等级: 上将
  • 技术积分: 4588
  • 用 户 组: 普通用户
  • 注册时间: 2009-02-22 14:51
文章分类

全部博文(401)

文章存档

2015年(16)

2014年(4)

2013年(12)

2012年(82)

2011年(98)

2010年(112)

2009年(77)

分类: LINUX

2012-11-12 07:27:33

DTE提供或接收数据,连接到中的用户端机器,主要是计算机和。与此相对地,在网络端的连接设备称为 DCE ( Date Circuit - terminating Equipment )。DTE与进行信令处理的DCE相连。 它是用户网络接口的用户端设备,可作为数据源、目的地或两者兼而有之。

数据终端设备

数据终端设备

DTE通过DCE设备(例如,调制解调器)连接到数据网络,且一般使用DCE产生的DTE包括像计算机、这样的设备。

 

Module_init中会注册tty_drivertty_device会在acm usb_driverprobe中注册。

每个ACM设备都由2Interface组成,第一个interface有一个interrupt endpoint主要负责控制,第二个interface主要负责数据传输,有2endpoint,有可能是两个int,也有可能是2bulk。他们都是成对出现的。

比如:

这个是第一个interface,其中CDC Union中,bMasterInterface就是设备的第0interface,它就是ACM中的第一个interface,作为主interface,它所对应的从interface的号是1,也就是负责数据传输的那个interface。他们两个是成对出现的。

    Interface Descriptor:

      bLength                 9

      bDescriptorType         4

      bInterfaceNumber        0

      bAlternateSetting       0

      bNumEndpoints           1

      bInterfaceClass         2 Communications

      bInterfaceSubClass      2 Abstract (modem)

      bInterfaceProtocol      1 AT-commands (v.25ter)

      iInterface              4 CDC Communication Interface

      CDC Header:

        bcdCDC               1.10

      CDC Union:

        bMasterInterface        0

        bSlaveInterface         1

      CDC Call Management:

        bmCapabilities       0x00

        bDataInterface          1

      CDC ACM:

        bmCapabilities       0x07

          sends break

          line coding and serial state

          get/set/clear comm features

      Endpoint Descriptor:

        bLength                 7

        bDescriptorType         5

        bEndpointAddress     0x81  EP 1 IN

        bmAttributes            3

          Transfer Type            Interrupt

          Synch Type               None

          Usage Type               Data

        wMaxPacketSize     0x0040  1x 64 bytes

        bInterval               4

第二个

    Interface Descriptor:

      bLength                 9

      bDescriptorType         4

      bInterfaceNumber        1

      bAlternateSetting       0

      bNumEndpoints           2

      bInterfaceClass        10 CDC Data

      bInterfaceSubClass      0 Unused

      bInterfaceProtocol      0

      iInterface              5 CDC Data Interface

      Endpoint Descriptor:

        bLength                 7

        bDescriptorType         5

        bEndpointAddress     0x82  EP 2 IN

        bmAttributes            2

          Transfer Type            Bulk

          Synch Type               None

          Usage Type               Data

        wMaxPacketSize     0x0200  1x 512 bytes

        bInterval               0

      Endpoint Descriptor:

        bLength                 7

        bDescriptorType         5

        bEndpointAddress     0x02  EP 2 OUT

        bmAttributes            2

          Transfer Type            Bulk

          Synch Type               None

          Usage Type               Data

        wMaxPacketSize     0x0200  1x 512 bytes

        bInterval               0

    Interface Association:

      bLength                 8

      bDescriptorType        11

      bFirstInterface         2

      bInterfaceCount         2

      bFunctionClass          2 Communications

      bFunctionSubClass       2 Abstract (modem)

      bFunctionProtocol       1 AT-commands (v.25ter)

      iFunction               0

在第一个interaface被匹配后,它对应的probe函数中,会找到它所对应的slave interface,并用

usb_driver_claim_interface(&acm_driver, data_interface, acm);来对其声明,让这两个interface device匹配同一个usb_driver

虽然在module_init中注册了tty_driver,但是此时它是不工作的,在probe的结尾会调用

tty_register_device(acm_tty_driver, minor, &control_interface->dev); 

这句话是注册tty_driver所对应的tty_device,此时他们俩会匹配,并创建相应的字符设备。这个时候user space才可以对其进行访问!

其中在probe中,会有三个ep

Epcontrol

Epread

Epwrite

其中controlinterrupt ep,在tty_open的时候会注册到系统中,监听control event.

Epread对应一个urb,也是在tty_open时被submit,每次接收到数据后,urbcallback了都会调用tty_flip_buffer_push将数据提交给tty子系统的flip buffer中。

Epwrite则是在tty_write中调用。

acm_tty_throttle会在最后一次read urb处理的callback中进行判断是否继续提交,因为tty子系统的flip buffer已经满了,直到acm_tty_unthrottle中会再次提交read urb

 

acm_tty_break_ctl是用来发送break信号的,RS232规定,收到break信号后,要output一段时间的logic zero

 

acm_tty_tiocmsetacm_tty_tiocmget主要是来设置和查询当前的CS232的硬件信号的支持。比如RTS信号

 

acm_tty_set_termios主要就是设置什么奇偶校验,波特率等串口传输特性。

阅读(10567) | 评论(0) | 转发(3) |
给主人留下些什么吧!~~