Included error correction on P25 TDULC.

Added a new "heuristics" module for P25 that improves the estimation of the symbol (dibit) that corresponds to a given analog signal value.
Added a BER (bit error reate) estimation for P25.
This commit is contained in:
EdFuentetaja
2014-05-11 02:23:24 +08:00
parent b45e563e54
commit 9d0fe07931
30 changed files with 2976 additions and 828 deletions

View File

@@ -30,7 +30,7 @@ protected:
std::cout << std::endl;
}
static void check_hamming(int v, int expected_v, int expected_errors)
static void check_decode(int v, int expected_v, int expected_errors)
{
Hamming_10_6_3 hamming;
Hamming_10_6_3_TableImpl hamming_table;
@@ -43,17 +43,17 @@ protected:
//print_debug(v, output_1, error_count_1);
if (expected_errors != -1) {
EXPECT_THAT(expected_errors, error_count_1);
EXPECT_EQ(expected_errors, error_count_1);
}
EXPECT_THAT(error_count_1, error_count_2);
EXPECT_EQ(error_count_1, error_count_2);
if (expected_v != -1) {
EXPECT_THAT(expected_v, output_1);
EXPECT_EQ(expected_v, output_1);
}
EXPECT_THAT(output_1, output_2);
EXPECT_EQ(output_1, output_2);
}
static void check_hamming(Hamming_Inteface* hamming, char* hex, char* parity, int expected_errors, char* expected)
static void check_decode(Hamming_Inteface* hamming, char* hex, char* parity, int expected_errors, char* expected)
{
int value = Hamming_10_6_3_TableImpl::convert_hex_parity_to_int(hex, parity);
int error_count = hamming->decode(hex, parity);
@@ -61,12 +61,34 @@ protected:
//print_debug(value, fixed, error_count);
EXPECT_THAT(expected_errors, error_count);
EXPECT_EQ(expected_errors, error_count);
for (unsigned int i=0; i<6; i++) {
EXPECT_THAT(expected[i], hex[i]);
EXPECT_EQ(expected[i], hex[i]);
}
}
static void check_encode(Hamming_Inteface* hamming, int input)
{
int parity = hamming->encode(input);
// Check it
EXPECT_LT(parity, 16);
int v = (input << 4) | parity;
int output;
int error_count = hamming->decode(v, &output);
EXPECT_EQ(error_count, 0);
EXPECT_EQ(output, input);
}
static void check_encode(Hamming_Inteface* hamming, char* hex)
{
char parity[4];
hamming->encode(hex, parity);
// Check it
int error_count = hamming->decode(hex, parity);
EXPECT_EQ(error_count, 0);
}
};
TEST_F(HammingTest, Test1)
@@ -74,7 +96,7 @@ TEST_F(HammingTest, Test1)
// OK
std::bitset<10> value(std::string("1010100110"));
std::bitset< 6> expected(std::string("101010"));
check_hamming((int)value.to_ulong(), (int)expected.to_ulong(), 0);
check_decode((int)value.to_ulong(), (int)expected.to_ulong(), 0);
}
TEST_F(HammingTest, Test2)
@@ -82,7 +104,7 @@ TEST_F(HammingTest, Test2)
// Error on parity bit 0 (9 is the left-most and 0 is the right-most)
std::bitset<10> value(std::string("1010100111"));
std::bitset< 6> expected(std::string("101010"));
check_hamming((int)value.to_ulong(), (int)expected.to_ulong(), 1);
check_decode((int)value.to_ulong(), (int)expected.to_ulong(), 1);
}
TEST_F(HammingTest, Test3)
@@ -90,7 +112,7 @@ TEST_F(HammingTest, Test3)
// Error on parity bit 1 (9 is the left-most and 0 is the right-most)
std::bitset<10> value(std::string("1010100100"));
std::bitset< 6> expected(std::string("101010"));
check_hamming((int)value.to_ulong(), (int)expected.to_ulong(), 1);
check_decode((int)value.to_ulong(), (int)expected.to_ulong(), 1);
}
TEST_F(HammingTest, Test4)
@@ -98,7 +120,7 @@ TEST_F(HammingTest, Test4)
// Error on parity bit 2 (9 is the left-most and 0 is the right-most)
std::bitset<10> value(std::string("1010100010"));
std::bitset< 6> expected(std::string("101010"));
check_hamming((int)value.to_ulong(), (int)expected.to_ulong(), 1);
check_decode((int)value.to_ulong(), (int)expected.to_ulong(), 1);
}
TEST_F(HammingTest, Test5)
@@ -106,7 +128,7 @@ TEST_F(HammingTest, Test5)
// Error on parity bit 3 (9 is the left-most and 0 is the right-most)
std::bitset<10> value(std::string("1010101110"));
std::bitset< 6> expected(std::string("101010"));
check_hamming((int)value.to_ulong(), (int)expected.to_ulong(), 1);
check_decode((int)value.to_ulong(), (int)expected.to_ulong(), 1);
}
TEST_F(HammingTest, Test6)
@@ -114,7 +136,7 @@ TEST_F(HammingTest, Test6)
// Error on bit 4 (9 is the left-most and 0 is the right-most)
std::bitset<10> value(std::string("1010110110"));
std::bitset< 6> expected(std::string("101010"));
check_hamming((int)value.to_ulong(), (int)expected.to_ulong(), 1);
check_decode((int)value.to_ulong(), (int)expected.to_ulong(), 1);
}
TEST_F(HammingTest, Test7)
@@ -122,7 +144,7 @@ TEST_F(HammingTest, Test7)
// Error on bit 5 (9 is the left-most and 0 is the right-most)
std::bitset<10> value(std::string("1010000110"));
std::bitset< 6> expected(std::string("101010"));
check_hamming((int)value.to_ulong(), (int)expected.to_ulong(), 1);
check_decode((int)value.to_ulong(), (int)expected.to_ulong(), 1);
}
TEST_F(HammingTest, Test8)
@@ -130,7 +152,7 @@ TEST_F(HammingTest, Test8)
// Error on bit 6 (9 is the left-most and 0 is the right-most)
std::bitset<10> value(std::string("1011100110"));
std::bitset< 6> expected(std::string("101010"));
check_hamming((int)value.to_ulong(), (int)expected.to_ulong(), 1);
check_decode((int)value.to_ulong(), (int)expected.to_ulong(), 1);
}
TEST_F(HammingTest, Test9)
@@ -138,7 +160,7 @@ TEST_F(HammingTest, Test9)
// Error on bit 7 (9 is the left-most and 0 is the right-most)
std::bitset<10> value(std::string("1000100110"));
std::bitset< 6> expected(std::string("101010"));
check_hamming((int)value.to_ulong(), (int)expected.to_ulong(), 1);
check_decode((int)value.to_ulong(), (int)expected.to_ulong(), 1);
}
TEST_F(HammingTest, Test10)
@@ -146,7 +168,7 @@ TEST_F(HammingTest, Test10)
// Error on bit 8 (9 is the left-most and 0 is the right-most)
std::bitset<10> value(std::string("1110100110"));
std::bitset< 6> expected(std::string("101010"));
check_hamming((int)value.to_ulong(), (int)expected.to_ulong(), 1);
check_decode((int)value.to_ulong(), (int)expected.to_ulong(), 1);
}
TEST_F(HammingTest, Test11)
@@ -154,7 +176,7 @@ TEST_F(HammingTest, Test11)
// Error on bit 9 (9 is the left-most and 0 is the right-most)
std::bitset<10> value(std::string("0010100110"));
std::bitset< 6> expected(std::string("101010"));
check_hamming((int)value.to_ulong(), (int)expected.to_ulong(), 1);
check_decode((int)value.to_ulong(), (int)expected.to_ulong(), 1);
}
TEST_F(HammingTest, Test12)
@@ -162,7 +184,7 @@ TEST_F(HammingTest, Test12)
// Two errors
std::bitset<10> value(std::string("0010100111"));
std::bitset< 6> expected(std::string("001010"));
check_hamming((int)value.to_ulong(), (int)expected.to_ulong(), 2);
check_decode((int)value.to_ulong(), (int)expected.to_ulong(), 2);
}
TEST_F(HammingTest, Test13)
@@ -170,7 +192,7 @@ TEST_F(HammingTest, Test13)
// Two errors, in this case they go undetected, thinks it's a parity error
std::bitset<10> value(std::string("1011000110"));
std::bitset< 6> expected(std::string("101100"));
check_hamming((int)value.to_ulong(), (int)expected.to_ulong(), 1);
check_decode((int)value.to_ulong(), (int)expected.to_ulong(), 1);
}
TEST_F(HammingTest, Test14)
@@ -178,14 +200,14 @@ TEST_F(HammingTest, Test14)
// OK
std::bitset<10> value(std::string("0001000111"));
std::bitset< 6> expected(std::string("000100"));
check_hamming((int)value.to_ulong(), (int)expected.to_ulong(), 0);
check_decode((int)value.to_ulong(), (int)expected.to_ulong(), 0);
}
TEST_F(HammingTest, TestEveryValue)
{
// Test every posible value
for (int v=0; v<1023; v++) {
check_hamming(v, -1, -1);
check_decode(v, -1, -1);
}
}
@@ -196,10 +218,10 @@ TEST_F(HammingTest, Test_hex_parity_interface_no_errors)
char parity[4] = {1,0,1,1};
Hamming_10_6_3 hamming;
check_hamming(&hamming, hex, parity, 0, fixed);
check_decode(&hamming, hex, parity, 0, fixed);
Hamming_10_6_3_TableImpl hamming_table;
check_hamming(&hamming_table, hex, parity, 0, fixed);
check_decode(&hamming_table, hex, parity, 0, fixed);
}
TEST_F(HammingTest, Test_hex_parity_interface_one_error_1)
@@ -210,11 +232,11 @@ TEST_F(HammingTest, Test_hex_parity_interface_one_error_1)
char parity[4] = {1,0,1,1};
Hamming_10_6_3 hamming;
check_hamming(&hamming, hex_1, parity, 1, fixed);
check_decode(&hamming, hex_1, parity, 1, fixed);
// hex is modified in place
Hamming_10_6_3_TableImpl hamming_table;
check_hamming(&hamming_table, hex_2, parity, 1, fixed);
check_decode(&hamming_table, hex_2, parity, 1, fixed);
// hex is modified in place
}
@@ -226,11 +248,11 @@ TEST_F(HammingTest, Test_hex_parity_interface_one_error_2)
char parity[4] = {0,0,0,0};
Hamming_10_6_3 hamming;
check_hamming(&hamming, hex_1, parity, 1, fixed);
check_decode(&hamming, hex_1, parity, 1, fixed);
// hex is modified in place
Hamming_10_6_3_TableImpl hamming_table;
check_hamming(&hamming_table, hex_2, parity, 1, fixed);
check_decode(&hamming_table, hex_2, parity, 1, fixed);
// hex is modified in place
}
@@ -242,10 +264,41 @@ TEST_F(HammingTest, Test_hex_parity_interface_one_error_3)
char parity[4] = {0,0,0,0};
Hamming_10_6_3 hamming;
check_hamming(&hamming, hex_1, parity, 1, fixed);
check_decode(&hamming, hex_1, parity, 1, fixed);
// hex is modified in place
Hamming_10_6_3_TableImpl hamming_table;
check_hamming(&hamming_table, hex_2, parity, 1, fixed);
check_decode(&hamming_table, hex_2, parity, 1, fixed);
// hex is modified in place
}
TEST_F(HammingTest, Test_encoding_1)
{
Hamming_10_6_3 hamming;
Hamming_10_6_3_TableImpl hamming_table;
for (int i=0; i<64; i++) {
check_encode(&hamming, i);
check_encode(&hamming_table, i);
}
}
TEST_F(HammingTest, Test_encoding_char)
{
Hamming_10_6_3 hamming;
Hamming_10_6_3_TableImpl hamming_table;
char hex[6];
for (int i=0; i<64; i++) {
// Convert i to char array
int input = i;
for (int j=5; j>=0; j--) {
hex[j] = input & 1;
input >>= 1;
}
check_encode(&hamming, hex);
check_encode(&hamming_table, hex);
}
}