Conversion between RC5 and IRMan codes
If you use Girder intensively in conjonction with CCF Tools, may be you need to convert RC5 codes (extracted from CCF file) to
IRMan codes (in order to generate Girder configuration file)
IRMAN code format
IRMan codes are defined by a 6 bytes hex string (12 hex digits).
Example :
14E000000000
RC5 format
RC5 codes are completely determined by 2 values named :
- system (between 0 and 31 included)
- command (between 0 and 127 included)
ProntoEdit writes this kind of code as a 6 short values string in hexadecimal format
5000 0000 0000 0001 system command
where system and command values are written as 4 digits hex strings prefilled with 0.
Example : For this RC5 code
5000 0000 0000 0001 001C 0021
- system is 001Ch = 28d
- command is 0021h = 33d
After some research, I discovered conversion formulas between these 2 formats :
RC5 to IRMan format conversion
By chance, RC5 codes are always translated like that : only the first 3 digits are important, the last 9 digits are always 0.
Let a,b,c these first 3 digits, x the system value and y the command value, the conversion formulas written in C code are :
if (y >= 64)
{
x = 31 - x;
y = 127 - y;
}
a = ( x >> 2 ) ^ 5;
b = ( ( y << 4 ) + 4 * ( x & 3 ) ) ^ 5;
c = ( y & 15 ) ^ 5;
Example :
RC5 code = 5000 0000 0000 0001 001C 0021
gives
x = 1Ch = 28d
y = 21h = 33d
then
a = ( 28 >> 4 ) ^ 5 = 7 ^ 5 = 2
b = ( ( 33 >> 4 ) + 4 * ( 28 & 3 ) ) ^ 5 = ( 2 + 4 * 0 ) ^ 5 = 2 ^ 5 = 7
c = ( 33 & 15 ) ^ 5 = 1 ^ 5 = 4
hence
IRMan code = 274000000000
IRMan to RC5 format conversion
The previous formulas need to be reversed, you will notice that for given values a,b,c there will be 2 x,y possible couples.
x = ( ( a ^ 5 ) << 2 ) + ( ( b ^ 5 ) >> 2 );
y = ( ( ( b ^ 5 ) & 3 ) << 4 ) + ( c ^ 5 );
the first solution is
x1 = x;
y1 = y;
the second solution is
x2 = 31 - x;
y2 = 127 - y;
Example :
IRMan code = 274000000000
gives
a = 2 a ^ 5 = 7
b = 7 b ^ 5 = 2
c = 4 c ^ 5 = 1
then
x1 = ( 7 << 2 ) + ( 2 >> 2 ) = 28 + 0 = 28 = 1Ch
y1 = ( ( ( 2 & 3 ) << 4 ) + 1 = ( 2 << 4 ) + 1 = 33 = 21h
x2 = 31 - 28 = 3
y2 = 127 - 33 = 94 = 5Eh
hence
RC5 code 1 = 5000 0000 0000 0001 001C 0021
or
RC5 code 2 = 5000 0000 0000 0001 0003 005E
You can download this zip file (RC5ToIRMan.zip) containing a Excel file with
all these formulas.
As a conclusion, 32 * 128 /2 = 2048 differents IRMan codes can be generated.
But I discovered, there are conflicts with some well known remote controls which use these codes
- Many Philips devices
- Canal+ and Canal Satellite decoder
Obviously there will be no problem if you don't own these types of devices.
Conversion between RC5x and IRMan codes
to be continued...
|