当前位置:  技术问答>linux和unix

lirc

    来源: 互联网  发布时间:2016-11-07

    本文导语:  LIRC - Linux Infrared Remote Control 谁玩过,用过,有啥好的建议参考一下。 | 这专业? 只玩过红外管... | Infrared Infrared (IR) rays are optical waves lying between the visible and the microwave...

LIRC - Linux Infrared Remote Control
谁玩过,用过,有啥好的建议参考一下。

|
这专业?
只玩过红外管...

|
Infrared
Infrared (IR) rays are optical waves lying between the visible and the microwave regions of the electromagnetic spectrum. One use of IR is in point-to-point data communication. Using IR, you can exchange visiting cards between PDAs, network two laptops, or dispatch a document to a printer. IR has a range of up to 1 meter within a 30-degree cone, spreading from –15 to +15 degrees.

There are two popular flavors of IR communication: Standard IR (SIR), which supports speeds of up to 115.20 Kbaud; and Fast IR (FIR), which has a bandwidth of 4Mbps.

Figure 16.4 shows IR connection on a laptop. UART1 in the Super I/O chipset is IR-enabled, so an IR transceiver is directly connected to it. Laptops having no IR support in their Super I/O chip may rely on an external IR dongle (see the section "Device Example: IR Dongle") similar to the one connected to UART0. Figure 16.5 shows IR connection on an embedded SoC having a built-in IR dongle connected to a system UART.

Linux supports IR communication on two planes:

Intelligent data-transfer via protocols specified by the Infrared Data Association (IrDA). This is implemented by the Linux-IrDA project.

Controlling applications via a remote control. This is implemented by the Linux Infrared Remote Control (LIRC) project.

This section primarily explores Linux-IrDA but takes a quick look at LIRC before wrapping up.

Linux-IrDA
The Linux-IrDA project (http://irda.sourceforge.net/) brings IrDA capabilities to the kernel. To get an idea of how Linux-IrDA components relate vis-à-vis the IrDA stack and possible hardware configurations, let's criss-cross through Figure 16.6:

Device drivers constitute the bottom layer. SIR chipsets that are 16550-compatible can reuse the native Linux serial driver after shaping its behavior using the IrDA line discipline, IrTTY. An alternative to this combo is the IrPort driver. FIR chipsets have their own special drivers.

Next comes the core protocol stack. This consists of the IR Link Access Protocol (IrLAP), IR Link Management Protocol (IrLMP), Tiny Transport Protocol (TinyTP), and the IrDA socket (IrSock) interface. IrLAP provides a reliable transport as well as the state machine to discover neighboring devices. IrLMP is a multiplexer over IrLAP. TinyTP provides segmentation, reassembly, and flow control. IrSock offers a socket interface over IrLMP and TinyTP.

Higher regions of the stack marry IrDA to data-transfer applications. IrLAN and IrNET enable networking, while IrComm allows serial communication.

You also need the applications that ultimately make or break the technology. An example is openobex (http://openobex.sourceforge.net/), which implements the OBject EXchange (OBEX) protocol used to exchange objects such as documents and visiting cards. To configure Linux-IrDA, you need the irda-utils package that comes bundled with many distributions. This provides tools such as irattach, irdadump, and irdaping.

Device Example: Super I/O Chip
To get a first taste of Linux-IrDA, let's get two laptops talking to each other over IR. Each laptop is IR-enabled via National Semiconductor's NSC PC87382 Super I/O chip.[2] UART1 in Figure 16.4 shows the connection scenario. The PC87382 chip can work in both SIR and FIR modes. We will look at each in turn.

[2] Super I/O chipsets typically support several peripherals besides IrDA, such as serial ports, parallel ports, Musical Instrument Digital Interface (MIDI), and floppy controllers.

SIR chips offer a UART interface to the host computer. For communicating in SIR mode, attach the associated UART port (/dev/ttyS1 in this example) of each laptop to the IrDA stack:

bash> irattach /dev/ttyS1 -s


Verify that IrDA kernel modules (irda.ko, sir_dev.ko, and irtty_sir.ko) are loaded and that the irda_sir_wq kernel thread is running. The irda0 interface should also have made an appearance in the ifconfig output. The -s option to irattach triggers a search for IR activity in the neighborhood. If you slide the laptops such that their IR transceivers lie within the range cone, they will be able to spot each other:

bash> cat /proc/net/irda/discovery
nickname: localhost, hint: 0x4400, saddr: 0x55529048, daddr: 0x8fefb350


The other laptop makes a similar announcement, but with the source and destination addresses (saddr and daddr) reversed. You may set the desired communication speed using stty on ttyS1. To set the baud rate to 19200, do this:

bash> stty speed 19200 

    
 
 

您可能感兴趣的文章:

 
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。












  • 相关文章推荐


  • 站内导航:


    特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

    ©2012-2021,,E-mail:www_#163.com(请将#改为@)

    浙ICP备11055608号-3