Changeset 4745

Show
Ignore:
Timestamp:
08/16/07 21:16:32 (6 years ago)
Author:
jgaeddert
Message:

adding test; fixing bits->symbol conversion method

Location:
experimental/components/DigitalModem/trunk/DigitalModem
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • experimental/components/DigitalModem/trunk/DigitalModem/atsrc/DigitalModulator_testsuite.h

    r4744 r4745  
    1515{ 
    1616public: 
    17     void test_01() { 
     17 
     18    void test_ConvertBitsToSymbol_01() { 
     19        char b[2] = {BIT0, BIT1}; 
     20         
     21        unsigned short s; 
     22         
     23        SetModulationScheme( SigProc::BPSK ); 
     24 
     25        for (unsigned int i=0; i<2; i++) { 
     26            ConvertBitsToSymbol(b+i*bitsPerSymbol, s); 
     27            TS_ASSERT_EQUALS( s, i ); 
     28        } 
     29    } 
     30 
     31    void test_ConvertBitsToSymbol_02() { 
     32        char b[8] = {BIT0, BIT0, 
     33                     BIT0, BIT1, 
     34                     BIT1, BIT0, 
     35                     BIT1, BIT1}; 
     36         
     37        unsigned short s; 
     38         
     39        SetModulationScheme( SigProc::QPSK ); 
     40 
     41        for (unsigned int i=0; i<4; i++) { 
     42            ConvertBitsToSymbol(b+i*bitsPerSymbol, s); 
     43            TS_ASSERT_EQUALS( s, i ); 
     44        } 
     45    } 
     46 
     47    void test_ConvertBitsToSymbol_03() { 
     48        char b[24] = {BIT0, BIT0, BIT0, 
     49                      BIT0, BIT0, BIT1, 
     50                      BIT0, BIT1, BIT0, 
     51                      BIT0, BIT1, BIT1, 
     52                      BIT1, BIT0, BIT0, 
     53                      BIT1, BIT0, BIT1, 
     54                      BIT1, BIT1, BIT0, 
     55                      BIT1, BIT1, BIT1}; 
     56         
     57        unsigned short s; 
     58         
     59        SetModulationScheme( SigProc::PSK8 ); 
     60 
     61        for (unsigned int i=0; i<8; i++) { 
     62            ConvertBitsToSymbol(b+i*bitsPerSymbol, s); 
     63            TS_ASSERT_EQUALS( s, i ); 
     64        } 
    1865    } 
    1966}; 
     
    2269//       definition, otherwise the python script does not recognize it 
    2370//       as a test class 
    24 class DigitalModulator_TestDemodulation : public CxxTest::TestSuite, 
     71class DigitalModulator_TestModulation : public CxxTest::TestSuite, 
    2572    public DigitalModem 
    2673{ 
  • experimental/components/DigitalModem/trunk/DigitalModem/src/DigitalModem.cpp

    r4744 r4745  
    205205     
    206206    for (unsigned int i=0; i<bitsPerSymbol; i++) { 
    207         s &= (bitsIn[bitsPerSymbol-i-1] > 0) ? 1 : 0; 
    208         s >>= 1; 
    209     } 
    210 } 
    211  
    212  
     207        s <<= 1; 
     208        s |= (bitsIn[i] > 0) ? 1 : 0; 
     209    } 
     210} 
     211 
     212