您好,登录后才能下订单哦!
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.
但是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 <lirc@bartelmus.de>
#
# 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 <lirc@bartelmus.de>
#
# 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)的键都被屏蔽掉了
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。