lirc

ShowMan 2009-07-18 01:04:58
LIRC - Linux Infrared Remote Control
谁玩过,用过,有啥好的建议参考一下。
...全文
341 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
fuyongwasu 2011-02-18
  • 打赏
  • 举报
回复
为什么看不到关键。。。。
ShowMan 2009-07-18
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 yhf365 的回复:]
引用 3 楼 showman 的回复:
晕,楼上的书,我去下,发现资源分不够,这太。。。。

老兄,我帮你下了,
发你hotmail邮箱里了。
morris88把资源分设成10分,
不厚道~~~
[/Quote]

这不是被榨取了吗? 网上一大把不要费用的, 不过还是太感谢了。
ShowMan 2009-07-18
  • 打赏
  • 举报
回复
当然第一看的就是官网, 一边看,一边发贴问。
pottichu 2009-07-18
  • 打赏
  • 举报
回复
http://www.lirc.org/

这不是有官方网站么 ?
yhf365 2009-07-18
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 showman 的回复:]
晕,楼上的书,我去下,发现资源分不够,这太。。。。
[/Quote]
老兄,我帮你下了,
发你hotmail邮箱里了。
morris88把资源分设成10分,
不厚道~~~
ShowMan 2009-07-18
  • 打赏
  • 举报
回复
当然要摸索, 贴也是要发的。。
  • 打赏
  • 举报
回复
没玩过,这东西还是自己摸索把。
就算别人玩过,你还是得摸索。
ShowMan 2009-07-18
  • 打赏
  • 举报
回复
晕,楼上的书,我去下,发现资源分不够,这太。。。。
morris88 2009-07-18
  • 打赏
  • 举报
回复
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 < /dev/ttyS1


The easiest way to cull IR activity from the air is by using the debug tool, irdadump. Here's a sample dump obtained during the preceding connection establishment, which shows the negotiated parameters:

Code View:
bash> irdadump -i irda0
...
22:05:07.831424 snrm:cmd ca=fe pf=1 6fb7ff33 > 2c0ce8b6 new-ca=40
LAP QoS: Baud Rate=19200bps Max Turn Time=500ms Data Size=2048B Window Size=7 Add
BOFS=0 Min Turn Time=5000us Link Disc=12s (32)
22:05:07.987043 ua:rsp ca=40 pf=1 6fb7ff33 < 2c0ce8b6
LAP QoS: Baud Rate=19200bps Max Turn Time=500ms Data Size=2048B Window Size=7 Add
BOFS=0 Min Turn Time=5000us Link Disc=12s (31)
...




You can also obtain debug information out of the IrDA stack by controlling the verbosity level in /proc/sys/net/irda/debug.

To set the laptops in FIR mode, dissociate ttyS1 from the native serial driver and instead attach it to the NSC FIR driver, nsc-ircc.ko:

bash> setserial /dev/ttyS1 uart none
bash> modprobe nsc-ircc dongle_id=0x09
bash> irattach irda0 -s


dongle_id depends on your IR hardware and can be found from your hardware documentation. As you did for SIR, take a look at /proc/net/irda/discovery to see whether things are okay thus far. Sometimes, FIR communication hangs at higher speeds. If irdadump shows a communication freeze, either put on your kernel hacking hat and fix the code, or try lowering the negotiated speed by tweaking /proc/sys/net/irda/max_baud_rate.

Note that unlike the Bluetooth physical layer that can establish one-to-many connections, IR can support only a single connection per physical device at a time.

Device Example: IR Dongle
Dongles are IR devices that plug into serial or USB ports. Some microcontrollers (such as Cirrus Logic's EP7211 shown in Figure 16.5) that have on-chip IR controllers wired to their UARTs are also considered dongles.

Dongle drivers are a set of control methods responsible for operations such as changing the communication speed. They have four entry points: open(), reset(), change_speed(), and close(). These entry points are defined as part of a dongle_driver structure and are invoked from the context of the IrDA kernel thread, irda_sir_wq. Dongle driver methods are allowed to block because they are invoked from process context with no locks held. The IrDA core offers three helper functions to dongle drivers: sirdev_raw_write() and sirdev_raw_read() to exchange control data with the associated UART, and sirdev_set_dtr_rts() to wiggle modem control lines connected to the UART.

Because you're probably more likely to add kernel support for dongles than modify other parts of Linux-IrDA, let's implement an example dongle driver. Assume that you're enabling a yet-unsupported simple serial IR dongle that communicates only at 19200 or 57600 baud. Assume also that when the user wants to toggle the baud rate between these two values, you have to hold the UART's Request-to-Send (RTS) pin low for 50 microseconds and pull it back high for 25 microseconds. Listing 16.2 implements a dongle driver for this device.


详细见 http://download.csdn.net/source/1277135
yhf365 2009-07-18
  • 打赏
  • 举报
回复
这专业?
只玩过红外管...

4,441

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 内核源代码研究区
社区管理员
  • 内核源代码研究区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧