lirc测试遥控代码
1, Reboot the box.
网站建设哪家好,找创新互联!专注于网页设计、网站建设、微信开发、微信平台小程序开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了临海免费建站欢迎大家使用!
2, insmod /opt/lib/modules/2.6.34/extra/lirc_dev.ko
insmod /opt/lib/modules/2.6.34/extra/lnxplatLirc.ko
3, Enter /opt/bin and run irrecord, ./irrecord -d /dev/lirc0 --disable-namespace new.conf
4, Register ‘power’ key, ‘1’ key and ‘2’ key.
5, cp new.conf /etc/ lircd.conf
6, Run lircd with command ./lircd --listen=5177 --device=/dev/lirc0 -n &
7, Enter /opt/bin and run irw
8, Test the registered key.
./lircd --device=/dev/lirc0 -u
Found gap: 292566
Please keep on pressing buttons like described above.
................................................................................
Space/pulse encoded remote control found.
Signal length is 67.
No header data.
Found trail pulse: 2670
Found repeat code: 45207 11583
Found repeat gap: 292566
Signals are space encoded.
Signal length is 33
Now enter the names for the buttons.
bits 33
flags SPACE_ENC
eps 30
aeps 100
zero 2671 2991
ptrail 2671
repeat 45210 11581
gap 292566
repeat_gap 292566
toggle_bit_mask 0x0
end codes
flags SPACE_ENC|CONST_LENGTH|REPEAT_HEADER
eps 30
aeps 100
zero 2671 2991
repeat 45207 11581
ptrail 2671
pre_data_bits 16
pre_data 0x608f
gap 292566
toggle_bit_mask 0x0
0 0x00FF
1 0x807F
2 0x40BF
3 0xC03F
4 0x20DF
5 0xA05F
6 0x609F
7 0xE01F
8 0x10EF
9 0x906F
* 0x14EB
# 0xF807
CHAN_UP 0x23DC
CHAN_DOWN 0xA35C
VOL_UP 0x639C
VOL_DOWN 0xE31C
STANDBY 0xD02F
MUTE 0x28D7
CHANNEL 0x30CF
HOME 0xCC33
FAVORITE 0xE41B
MENU 0x708F
BACK 0x946B
OK 0xA857
UP 0x38C7
LEFT 0xB04F
RIGHT 0xB847
DOWN 0x7887
STOP 0x58A7
PALY 0xD827
FASTBACKWARD 0x08F7
FASTFORWARD 0x48B7
DEL 0x44BB
PAGE_UP 0xE817
PAGE_DOWN 0x50AF
LOCAL 0x4CB3
RED 0x847B
GREEN 0x9867
YELLOW 0x18E7
BLUE 0x04FB
F1 0x649B
F2 0xA45B
F3 0x24DB
F4 0xC43B
end codes
down for approximately one second. Each button should generate at least one
dot but in no case more than ten dots of output.
Don't stop pressing buttons until two lines of dots (2x80) have been
generated.
................................................................................
Found const length: 107221
Please keep on pressing buttons like described above.
................................................................................
Space/pulse encoded remote control found.
Signal length is 67.
Found possible header: 8953 4441
Found trail pulse: 595
Found repeat code: 8955 2204
Signals are space encoded.
Signal length is 32
Now enter the names for the buttons.
# Please make this file available to others
# by sending it to
#
# this config file was automatically generated
# using lirc-0.8.4a(default) on Thu Jan 1 01:05:46 1970
#
# contributed by
#
# brand: /etc/lircd.conf
# model no. of remote control:
# devices being controlled by this remote:
#
bits 16
flags SPACE_ENC|CONST_LENGTH
eps 30
aeps 100
one 594 1630
zero 594 515
ptrail 595
repeat 8955 2204
pre_data_bits 16
pre_data 0x608F
gap 107221
toggle_bit_mask 0x0
begin codes
KEY_0 0x00FF
KEY_1 0x807F
KEY_2 0x40BF
KEY_3 0xC03F
KEY_4 0x20DF
KEY_5 0xA05F
KEY_6 0x609F
KEY_7 0xE01F
KEY_8 0x10EF
KEY_9 0x906F
KEY_SWITCHVIDEOMODE 0x14EB
KEY_KBDILLUMTOGGLE 0xF807
KEY_CHANNELUP 0x23DC
KEY_CHANNELDOWN 0xA35C
KEY_VOLUMEUP 0x639C
KEY_VOLUMEDOWN 0xE31C
KEY_POWER 0xD02F
KEY_MUTE 0x28D7
KEY_CHANNEL 0x30CF
KEY_MENU 0xCC33
KEY_FAVORITES 0xE41B
KEY_HOME 0x708F
KEY_BACK 0x946B
KEY_ENTER 0xA857
KEY_UP 0x38C7
KEY_LEFT 0xB04F
KEY_RIGHT 0xB847
KEY_DOWN 0x7887
KEY_STOP 0x58A7
KEY_PLAY 0xD827
KEY_REWIND 0x08F7
KEY_FORWARD 0x48B7
KEY_DELETE 0x44BB
KEY_PAGEUP 0xE817
KEY_PAGEDOWN 0x50AF
LOCAL 0x4CB3
KEY_F1 0x847B
KEY_F2 0x9867
KEY_F3 0x18E7
KEY_F4 0x04FB
KEY_RED 0x649B
KEY_GREEN 0xA45B
KEY_YELLOW 0x24DB
KEY_BLUE 0xC43B
end codes
但是SEJIN的协议仍然有点小问题,就是第一次按键往往都检测不到,有时候要连续按几次才能检测到一次
查看代码,发现SEJIN和NEC的区别只是采样时钟的定义不同:
#if (REMOTE_PROTOCOL == REMOTE_PROTOCOL_SEJIN)
#define IRRX_CLK_CTRL 55
#define IR_FILTER_VALUE 0x320
#else
/* NEC RC5 */
#define IRRX_CLK_CTRL (((CRYSTAL_FREQUENCY / (16 * 38222 )) - 1)/8)
#define IR_FILTER_VALUE ((CRYSTAL_FREQUENCY / 1000000 )* 400 )
#endif
NEC的频率应该是38KHz,所以改为38000,然后再用irrecord
Press RETURN now to start recording.
................................................................................
Found const length: 352410
Please keep on pressing buttons like described above.
................................................................................
Space/pulse encoded remote control found.
Signal length is 67.
Found possible header: 45585 22623
Found trail pulse: 3033
Found repeat code: 45585 11230
Signals are space encoded.
Signal length is 32
Now enter the names for the buttons.
生成文件如下:
# Please make this file available to others
# by sending it to
#
# this config file was automatically generated
# using lirc-0.8.7(default) on Wed Dec 31 17:06:14 1969
#
# contributed by
#
# brand: new.conf
# model no. of remote control:
# devices being controlled by this remote:
#
begin remote
name new.conf
bits 32
flags SPACE_ENC|CONST_LENGTH
eps 30
aeps 100
header 45585 22623
one 3033 8297
zero 3033 2631
ptrail 3033
repeat 45585 11230
gap 352410
toggle_bit_mask 0x0
begin codes
end codes
end remote
头基本上都对了,具体键值,可用打印的办法测出
# Please make this file available to others
# by sending it to
#
# this config file was automatically generated
# using lirc-0.8.7(default) on Wed Dec 31 17:06:20 1969
#
# contributed by
#
# brand: new.conf
# model no. of remote control:
# devices being controlled by this remote:
#
begin remote
name new.conf
bits 16
flags SPACE_ENC|CONST_LENGTH
eps 30
aeps 100
header 45566 22645
one 3005 8325
zero 3005 2661
ptrail 3007
repeat 45566 11247
pre_data_bits 16
pre_data 0x608f
gap 352399
toggle_bit_mask 0x0
begin codes
KEY_0 0x00FF
KEY_1 0x807F
KEY_2 0x40BF
KEY_3 0xC03F
KEY_4 0x20DF
KEY_5 0xA05F
KEY_6 0x609F
KEY_7 0xE01F
KEY_8 0x10EF
KEY_9 0x906F
KEY_SWITCHVIDEOMODE 0x14EB
KEY_KBDILLUMTOGGLE 0xF807
KEY_CHANNELUP 0x23DC
KEY_CHANNELDOWN 0xA35C
KEY_VOLUMEUP 0x639C
KEY_VOLUMEDOWN 0xE31C
KEY_POWER 0xD02F
KEY_MUTE 0x28D7
KEY_CHANNEL 0x30CF
KEY_MENU 0xCC33
KEY_FAVORITES 0xE41B
KEY_HOME 0x708F
KEY_BACK 0x946B
KEY_ENTER 0xA857
KEY_UP 0x38C7
KEY_LEFT 0xB04F
KEY_RIGHT 0xB847
KEY_DOWN 0x7887
KEY_STOP 0x58A7
KEY_PLAY 0xD827
KEY_REWIND 0x08F7
KEY_FORWARD 0x48B7
KEY_DELETE 0x44BB
KEY_PAGEUP 0xE817
KEY_PAGEDOWN 0x50AF
LOCAL 0x4CB3
KEY_F1 0x847B
KEY_F2 0x9867
KEY_F3 0x18E7
KEY_F4 0x04FB
KEY_RED 0x649B
KEY_GREEN 0xA45B
KEY_YELLOW 0x24DB
KEY_BLUE 0xC43B
end codes
end remote
如果发现有些键值irw能接收到,但是input系统没有收到:
lircd.c
int setup_uinputfd(const char *name)
{
#if defined(__linux__)
int fd;
int key;
struct uinput_user_dev dev;
fd = open("/dev/input/uinput", O_RDWR);
if(fd == -1)
{
fd = open("/dev/uinput", O_RDWR);
if(fd == -1)
{
fd = open("/dev/misc/uinput", O_RDWR);
if(fd == -1)
{
fprintf(stderr, "could not open %s\n",
"uinput");
perror(NULL);
return -1;
}
}
}
memset(&dev, 0, sizeof(dev));
strncpy(dev.name, name, sizeof(dev.name));
dev.name[sizeof(dev.name)-1] = 0;
if(write(fd, &dev, sizeof(dev)) != sizeof(dev) ||
ioctl(fd, UI_SET_EVBIT, EV_KEY) != 0 )/*||
ioctl(fd, UI_SET_EVBIT, EV_REP) != 0) */
{
goto setup_error;
}
for(key = KEY_RESERVED; key <= KEY_UNKNOWN; key++)
{
if(ioctl(fd, UI_SET_KEYBIT, key) != 0)
{
goto setup_error;
}
}
if(ioctl(fd, UI_DEV_CREATE) != 0)
{
goto setup_error;
}
return fd;
setup_error:
fprintf(stderr, "could not setup %s\n", "uinput");
perror(NULL);
close(fd);
#endif
return -1;
}
由于在input_map.inc
{"KEY_UNKNOWN", 240},
所以大于240(0xF0)的键都被屏蔽掉了
名称栏目:lirc测试遥控代码
URL分享:http://scyanting.com/article/pphgdh.html