--- irmp.c	Mon Jan 19 23:26:36 1970
+++ irmp.c	Mon Jan 19 23:26:36 1970
@@ -1736,6 +1691,7 @@
 #endif
 #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
 static uint8_t  xor_check[6];                                                           // check kaseikyo "parity" bits
+static uint8_t  genre2;                                                                 // save genre2 bits here, later copied to MSB in flags
 #endif
 
 /*---------------------------------------------------------------------------------------------------------------------------------------------------
@@ -1802,7 +1758,12 @@
     {
         irmp_tmp_command |= (((uint16_t) (value)) << (irmp_bit - 8));                   // store 4 system bits in upper nibble with LSB first
     }
-
+ 
+	if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL && irmp_bit >= 24 && irmp_bit < 28)
+    {
+        genre2 |= (((uint8_t) (value)) << (irmp_bit - 20));                   // store 4 system bits (genre 2) in upper nibble with LSB first
+    }
+	
     if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL && irmp_bit < KASEIKYO_COMPLETE_DATA_LEN)
     {
         if (value)
@@ -1929,6 +1890,10 @@
                     irmp_tmp_command        = 0;
                     irmp_tmp_address        = 0;
 
+#if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
+                    genre2                  = 0;
+#endif
+
 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1) || IRMP_SUPPORT_NEC42_PROTOCOL == 1
                     irmp_tmp_command2       = 0;
                     irmp_tmp_address2       = 0;
@@ -3336,6 +3301,7 @@
                                 ANALYZE_PRINTF ("error 4: wrong XOR check for data bits: 0x%02x 0x%02x\n", xor, xor_check[5]);
                                 irmp_ir_detected = FALSE;
                             }
+                            irmp_flags |= genre2;	// write the genre2 bits into MSB of the flag byte
                         }
 #endif // IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
 
--- irsnd.c	Mon Jan 19 23:26:36 1970
+++ irsnd.c	Mon Jan 19 23:26:36 1970
@@ -713,16 +713,18 @@
         case IRMP_KASEIKYO_PROTOCOL:
         {
             uint8_t xor;
-
+            uint16_t genre2;
+			
             address = bitsrevervse (irmp_data_p->address, KASEIKYO_ADDRESS_LEN);
             command = bitsrevervse (irmp_data_p->command, KASEIKYO_COMMAND_LEN + 4);
-
+			genre2 = bitsrevervse ((irmp_data_p->flags & ~IRSND_REPETITION_MASK) >> 4, 4) ;
+			
             xor = ((address & 0x000F) ^ ((address & 0x00F0) >> 4) ^ ((address & 0x0F00) >> 8) ^ ((address & 0xF000) >> 12)) & 0x0F;
 
             irsnd_buffer[0] = (address & 0xFF00) >> 8;                                                          // AAAAAAAA
             irsnd_buffer[1] = (address & 0x00FF);                                                               // AAAAAAAA
             irsnd_buffer[2] = xor << 4 | (command & 0x000F);                                                    // XXXXCCCC
-            irsnd_buffer[3] = 0 | (command & 0xF000) >> 12;                                                     // 0000CCCC
+            irsnd_buffer[3] = (genre2 << 4) | (command & 0xF000) >> 12;                                         // ggggCCCC
             irsnd_buffer[4] = (command & 0x0FF0) >> 4;                                                          // CCCCCCCC
 
             xor = irsnd_buffer[2] ^ irsnd_buffer[3] ^ irsnd_buffer[4];
