Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Lirc test remote control code

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

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.

If you use the default socket: mkdir / var/run/lirc

. / lircd-- device=/dev/lirc0-u if you specify: / opt/bin/lircd-- listen=5177-- device=/dev/lirc0, of course, this is an ideal situation, actually when recording with irrecord There are few times when the recording is completely correct.

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. It is very successful to get the above results. In most cases, the raw mode will be detected. I used an oscilloscope to observe the input waveform of the remote control head in real time. I found that the angle between the remote control head and the remote control head is different, and the waveform is very different in the synchronization head. Normally, a long low level followed by a slightly shorter high level is the synchronization head, but when it is abnormal. This part is only very narrow and a low level. So on this basis, how can we modify it and make it work properly? First, take a look at the generated conf file as follows: begin remote name new2.conf

Bits 33

Flags SPACE_ENC

Eps 30

Aeps 100 one 2671 8657

Zero 2671 2991

Ptrail 2671

Repeat 45210 11581

Gap 292566

Repeat_gap 292566

Toggle_bit_mask 0x0 begin codes

End codes end remote bit 33 is obviously wrong. It should be 32. After changing it to 32, we copy it to / etc/lirc.conf and modify the function receive_decode () in receive.c: LOGPRINTF (1, "code:% llx", code);-> logprintf (1, "code:% llx", code). Then run:. / lircd-- listen=5177-- device=/dev/lirc0-n &. / irw after pressing the button, you will see that code will print out, and the value of code is the actual remote control code: lircd: code: 608f807f lircd: code: 608fe01f so we can return to modify the conf file as follows: begin remote bits 16

Flags SPACE_ENC | CONST_LENGTH | REPEAT_HEADER

Eps 30

Aeps 100 one 2671 8657

Zero 2671 2991

Repeat 45207 11581

Ptrail 2671

Pre_data_bits 16

Pre_data 0x608f

Gap 292566

Toggle_bit_mask 0x0 begin codes

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 end remote is then tested with irw, and everything works fine. But the repeat key was not detected. Occasionally, when the remote control protocol was configured as SEJIN, I tried it with irrecord, and I got the correct code once: It is very important that you press many different buttons and hold them.

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. Press RETURN now to start recording.

....

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. The resulting file is as follows:

# 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:

# begin remote name / etc/lircd.conf

Bits 16

Flags SPACE_ENC | CONST_LENGTH

Eps 30

Aeps 100 header 8953 4441

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 end remote flags SPACE_ENC | CONST_LENGTH | the repeat key cannot be detected after REPEAT_HEADER has REPEAT_HEADER.

However, there is still a slight problem with the SEJIN protocol, that is, the first key press is often undetectable, and sometimes it takes several consecutive presses to detect it.

Look at the code and see that the only difference between SEJIN and NEC is the definition of the sampling clock:

# 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

The frequency of NEC should be 38KHz, so change it to 38000, and then use 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.

The generated file is as follows:

# 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

The head is basically right, and the specific key value can be measured by printing.

# 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

If it is found that some key values can be received by irw, but the input system does not:

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report