From: ukw Date: Thu, 2 Sep 2010 10:07:18 +0000 (+0000) Subject: Version 1.8.0: added JVC in irsnd, fitted APPLE protocol to IRMP 1.7.3 X-Git-Tag: irmp-libopencm3-pre-1~143 X-Git-Url: http://cloudbase.mooo.com/gitweb/irmp.git/commitdiff_plain/c7a47e897cc2d4716bf54b323c46978e624b65cf?hp=4957f820f027b7e0f30b88fbef5a11c8e7d9c570 Version 1.8.0: added JVC in irsnd, fitted APPLE protocol to IRMP 1.7.3 git-svn-id: svn://mikrocontroller.net/irmp@46 aeb2e35e-bfc4-4214-b83c-9e8de998ed28 --- diff --git a/IR-Data/test-suite.sh b/IR-Data/test-suite.sh index 53585ed..a1abf02 100644 --- a/IR-Data/test-suite.sh +++ b/IR-Data/test-suite.sh @@ -28,6 +28,7 @@ for j in \ Grundig_TP715.txt \ Grundig_TP715_SatTV.txt \ Grundig_TP715_Video.txt \ + Kathrein-UFS-912-Remote.txt \ Matsushita.txt \ Nokia.txt \ Panasonic-Blue-Ray.txt \ @@ -62,28 +63,30 @@ for j in \ rc6-hold.txt \ rc6.txt \ sharp-denon.txt \ - sharp-denon2.txt + sharp-denon2.txt \ + xbox360-10kHz.txt do echo "testing $j ..." if tmpsrc/irmp -v < $j | grep -q error then - tmpsrc/irmp -v < $j | grep error - echo "test failed" - exit 1 + tmpsrc/irmp -v < $j | grep error + echo "test failed" + exit 1 fi done for j in \ Siemens-Gigaset-M740AV-15kHz.txt \ bo_beolink1000-15kHz.txt \ - denon-15kHz.txt + denon-15kHz.txt \ + xbox360-15kHz.txt do echo "testing $j ..." if tmpsrc/irmp-15kHz -v < $j | grep -q error then - tmpsrc/irmp-15kHz -v < $j | grep error - echo "test failed" - exit 1 + tmpsrc/irmp-15kHz -v < $j | grep error + echo "test failed" + exit 1 fi done @@ -95,9 +98,9 @@ do echo "testing $j ..." if tmpsrc/irmp-20kHz -v < $j | grep -q error then - tmpsrc/irmp-20kHz -v < $j | grep error - echo "test failed" - exit 1 + tmpsrc/irmp-20kHz -v < $j | grep error + echo "test failed" + exit 1 fi done diff --git a/README.txt b/README.txt index e065ac2..0bf0e38 100644 --- a/README.txt +++ b/README.txt @@ -1,8 +1,8 @@ IRMP - Infrared Multi Protocol Decoder -------------------------------------- -Version IRMP: 1.7.3 29.08.2010 -Version IRSND: 1.7.3 29.08.2010 +Version IRMP: 1.8.0 02.09.2010 +Version IRSND: 1.8.0 92.09.2010 Dokumentation: diff --git a/irmp.c b/irmp.c index 4077f54..879d50e 100644 --- a/irmp.c +++ b/irmp.c @@ -3,7 +3,7 @@ * * Copyright (c) 2009-2010 Frank Meyer - frank(at)fli4l.de * - * $Id: irmp.c,v 1.79 2010/08/28 22:14:56 fm Exp $ + * $Id: irmp.c,v 1.82 2010/08/31 15:22:24 fm Exp $ * * ATMEGA88 @ 8 MHz * @@ -342,16 +342,6 @@ typedef unsigned int16 uint16_t; #define IRMP_SUPPORT_MANCHESTER 0 #endif -#define IRMP_TIMEOUT_TIME 16500.0e-6 // timeout after 16.5 ms darkness -#define IRMP_TIMEOUT_TIME_MS 16500L // timeout after 16.5 ms darkness - -#if (F_INTERRUPTS * IRMP_TIMEOUT_TIME_MS) / 1000000 >= 254 -typedef uint16_t PAUSE_LEN; -#else -typedef uint8_t PAUSE_LEN; -#endif - -#define IRMP_TIMEOUT_LEN (PAUSE_LEN)(F_INTERRUPTS * IRMP_TIMEOUT_TIME + 0.5) #define IRMP_KEY_REPETITION_LEN (uint16_t)(F_INTERRUPTS * 150.0e-3 + 0.5) // autodetect key repetition within 150 msec #define MIN_TOLERANCE_00 1.0 // -0% @@ -474,8 +464,10 @@ typedef uint8_t PAUSE_LEN; #define RC6_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) #define RC6_TOGGLE_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC6_TOGGLE_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1) #define RC6_TOGGLE_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_TOGGLE_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1) -#define RC6_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC6_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1) -#define RC6_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define RC6_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC6_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define RC6_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_BIT_TIME * MAX_TOLERANCE_30 + 0.5) + 1) // pulses: 300 - 700 +#define RC6_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC6_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1) // pauses: 300 - 600 +#define RC6_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1) #define RECS80EXT_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PULSE_TIME * MIN_TOLERANCE_00 + 0.5) - 1) #define RECS80EXT_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PULSE_TIME * MAX_TOLERANCE_00 + 0.5) + 1) @@ -617,6 +609,7 @@ static int verbose; #endif #define UART0_TXEN_BIT_VALUE (1< IRMP_TIMEOUT_LEN) // timeout? { // yes... - ANALYZE_PRINTF ("error 1: pause after start bit pulse %d too long: %d\n", irmp_pulse_time, irmp_pause_time); - ANALYZE_ONLY_NORMAL_PUTCHAR ('\n'); +#if IRMP_SUPPORT_JVC_PROTOCOL == 1 + if (irmp_protocol == IRMP_JVC_PROTOCOL) // don't show eror if JVC protocol, irmp_pulse_time has been set below! + { + ; + } + else +#endif // IRMP_SUPPORT_JVC_PROTOCOL == 1 + { + ANALYZE_PRINTF ("%8d error 1: pause after start bit pulse %d too long: %d\n", time_counter, irmp_pulse_time, irmp_pause_time); + ANALYZE_ONLY_NORMAL_PUTCHAR ('\n'); + } irmp_start_bit_detected = 0; // reset flags, let's wait for another start bit irmp_pulse_time = 0; irmp_pause_time = 0; @@ -1539,7 +1542,7 @@ irmp_ISR (void) irmp_param2.protocol = 0; #endif - ANALYZE_PRINTF ("start-bit: pulse = %d, pause = %d\n", irmp_pulse_time, irmp_pause_time); + ANALYZE_PRINTF ("%8d [start-bit: pulse = %2d, pause = %2d]\n", time_counter, irmp_pulse_time, irmp_pause_time); #if IRMP_SUPPORT_SIRCS_PROTOCOL == 1 if (irmp_pulse_time >= SIRCS_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= SIRCS_START_BIT_PULSE_LEN_MAX && @@ -1717,7 +1720,7 @@ irmp_ISR (void) RC6_START_BIT_PAUSE_LEN_MIN, RC6_START_BIT_PAUSE_LEN_MAX); irmp_param_p = (IRMP_PARAMETER *) &rc6_param; last_pause = 0; - last_value = 0; + last_value = 1; } else #endif // IRMP_SUPPORT_RC6_PROTOCOL == 1 @@ -1838,9 +1841,9 @@ irmp_ISR (void) else { ANALYZE_PRINTF ("pulse: %3d - %3d or %3d - %3d\n", irmp_param.pulse_1_len_min, irmp_param.pulse_1_len_max, - 2 * irmp_param.pulse_1_len_min, 2 * irmp_param.pulse_1_len_max); + irmp_param.pulse_1_len_max + 1, 2 * irmp_param.pulse_1_len_max); ANALYZE_PRINTF ("pause: %3d - %3d or %3d - %3d\n", irmp_param.pause_1_len_min, irmp_param.pause_1_len_max, - 2 * irmp_param.pause_1_len_min, 2 * irmp_param.pause_1_len_max); + irmp_param.pause_1_len_max + 1, 2 * irmp_param.pause_1_len_max); } #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1) @@ -2056,35 +2059,60 @@ irmp_ISR (void) #if IRMP_SUPPORT_MANCHESTER == 1 if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER)) // Manchester { -#if IRMP_SUPPORT_RC6_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_bit >= 3 && irmp_bit <= 5) // special bits of RC6 + if (irmp_pulse_time > irmp_param.pulse_1_len_max /* && irmp_pulse_time <= 2 * irmp_param.pulse_1_len_max */) { - if (irmp_pulse_time > RC6_TOGGLE_BIT_LEN_MAX && irmp_pause_time > RC6_TOGGLE_BIT_LEN_MAX) +#if IRMP_SUPPORT_RC6_PROTOCOL == 1 + if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_bit == 4 && irmp_pulse_time > RC6_TOGGLE_BIT_LEN_MIN) // RC6 toggle bit { - ANALYZE_PUTCHAR ('1'); - irmp_store_bit (1); + ANALYZE_PUTCHAR ('T'); + if (irmp_param.complete_len == RC6_COMPLETE_DATA_LEN_LONG) // RC6 mode 6A + { + irmp_store_bit (1); + last_value = 1; + } + else // RC6 mode 0 + { + irmp_store_bit (0); + last_value = 0; + } + ANALYZE_NEWLINE (); } + else +#endif // IRMP_SUPPORT_RC6_PROTOCOL == 1 + { + ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '0' : '1'); + irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 0 : 1 ); - ANALYZE_PUTCHAR ('0'); - irmp_store_bit (0); - last_value = 0; - ANALYZE_NEWLINE (); - } - else +#if IRMP_SUPPORT_RC6_PROTOCOL == 1 + if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_bit == 4 && irmp_pulse_time > RC6_TOGGLE_BIT_LEN_MIN) // RC6 toggle bit + { + ANALYZE_PUTCHAR ('T'); + irmp_store_bit (1); + + if (irmp_pause_time > 2 * irmp_param.pause_1_len_max) + { + last_value = 0; + } + else + { + last_value = 1; + } + ANALYZE_NEWLINE (); + } + else #endif // IRMP_SUPPORT_RC6_PROTOCOL == 1 - if (irmp_pulse_time > irmp_param.pulse_1_len_max && irmp_pulse_time <= 2 * irmp_param.pulse_1_len_max) - { - ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '0' : '1'); - irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 0 : 1 ); - ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '1' : '0'); - irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 1 : 0 ); + { + ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '1' : '0'); + irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 1 : 0 ); #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1) - if (! irmp_param2.protocol) + if (! irmp_param2.protocol) #endif - { - ANALYZE_NEWLINE (); + { + ANALYZE_NEWLINE (); + } + last_value = (irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 1 : 0; + } } - last_value = (irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 1 : 0; } else if (irmp_pulse_time >= irmp_param.pulse_1_len_min && irmp_pulse_time <= irmp_param.pulse_1_len_max) { @@ -2100,22 +2128,28 @@ irmp_ISR (void) manchester_value = last_value; } -#if 0 -#if IRMP_SUPPORT_RC6_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_bit == 1 && manchester_value == 0) // RC6 mode != 0 ??? - { - irmp_param.complete_len = RC6_COMPLETE_DATA_LEN_LONG; - } -#endif // IRMP_SUPPORT_RC6_PROTOCOL == 1 -#endif // 0 - ANALYZE_PUTCHAR (manchester_value + '0'); + #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1) if (! irmp_param2.protocol) #endif { ANALYZE_NEWLINE (); } + +#if IRMP_SUPPORT_RC6_PROTOCOL == 1 + if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_bit == 1 && manchester_value == 1) // RC6 mode != 0 ??? + { + ANALYZE_PRINTF ("Switching to RC6A protocol\n"); + irmp_param.complete_len = RC6_COMPLETE_DATA_LEN_LONG; + irmp_param.address_offset = 5; + irmp_param.address_end = irmp_param.address_offset + 15; + irmp_param.command_offset = irmp_param.address_end + 1; // skip 1 system bit, changes like a toggle bit + irmp_param.command_end = irmp_param.command_offset + 16 - 1; + irmp_tmp_address = 1; // addr 0 - 32767 --> 32768 - 65535 + } +#endif // IRMP_SUPPORT_RC6_PROTOCOL == 1 + irmp_store_bit (manchester_value); } else @@ -2145,7 +2179,7 @@ irmp_ISR (void) { ANALYZE_PUTCHAR ('?'); ANALYZE_NEWLINE (); - ANALYZE_PRINTF ("error 3 RC5: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time); + ANALYZE_PRINTF ("error 3 manchester: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time); ANALYZE_ONLY_NORMAL_PUTCHAR ('\n'); irmp_start_bit_detected = 0; // reset flags and wait for next start bit irmp_pause_time = 0; @@ -2378,7 +2412,7 @@ irmp_ISR (void) if (irmp_start_bit_detected && irmp_bit == irmp_param.complete_len && irmp_param.stop_bit == 0) // enough bits received? { - if (last_irmp_command == irmp_tmp_command && repetition_counter < AUTO_FRAME_REPETITION_LEN) + if (last_irmp_command == irmp_tmp_command && repetition_len < AUTO_FRAME_REPETITION_LEN) { repetition_frame_number++; } @@ -2392,8 +2426,8 @@ irmp_ISR (void) if (irmp_param.protocol == IRMP_SIRCS_PROTOCOL && (repetition_frame_number == 1 || repetition_frame_number == 2)) { ANALYZE_PRINTF ("code skipped: SIRCS auto repetition frame #%d, counter = %d, auto repetition len = %d\n", - repetition_frame_number + 1, repetition_counter, AUTO_FRAME_REPETITION_LEN); - repetition_counter = 0; + repetition_frame_number + 1, repetition_len, AUTO_FRAME_REPETITION_LEN); + repetition_len = 0; } else #endif @@ -2403,8 +2437,8 @@ irmp_ISR (void) if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL && repetition_frame_number == 1) { ANALYZE_PRINTF ("code skipped: KASEIKYO auto repetition frame #%d, counter = %d, auto repetition len = %d\n", - repetition_frame_number + 1, repetition_counter, AUTO_FRAME_REPETITION_LEN); - repetition_counter = 0; + repetition_frame_number + 1, repetition_len, AUTO_FRAME_REPETITION_LEN); + repetition_len = 0; } else #endif @@ -2414,8 +2448,8 @@ irmp_ISR (void) if (irmp_param.protocol == IRMP_SAMSUNG32_PROTOCOL && (repetition_frame_number & 0x01)) { ANALYZE_PRINTF ("code skipped: SAMSUNG32 auto repetition frame #%d, counter = %d, auto repetition len = %d\n", - repetition_frame_number + 1, repetition_counter, AUTO_FRAME_REPETITION_LEN); - repetition_counter = 0; + repetition_frame_number + 1, repetition_len, AUTO_FRAME_REPETITION_LEN); + repetition_len = 0; } else #endif @@ -2425,14 +2459,14 @@ irmp_ISR (void) if (irmp_param.protocol == IRMP_NUBERT_PROTOCOL && (repetition_frame_number & 0x01)) { ANALYZE_PRINTF ("code skipped: NUBERT auto repetition frame #%d, counter = %d, auto repetition len = %d\n", - repetition_frame_number + 1, repetition_counter, AUTO_FRAME_REPETITION_LEN); - repetition_counter = 0; + repetition_frame_number + 1, repetition_len, AUTO_FRAME_REPETITION_LEN); + repetition_len = 0; } else #endif { - ANALYZE_PRINTF ("code detected, length = %d\n", irmp_bit); + ANALYZE_PRINTF ("%8d code detected, length = %d\n", time_counter, irmp_bit); irmp_ir_detected = TRUE; #if IRMP_SUPPORT_DENON_PROTOCOL == 1 @@ -2477,18 +2511,18 @@ irmp_ISR (void) #if IRMP_SUPPORT_NEC_PROTOCOL == 1 if (irmp_param.protocol == IRMP_NEC_PROTOCOL && irmp_bit == 0) // repetition frame { - if (repetition_counter < NEC_FRAME_REPEAT_PAUSE_LEN_MAX) + if (repetition_len < NEC_FRAME_REPEAT_PAUSE_LEN_MAX) { - ANALYZE_PRINTF ("Detected NEC repetition frame, repetition_counter = %d\n", repetition_counter); + ANALYZE_PRINTF ("Detected NEC repetition frame, repetition_len = %d\n", repetition_len); irmp_tmp_address = last_irmp_address; // address is last address irmp_tmp_command = last_irmp_command; // command is last command irmp_flags |= IRMP_FLAG_REPETITION; - repetition_counter = 0; + repetition_len = 0; } else { - ANALYZE_PRINTF ("Detected NEC repetition frame, ignoring it: timeout occured, repetition_counter = %d > %d\n", - repetition_counter, NEC_FRAME_REPEAT_PAUSE_LEN_MAX); + ANALYZE_PRINTF ("Detected NEC repetition frame, ignoring it: timeout occured, repetition_len = %d > %d\n", + repetition_len, NEC_FRAME_REPEAT_PAUSE_LEN_MAX); irmp_ir_detected = FALSE; } } @@ -2519,6 +2553,14 @@ irmp_ISR (void) } #endif // IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1 +#if IRMP_SUPPORT_RC6_PROTOCOL == 1 + if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_param.complete_len == RC6_COMPLETE_DATA_LEN_LONG) // RC6 mode = 6? + { + irmp_protocol = IRMP_RC6A_PROTOCOL; + } + else +#endif // IRMP_SUPPORT_RC6_PROTOCOL == 1 + irmp_protocol = irmp_param.protocol; #if IRMP_SUPPORT_FDC_PROTOCOL == 1 @@ -2560,7 +2602,7 @@ irmp_ISR (void) { if (last_irmp_command == irmp_command && last_irmp_address == irmp_address && - repetition_counter < IRMP_KEY_REPETITION_LEN) + repetition_len < IRMP_KEY_REPETITION_LEN) { irmp_flags |= IRMP_FLAG_REPETITION; } @@ -2568,7 +2610,7 @@ irmp_ISR (void) last_irmp_address = irmp_tmp_address; // store as last address, too last_irmp_command = irmp_tmp_command; // store as last command, too - repetition_counter = 0; + repetition_len = 0; } else { @@ -2616,7 +2658,7 @@ irmp_ISR (void) static void print_timings (void) { - printf ("IRMP_TIMEOUT_LEN: %d\n", IRMP_TIMEOUT_LEN); + printf ("IRMP_TIMEOUT_LEN: %d [%d byte(s)]\n", IRMP_TIMEOUT_LEN, sizeof (PAUSE_LEN)); printf ("IRMP_KEY_REPETITION_LEN %d\n", IRMP_KEY_REPETITION_LEN); puts (""); printf ("PROTOCOL S S-PULSE S-PAUSE PULSE-0 PAUSE-0 PULSE-1 PAUSE-1\n"); @@ -2665,9 +2707,9 @@ print_timings (void) DENON_PULSE_LEN_MIN, DENON_PULSE_LEN_MAX, DENON_0_PAUSE_LEN_MIN, DENON_0_PAUSE_LEN_MAX, DENON_PULSE_LEN_MIN, DENON_PULSE_LEN_MAX, DENON_1_PAUSE_LEN_MIN, DENON_1_PAUSE_LEN_MAX); - printf ("RC6 1 %3d - %3d %3d - %3d %3d - %3d\n", + printf ("RC6 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n", RC6_START_BIT_PULSE_LEN_MIN, RC6_START_BIT_PULSE_LEN_MAX, RC6_START_BIT_PAUSE_LEN_MIN, RC6_START_BIT_PAUSE_LEN_MAX, - RC6_BIT_LEN_MIN, RC6_BIT_LEN_MAX); + RC6_BIT_PULSE_LEN_MIN, RC6_BIT_PULSE_LEN_MAX, RC6_BIT_PAUSE_LEN_MIN, RC6_BIT_PAUSE_LEN_MAX); printf ("RECS80EXT 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n", RECS80EXT_START_BIT_PULSE_LEN_MIN, RECS80EXT_START_BIT_PULSE_LEN_MAX, RECS80EXT_START_BIT_PAUSE_LEN_MIN, RECS80EXT_START_BIT_PAUSE_LEN_MAX, @@ -2934,12 +2976,96 @@ get_fdc_key (uint16_t cmd) return (key); } +static int analyze = FALSE; +static int list = FALSE; +static IRMP_DATA irmp_data; + +static void +next_tick (void) +{ + if (! analyze && ! list) + { + (void) irmp_ISR (); + + if (irmp_get_data (&irmp_data)) + { + uint8_t key; + + ANALYZE_ONLY_NORMAL_PUTCHAR (' '); + + if (verbose) + { + printf ("%8d ", time_counter); + } + + if (irmp_data.protocol == IRMP_FDC_PROTOCOL && (key = get_fdc_key (irmp_data.command)) != 0) + { + if ((key >= 0x20 && key < 0x7F) || key >= 0xA0) + { + printf ("p = %2d, a = 0x%04x, c = 0x%04x, f = 0x%02x, asc = 0x%02x, key = '%c'\n", + irmp_data.protocol, irmp_data.address, irmp_data.command, irmp_data.flags, key, key); + } + else if (key == '\r' || key == '\t' || key == KEY_ESCAPE || (key >= 0x80 && key <= 0x9F)) // function keys + { + char * p = (char *) NULL; + + switch (key) + { + case '\t' : p = "TAB"; break; + case '\r' : p = "CR"; break; + case KEY_ESCAPE : p = "ESCAPE"; break; + case KEY_MENUE : p = "MENUE"; break; + case KEY_BACK : p = "BACK"; break; + case KEY_FORWARD : p = "FORWARD"; break; + case KEY_ADDRESS : p = "ADDRESS"; break; + case KEY_WINDOW : p = "WINDOW"; break; + case KEY_1ST_PAGE : p = "1ST_PAGE"; break; + case KEY_STOP : p = "STOP"; break; + case KEY_MAIL : p = "MAIL"; break; + case KEY_FAVORITES : p = "FAVORITES"; break; + case KEY_NEW_PAGE : p = "NEW_PAGE"; break; + case KEY_SETUP : p = "SETUP"; break; + case KEY_FONT : p = "FONT"; break; + case KEY_PRINT : p = "PRINT"; break; + case KEY_ON_OFF : p = "ON_OFF"; break; + + case KEY_INSERT : p = "INSERT"; break; + case KEY_DELETE : p = "DELETE"; break; + case KEY_LEFT : p = "LEFT"; break; + case KEY_HOME : p = "HOME"; break; + case KEY_END : p = "END"; break; + case KEY_UP : p = "UP"; break; + case KEY_DOWN : p = "DOWN"; break; + case KEY_PAGE_UP : p = "PAGE_UP"; break; + case KEY_PAGE_DOWN : p = "PAGE_DOWN"; break; + case KEY_RIGHT : p = "RIGHT"; break; + case KEY_MOUSE_1 : p = "KEY_MOUSE_1"; break; + case KEY_MOUSE_2 : p = "KEY_MOUSE_2"; break; + default : p = ""; break; + } + + printf ("p = %2d, a = 0x%04x, c = 0x%04x, f = 0x%02x, asc = 0x%02x, key = %s\n", + irmp_data.protocol, irmp_data.address, irmp_data.command, irmp_data.flags, key, p); + } + else + { + printf ("p = %2d, a = 0x%04x, c = 0x%04x, f = 0x%02x, asc = 0x%02x\n", + irmp_data.protocol, irmp_data.address, irmp_data.command, irmp_data.flags, key); + } + } + else + { + printf ("p = %2d, a = 0x%04x, c = 0x%04x, f = 0x%02x\n", + irmp_data.protocol, irmp_data.address, irmp_data.command, irmp_data.flags); + } + } + } +} + int main (int argc, char ** argv) { int i; - int analyze = FALSE; - int list = FALSE; int ch; int last_ch = 0; int pulse = 0; @@ -2953,8 +3079,6 @@ main (int argc, char ** argv) int first_pulse = TRUE; int first_pause = TRUE; - IRMP_DATA irmp_data; - if (argc == 2) { if (! strcmp (argv[1], "-v")) @@ -3074,7 +3198,7 @@ main (int argc, char ** argv) { for (i = 0; i < (int) ((8000.0 * F_INTERRUPTS) / 10000); i++) // newline: long pause of 800 msec { - (void) irmp_ISR (); + next_tick (); } } first_pulse = TRUE; @@ -3108,78 +3232,7 @@ main (int argc, char ** argv) last_ch = ch; - if (! analyze && ! list) - { - (void) irmp_ISR (); - - if (irmp_get_data (&irmp_data)) - { - uint8_t key; - - ANALYZE_ONLY_NORMAL_PUTCHAR (' '); - - if (irmp_data.protocol == IRMP_FDC_PROTOCOL && (key = get_fdc_key (irmp_data.command)) != 0) - { - if ((key >= 0x20 && key < 0x7F) || key >= 0xA0) - { - printf ("p = %2d, a = 0x%04x, c = 0x%04x, f = 0x%02x, asc = 0x%02x, key = '%c'\n", - irmp_data.protocol, irmp_data.address, irmp_data.command, irmp_data.flags, key, key); - } - else if (key == '\r' || key == '\t' || key == KEY_ESCAPE || (key >= 0x80 && key <= 0x9F)) // function keys - { - char * p = (char *) NULL; - - switch (key) - { - case '\t' : p = "TAB"; break; - case '\r' : p = "CR"; break; - case KEY_ESCAPE : p = "ESCAPE"; break; - case KEY_MENUE : p = "MENUE"; break; - case KEY_BACK : p = "BACK"; break; - case KEY_FORWARD : p = "FORWARD"; break; - case KEY_ADDRESS : p = "ADDRESS"; break; - case KEY_WINDOW : p = "WINDOW"; break; - case KEY_1ST_PAGE : p = "1ST_PAGE"; break; - case KEY_STOP : p = "STOP"; break; - case KEY_MAIL : p = "MAIL"; break; - case KEY_FAVORITES : p = "FAVORITES"; break; - case KEY_NEW_PAGE : p = "NEW_PAGE"; break; - case KEY_SETUP : p = "SETUP"; break; - case KEY_FONT : p = "FONT"; break; - case KEY_PRINT : p = "PRINT"; break; - case KEY_ON_OFF : p = "ON_OFF"; break; - - case KEY_INSERT : p = "INSERT"; break; - case KEY_DELETE : p = "DELETE"; break; - case KEY_LEFT : p = "LEFT"; break; - case KEY_HOME : p = "HOME"; break; - case KEY_END : p = "END"; break; - case KEY_UP : p = "UP"; break; - case KEY_DOWN : p = "DOWN"; break; - case KEY_PAGE_UP : p = "PAGE_UP"; break; - case KEY_PAGE_DOWN : p = "PAGE_DOWN"; break; - case KEY_RIGHT : p = "RIGHT"; break; - case KEY_MOUSE_1 : p = "KEY_MOUSE_1"; break; - case KEY_MOUSE_2 : p = "KEY_MOUSE_2"; break; - default : p = ""; break; - } - - printf ("p = %2d, a = 0x%04x, c = 0x%04x, f = 0x%02x, asc = 0x%02x, key = %s\n", - irmp_data.protocol, irmp_data.address, irmp_data.command, irmp_data.flags, key, p); - } - else - { - printf ("p = %2d, a = 0x%04x, c = 0x%04x, f = 0x%02x, asc = 0x%02x\n", - irmp_data.protocol, irmp_data.address, irmp_data.command, irmp_data.flags, key); - } - } - else - { - printf ("p = %2d, a = 0x%04x, c = 0x%04x, f = 0x%02x\n", - irmp_data.protocol, irmp_data.address, irmp_data.command, irmp_data.flags); - } - } - } + next_tick (); } if (analyze) diff --git a/irmp.exe b/irmp.exe index 808c9e2..b6b3217 100644 Binary files a/irmp.exe and b/irmp.exe differ diff --git a/irmp.h b/irmp.h index c8c709a..21ff7db 100644 --- a/irmp.h +++ b/irmp.h @@ -3,7 +3,7 @@ * * Copyright (c) 2009-2010 Frank Meyer - frank(at)fli4l.de * - * $Id: irmp.h,v 1.41 2010/08/18 12:03:26 fm Exp $ + * $Id: irmp.h,v 1.43 2010/08/31 15:22:24 fm Exp $ * * ATMEGA88 @ 8 MHz * @@ -22,6 +22,21 @@ extern "C" { #endif +/*--------------------------------------------------------------------------------------------------------------------------------------------------- + * timing constants: + *--------------------------------------------------------------------------------------------------------------------------------------------------- + */ +#define IRMP_TIMEOUT_TIME 16500.0e-6 // timeout after 16.5 ms darkness +#define IRMP_TIMEOUT_TIME_MS 16500L // timeout after 16.5 ms darkness + +#if (F_INTERRUPTS * IRMP_TIMEOUT_TIME_MS) / 1000000 >= 254 +typedef uint16_t PAUSE_LEN; +#else +typedef uint8_t PAUSE_LEN; +#endif + +#define IRMP_TIMEOUT_LEN (PAUSE_LEN)(F_INTERRUPTS * IRMP_TIMEOUT_TIME + 0.5) + /*--------------------------------------------------------------------------------------------------------------------------------------------------- * IR protocols *--------------------------------------------------------------------------------------------------------------------------------------------------- @@ -46,6 +61,7 @@ extern "C" #define IRMP_FDC_PROTOCOL 18 // FDC keyboard #define IRMP_RCCAR_PROTOCOL 19 // RC Car #define IRMP_JVC_PROTOCOL 20 // JVC +#define IRMP_RC6A_PROTOCOL 21 // RC6A, e.g. Kathrein, XBOX // some flags of struct IRMP_PARAMETER: #define IRMP_PARAM_FLAG_IS_MANCHESTER 0x01 @@ -322,7 +338,7 @@ extern "C" #define JVC_PULSE_TIME 560.0e-6 // 560 usec pulse #define JVC_1_PAUSE_TIME 1690.0e-6 // 1690 usec pause #define JVC_0_PAUSE_TIME 560.0e-6 // 560 usec pause -#define JVC_FRAME_REPEAT_PAUSE_TIME 25.0e-3 // frame repeat after 25ms +#define JVC_FRAME_REPEAT_PAUSE_TIME 22.0e-3 // frame repeat after 22ms #define JVC_ADDRESS_OFFSET 0 // skip 0 bits #define JVC_ADDRESS_LEN 4 // read 4 address bits #define JVC_COMMAND_OFFSET 4 // skip 4 bits diff --git a/irmpconfig.h b/irmpconfig.h index 2d26848..1a42f89 100644 --- a/irmpconfig.h +++ b/irmpconfig.h @@ -3,7 +3,7 @@ * * Copyright (c) 2010 Frank Meyer - frank(at)fli4l.de * - * $Id: irmpconfig.h,v 1.37 2010/08/18 12:03:26 fm Exp $ + * $Id: irmpconfig.h,v 1.39 2010/08/30 15:45:27 fm Exp $ * * ATMEGA88 @ 8 MHz * @@ -51,7 +51,7 @@ #define IRMP_SUPPORT_DENON_PROTOCOL 1 // DENON >= 10000 ~250 bytes #define IRMP_SUPPORT_JVC_PROTOCOL 1 // JVC >= 10000 ~250 bytes #define IRMP_SUPPORT_RC5_PROTOCOL 1 // RC5 >= 10000 ~250 bytes -#define IRMP_SUPPORT_RC6_PROTOCOL 1 // RC6 >= 10000 ~200 bytes +#define IRMP_SUPPORT_RC6_PROTOCOL 1 // RC6 & RC6A >= 10000 ~200 bytes #define IRMP_SUPPORT_GRUNDIG_PROTOCOL 1 // Grundig >= 10000 ~150 bytes #define IRMP_SUPPORT_NOKIA_PROTOCOL 1 // Nokia >= 10000 ~150 bytes #define IRMP_SUPPORT_NUBERT_PROTOCOL 1 // NUBERT >= 10000 ~50 bytes diff --git a/irsnd.c b/irsnd.c index ee91c6b..6f2e6b1 100644 --- a/irsnd.c +++ b/irsnd.c @@ -3,7 +3,7 @@ * * Copyright (c) 2010 Frank Meyer - frank(at)fli4l.de * - * $Id: irsnd.c,v 1.21 2010/08/18 12:03:26 fm Exp $ + * $Id: irsnd.c,v 1.24 2010/09/02 10:22:26 fm Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,6 +26,9 @@ #ifdef WIN32 // test/debug on windows #include +#include +#include + #define F_CPU 8000000L typedef unsigned char uint8_t; typedef unsigned short uint16_t; @@ -175,6 +178,14 @@ typedef unsigned short uint16_t; #define RCCAR_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RCCAR_0_PAUSE_TIME + 0.5) #define RCCAR_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RCCAR_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! +#define JVC_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * JVC_START_BIT_PULSE_TIME + 0.5) +#define JVC_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * JVC_START_BIT_PAUSE_TIME + 0.5) +#define JVC_REPEAT_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * JVC_REPEAT_START_BIT_PAUSE_TIME + 0.5) +#define JVC_PULSE_LEN (uint8_t)(F_INTERRUPTS * JVC_PULSE_TIME + 0.5) +#define JVC_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * JVC_1_PAUSE_TIME + 0.5) +#define JVC_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * JVC_0_PAUSE_TIME + 0.5) +#define JVC_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * JVC_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! + static volatile uint8_t irsnd_busy; static volatile uint8_t irsnd_protocol; static volatile uint8_t irsnd_buffer[6]; @@ -334,8 +345,25 @@ irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait) } #endif #if IRSND_SUPPORT_NEC_PROTOCOL == 1 - case IRMP_NEC_PROTOCOL: case IRMP_APPLE_PROTOCOL: + { + command = irmp_data_p->command | (irmp_data_p->address << 8); // store address as ID in upper byte of command + address = 0x87EE; // set fixed NEC-lookalike address (customer ID of apple) + + address = bitsrevervse (address, NEC_ADDRESS_LEN); + command = bitsrevervse (command, NEC_COMMAND_LEN); + + irsnd_protocol = IRMP_NEC_PROTOCOL; // APPLE protocol is NEC with id instead of inverted command + + irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA + irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA + irsnd_buffer[2] = (command & 0xFF00) >> 8; // CCCCCCCC + irsnd_buffer[3] = (command & 0x00FF); // CCCCCCCC + + irsnd_busy = TRUE; + break; + } + case IRMP_NEC_PROTOCOL: { address = bitsrevervse (irmp_data_p->address, NEC_ADDRESS_LEN); command = bitsrevervse (irmp_data_p->command, NEC_COMMAND_LEN); @@ -344,12 +372,8 @@ irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait) irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA irsnd_buffer[2] = (command & 0xFF00) >> 8; // CCCCCCCC - if (irsnd_protocol == IRMP_APPLE_PROTOCOL) - { - irsnd_protocol = IRMP_NEC_PROTOCOL; // APPLE protocol is NEC with fix bitmask instead of inverted command - irsnd_buffer[3] = 0x8B; // 10001011 - } - else + irsnd_protocol = IRMP_NEC_PROTOCOL; // APPLE protocol is NEC with fix bitmask instead of inverted command + irsnd_buffer[3] = 0x8B; // 10001011 { irsnd_buffer[3] = ~((command & 0xFF00) >> 8); // cccccccc } @@ -556,6 +580,19 @@ irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait) break; } #endif +#if IRSND_SUPPORT_JVC_PROTOCOL == 1 + case IRMP_JVC_PROTOCOL: + { + address = bitsrevervse (irmp_data_p->address, JVC_ADDRESS_LEN); + command = bitsrevervse (irmp_data_p->command, JVC_COMMAND_LEN); + + irsnd_buffer[0] = ((address & 0x000F) << 4) | (command & 0x0F00) >> 8; // AAAACCCC + irsnd_buffer[1] = (command & 0x00FF); // CCCCCCCC + + irsnd_busy = TRUE; + break; + } +#endif default: { break; @@ -984,6 +1021,30 @@ irsnd_ISR (void) break; } #endif +#if IRSND_SUPPORT_JVC_PROTOCOL == 1 + case IRMP_JVC_PROTOCOL: + { + if (repeat_counter != 0) // skip start bit if repetition frame + { + current_bit = 0; + } + + startbit_pulse_len = JVC_START_BIT_PULSE_LEN; + startbit_pause_len = JVC_START_BIT_PAUSE_LEN; + complete_data_len = JVC_COMPLETE_DATA_LEN; + pulse_1_len = JVC_PULSE_LEN; + pause_1_len = JVC_1_PAUSE_LEN; + pulse_0_len = JVC_PULSE_LEN; + pause_0_len = JVC_0_PAUSE_LEN; + has_stop_bit = JVC_STOP_BIT; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = JVC_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + + break; + } +#endif default: { irsnd_busy = FALSE; @@ -1036,11 +1097,15 @@ irsnd_ISR (void) #if IRSND_SUPPORT_RCCAR_PROTOCOL == 1 case IRMP_RCCAR_PROTOCOL: #endif +#if IRSND_SUPPORT_JVC_PROTOCOL == 1 + case IRMP_JVC_PROTOCOL: +#endif #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1 || IRSND_SUPPORT_NEC_PROTOCOL == 1 || IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1 || IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1 || \ IRSND_SUPPORT_KASEIKYO_PROTOCOL == 1 || IRSND_SUPPORT_RECS80_PROTOCOL == 1 || IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1 || IRSND_SUPPORT_DENON_PROTOCOL == 1 || \ - IRSND_SUPPORT_NUBERT_PROTOCOL == 1 || IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 || IRSND_SUPPORT_FDC_PROTOCOL == 1 || IRSND_SUPPORT_RCCAR_PROTOCOL == 1 + IRSND_SUPPORT_NUBERT_PROTOCOL == 1 || IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 || IRSND_SUPPORT_FDC_PROTOCOL == 1 || IRSND_SUPPORT_RCCAR_PROTOCOL == 1 || \ + IRSND_SUPPORT_JVC_PROTOCOL == 1 { if (pulse_counter == 0) { diff --git a/irsnd.exe b/irsnd.exe index 76481e3..02672d3 100644 Binary files a/irsnd.exe and b/irsnd.exe differ diff --git a/irsndconfig.h b/irsndconfig.h index 5220a4a..33a0c96 100644 --- a/irsndconfig.h +++ b/irsndconfig.h @@ -3,7 +3,7 @@ * * Copyright (c) 2010 Frank Meyer - frank(at)fli4l.de * - * $Id: irsndconfig.h,v 1.10 2010/08/18 12:03:26 fm Exp $ + * $Id: irsndconfig.h,v 1.12 2010/08/31 15:22:24 fm Exp $ * * ATMEGA88 @ 8 MHz * @@ -37,7 +37,8 @@ #define IRSND_SUPPORT_KASEIKYO_PROTOCOL 1 // Kaseikyo >= 10000 uses ~150 bytes #define IRSND_SUPPORT_RC5_PROTOCOL 1 // RC5 >= 10000 uses ~150 bytes #define IRSND_SUPPORT_DENON_PROTOCOL 1 // DENON >= 10000 uses ~200 bytes -#define IRSND_SUPPORT_RC6_PROTOCOL 0 // RC6 NOT SUPPORTED YET! +#define IRSND_SUPPORT_JVC_PROTOCOL 1 // JVC >= 10000 uses ~150 bytes +#define IRSND_SUPPORT_RC6_PROTOCOL 0 // RC6 NOT SUPPORTED YET! DON'T CHANGE! #define IRSND_SUPPORT_NUBERT_PROTOCOL 1 // NUBERT >= 10000 uses ~100 bytes #define IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL 1 // Bang&Olufsen >= 10000 uses ~250 bytes #define IRSND_SUPPORT_GRUNDIG_PROTOCOL 1 // Grundig >= 10000 uses ~300 bytes @@ -47,7 +48,6 @@ #define IRSND_SUPPORT_SIEMENS_PROTOCOL 0 // Siemens, Gigaset >= 15000 uses ~150 bytes #define IRSND_SUPPORT_RECS80_PROTOCOL 0 // RECS80 >= 20000 uses ~100 bytes #define IRSND_SUPPORT_RECS80EXT_PROTOCOL 0 // RECS80EXT >= 20000 uses ~100 bytes -#define IRSND_SUPPORT_JVC_PROTOCOL 0 // JVC NOT SUPPORTED YET! /*--------------------------------------------------------------------------------------------------------------------------------------------------- @@ -82,4 +82,3 @@ #undef IRSND_SUPPORT_RECS80EXT_PROTOCOL #define IRSND_SUPPORT_RECS80EXT_PROTOCOL 0 #endif - diff --git a/main.c b/main.c index cfcb8c9..f28cce9 100644 --- a/main.c +++ b/main.c @@ -3,7 +3,7 @@ * * Copyright (c) 2009-2010 Frank Meyer - frank(at)fli4l.de * - * $Id: main.c,v 1.7 2010/06/22 08:33:21 fm Exp $ + * $Id: main.c,v 1.8 2010/08/30 15:45:27 fm Exp $ * * ATMEGA88 @ 8 MHz * @@ -108,9 +108,7 @@ main (void) #ifdef _OPTIMIZE_SIZE_ #pragma optsize+ #endif - static uint8_t *Proto[]={"SIRCS","NEC","SAMSUNG","MATSUSH","KASEIKYO","RECS80","RC5(x)","DENON","RC6","SAMSG32","APPLE"}; - #define IRMP_APPLE_ADDRESS 0x77E1 - + static uint8_t *Proto[]={"SIRCS","NEC","SAMSUNG","MATSUSH","KASEIKYO","RECS80","RC5(x)","DENON","RC6","SAMSG32","APPLE","RECS80X","NUBERT","B&O","GRUNDIG","NOKIA","SIEMENS","FDC","RCCAR","JVC","RC6A"}; #if IRMP_LOGGING == 0 // USART initialization has to be done here if Logging is off @@ -146,9 +144,7 @@ main (void) // irmp_data.address is the address/manufacturer code of ir sender // irmp_data.command is the command code #if IRMP_LOGGING != 1 - if((irmp_data.protocol == IRMP_NEC_PROTOCOL) && (irmp_data.address == IRMP_APPLE_ADDRESS)) - printf("Code: Apple\n"); - else printf("Code: %s\n",Proto[irmp_data.protocol-1]); + printf("Code: %s\n",Proto[irmp_data.protocol-1]); printf("Address: 0x%.2X\n",irmp_data.address); printf("Command: 0x%.2X\n\n",irmp_data.command); #endif