@ -95,7 +95,7 @@ namespace fnecore.EDAC.RS
{
uint offset = 0 U ;
for ( uint i = 0 U ; i < 36 U ; i + + , offset + = 6 )
codeword [ 27 + i ] = bin2Hex ( message , offset ) ;
codeword [ 27 + i ] = FneUtils. BIN2HEX ( message , offset ) ;
ReedSolomonDecoder rs362017 = new ReedSolomonDecoder ( 64 , 47 , 16 , 0x43 ) ;
byte [ ] codewordEC = rs362017 . DecodeEx ( codeword ) ;
@ -103,14 +103,14 @@ namespace fnecore.EDAC.RS
byte [ ] messageOut = new byte [ message . Length ] ;
offset = 0 U ;
for ( uint i = 0 U ; i < 20 U ; i + + , offset + = 6 )
hex2Bin ( codewordEC [ 27 + i ] , ref messageOut , offset ) ;
FneUtils. HEX2BIN ( codewordEC [ 27 + i ] , ref messageOut , offset ) ;
return messageOut ;
}
else if ( eccType = = ErrorCorrectionCodeType . ReedSolomon_241213 )
{
uint offset = 0 U ;
for ( uint i = 0 U ; i < 24 U ; i + + , offset + = 6 )
codeword [ 39 + i ] = bin2Hex ( message , offset ) ;
codeword [ 39 + i ] = FneUtils. BIN2HEX ( message , offset ) ;
ReedSolomonDecoder rs241213 = new ReedSolomonDecoder ( 64 , 51 , 12 , 0x43 ) ;
byte [ ] codewordEC = rs241213 . DecodeEx ( codeword ) ;
@ -118,14 +118,14 @@ namespace fnecore.EDAC.RS
byte [ ] messageOut = new byte [ message . Length ] ;
offset = 0 U ;
for ( uint i = 0 U ; i < 12 U ; i + + , offset + = 6 )
hex2Bin ( codewordEC [ 39 + i ] , ref messageOut , offset ) ;
FneUtils. HEX2BIN ( codewordEC [ 39 + i ] , ref messageOut , offset ) ;
return messageOut ;
}
else if ( eccType = = ErrorCorrectionCodeType . ReedSolomon_24169 )
{
uint offset = 0 U ;
for ( uint i = 0 U ; i < 24 U ; i + + , offset + = 6 )
codeword [ 39 + i ] = bin2Hex ( message , offset ) ;
codeword [ 39 + i ] = FneUtils. BIN2HEX ( message , offset ) ;
ReedSolomonDecoder rs24169 = new ReedSolomonDecoder ( 64 , 55 , 8 , 0x43 ) ;
byte [ ] codewordEC = rs24169 . DecodeEx ( codeword ) ;
@ -133,48 +133,11 @@ namespace fnecore.EDAC.RS
byte [ ] messageOut = new byte [ message . Length ] ;
offset = 0 U ;
for ( uint i = 0 U ; i < 16 U ; i + + , offset + = 6 )
hex2Bin ( codewordEC [ 39 + i ] , ref messageOut , offset ) ;
FneUtils. HEX2BIN ( codewordEC [ 39 + i ] , ref messageOut , offset ) ;
return messageOut ;
}
else
throw new ArgumentException ( $"Invalid '{nameof(eccType)}' argument." , nameof ( eccType ) ) ;
}
/// <summary>
///
/// </summary>
/// <param name="input"></param>
/// <param name="offset"></param>
/// <returns></returns>
internal static byte bin2Hex ( byte [ ] input , uint offset )
{
byte output = 0x00 ;
output | = ( byte ) ( FneUtils . ReadBit ( input , offset + 0 U ) ? 0x20 U : 0x00 U ) ;
output | = ( byte ) ( FneUtils . ReadBit ( input , offset + 1 U ) ? 0x10 U : 0x00 U ) ;
output | = ( byte ) ( FneUtils . ReadBit ( input , offset + 2 U ) ? 0x08 U : 0x00 U ) ;
output | = ( byte ) ( FneUtils . ReadBit ( input , offset + 3 U ) ? 0x04 U : 0x00 U ) ;
output | = ( byte ) ( FneUtils . ReadBit ( input , offset + 4 U ) ? 0x02 U : 0x00 U ) ;
output | = ( byte ) ( FneUtils . ReadBit ( input , offset + 5 U ) ? 0x01 U : 0x00 U ) ;
return output ;
}
/// <summary>
///
/// </summary>
/// <param name="input"></param>
/// <param name="output"></param>
/// <param name="offset"></param>
/// <returns></returns>
internal static void hex2Bin ( byte input , ref byte [ ] output , uint offset )
{
FneUtils . WriteBit ( ref output , offset + 0 U , ( input & 0x20 U ) = = 0x20 U ) ;
FneUtils . WriteBit ( ref output , offset + 1 U , ( input & 0x10 U ) = = 0x10 U ) ;
FneUtils . WriteBit ( ref output , offset + 2 U , ( input & 0x08 U ) = = 0x08 U ) ;
FneUtils . WriteBit ( ref output , offset + 3 U , ( input & 0x04 U ) = = 0x04 U ) ;
FneUtils . WriteBit ( ref output , offset + 4 U , ( input & 0x02 U ) = = 0x02 U ) ;
FneUtils . WriteBit ( ref output , offset + 5 U , ( input & 0x01 U ) = = 0x01 U ) ;
}
} // public static class ReedSolomonAlgorithm
} // namespace fnecore.EDAC.RS