Changeset 5237
- Timestamp:
- 10/04/07 17:23:07 (6 years ago)
- Location:
- experimental/components/Packetizer/trunk/Packetizer-metadata
- Files:
-
- 7 modified
-
Makefile.am (modified) (1 diff)
-
src/PNCodes.cpp (modified) (2 diffs)
-
src/PNCodes.h (modified) (1 diff)
-
src/PacketizerDSP.cpp (modified) (3 diffs)
-
src/PacketizerDSP.h (modified) (1 diff)
-
tests/Depacketizer_testsuite.h (modified) (3 diffs)
-
tests/Packetizer_testsuite.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
experimental/components/Packetizer/trunk/Packetizer-metadata/Makefile.am
r5219 r5237 59 59 cxxtestgen.py --error-printer -o autotest.cpp \ 60 60 tests/binary_sequence_testsuite.h \ 61 tests/Packetizer_testsuite.h 62 #tests/Depacketizer_testsuite.h61 tests/Packetizer_testsuite.h \ 62 tests/Depacketizer_testsuite.h 63 63 64 64 # ---------- documentation --------- -
experimental/components/Packetizer/trunk/Packetizer-metadata/src/PNCodes.cpp
r4104 r5237 24 24 25 25 // P/N packet synchronization code 26 char pn PacketSyncCode[63] = {26 char pn_code_63[63] = { 27 27 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 28 28 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, … … 31 31 32 32 // P/N packet control code 33 char pn ControlCode[7] = {1, 1, 1, 0, 1, 0, 0};33 char pn_code_7[7] = {1, 1, 1, 0, 1, 0, 0}; 34 34 35 35 // P/N inverse packet control code 36 char pn ControlCodeInv[7] = {0, 0, 0, 1, 0, 1, 1};36 char pn_code_7_inv[7] = {0, 0, 0, 1, 0, 1, 1}; 37 37 38 38 -
experimental/components/Packetizer/trunk/Packetizer-metadata/src/PNCodes.h
r4104 r5237 26 26 /// 27 27 /// generator polynomial : g = 103 (octal) 28 extern char pn PacketSyncCode[63];28 extern char pn_code_63[63]; 29 29 30 30 // P/N packet control code 31 extern char pn ControlCode[7];31 extern char pn_code_7[7]; 32 32 33 33 // P/N inverse packet control code 34 extern char pn ControlCodeInv[7];34 extern char pn_code_7_inv[7]; 35 35 -
experimental/components/Packetizer/trunk/Packetizer-metadata/src/PacketizerDSP.cpp
r5236 r5237 30 30 { 31 31 // Initialize P/N synchronization code block 32 pnSyncCode = pn PacketSyncCode;32 pnSyncCode = pn_code_63; 33 33 34 34 // Initialize P/N synchronization shift register … … 37 37 for (unsigned int i=0; i<PN_SYNC_CODE_LENGTH; i++) 38 38 binary_sequence_push(pn_sync_code, pnSyncCode[i] & 0x01); 39 40 // Initialize P/N synchronization code block 41 pnControlCode = pn_code_7; 42 43 // Initialize P/N control code shift register 44 pn_control_code = binary_sequence_create(); 45 binary_sequence_initialize(pn_control_code, PN_CONTROL_CODE_LENGTH); 46 for (unsigned int i=0; i<PN_CONTROL_CODE_LENGTH; i++) 47 binary_sequence_push(pn_control_code, pnControlCode[i] & 0x01); 39 48 40 49 // Initialize control block pointers … … 70 79 { 71 80 for (unsigned int i=NUM_CONTROL_CODES; i>0; i--) { 72 controlBlock[i-1] = ( id & 0x01 ) ? pn ControlCode : pnControlCodeInv;81 controlBlock[i-1] = ( id & 0x01 ) ? pn_code_7 : pn_code_7_inv; 73 82 id >>= 1; 74 83 } -
experimental/components/Packetizer/trunk/Packetizer-metadata/src/PacketizerDSP.h
r5236 r5237 99 99 binary_sequence_t * pn_sync_code; ///< packet synchronization code shift register 100 100 101 char * pnControlCode; ///< packet control code 102 binary_sequence_t * pn_control_code;///< packet control code shift register 103 101 104 char * pnEOMCode; ///< packet EOM code 102 105 binary_sequence_t * pn_eom_code; ///< packet EOM code shift register -
experimental/components/Packetizer/trunk/Packetizer-metadata/tests/Depacketizer_testsuite.h
r5219 r5237 3 3 4 4 #include <cxxtest/TestSuite.h> 5 #include "src/ DepacketizerDSP.h"5 #include "src/PacketizerDSP.h" 6 6 7 7 // … … 12 12 // as a test class 13 13 class Depacketizer_testsuite1 : public CxxTest::TestSuite, 14 public DepacketizerDSP14 public PacketizerDSP 15 15 { 16 16 public: … … 21 21 // Test for positive P/N sync code correlation 22 22 for (unsigned int i=0; i<63; i++) 23 inputBuffer.Push(pnSyncCode[i] );23 binary_sequence_push( pn_sync_buffer, pnSyncCode[i] ); 24 24 25 r = CorrelateSequence( pnSyncCode, 63);25 r = binary_sequence_correlate( pn_sync_buffer, pn_sync_code ); 26 26 TS_ASSERT_EQUALS( r, 63 ); 27 27 28 28 // Test for negative P/N sync code correlation 29 29 for (unsigned int i=0; i<63; i++) 30 inputBuffer.Push(1-pnSyncCode[i] );30 binary_sequence_push( pn_sync_buffer, 1-pnSyncCode[i] ); 31 31 32 r = CorrelateSequence( pnSyncCode, 63);32 r = binary_sequence_correlate( pn_sync_buffer, pn_sync_code ); 33 33 TS_ASSERT_EQUALS( r, -63 ); 34 34 35 35 // Test for positive P/N control code correlation 36 inputBuffer.Release();37 36 for (unsigned int i=0; i<7; i++) 38 inputBuffer.Push( pnCtrlCode[i] );37 binary_sequence_push( pn_control_buffer, pnControlCode[i] ); 39 38 40 r = CorrelateSequence( pnCtrlCode, 7);39 r = binary_sequence_correlate( pn_control_buffer, pn_control_code ); 41 40 TS_ASSERT_EQUALS( r, 7 ); 42 41 43 42 // Test for positive P/N control code correlation 44 inputBuffer.Release();45 43 for (unsigned int i=0; i<7; i++) 46 inputBuffer.Push( 1-pnCtrlCode[i] );44 binary_sequence_push( pn_control_buffer, 1-pnControlCode[i] ); 47 45 48 r = CorrelateSequence( pnCtrlCode, 7);46 r = binary_sequence_correlate( pn_control_buffer, pn_control_code ); 49 47 TS_ASSERT_EQUALS( r, -7 ); 50 48 51 49 } 52 50 53 void test_DecodeControlSequence() {54 controlSequence[0] = -10;55 controlSequence[1] = -10;56 controlSequence[2] = -10;57 controlSequence[3] = -10;58 controlSequence[4] = -10;59 controlSequence[5] = -10;60 controlSequence[6] = -10;61 DecodeControlSequence();62 TS_ASSERT_EQUALS( controlOutput, 0 );63 64 controlSequence[0] = -10;65 controlSequence[1] = -10;66 controlSequence[2] = -10;67 controlSequence[3] = -10;68 controlSequence[4] = -10;69 controlSequence[5] = -10;70 controlSequence[6] = 10;71 DecodeControlSequence();72 TS_ASSERT_EQUALS( controlOutput, 1 );73 74 controlSequence[0] = -10;75 controlSequence[1] = -10;76 controlSequence[2] = -10;77 controlSequence[3] = -10;78 controlSequence[4] = 10;79 controlSequence[5] = 10;80 controlSequence[6] = 10;81 DecodeControlSequence();82 TS_ASSERT_EQUALS( controlOutput, 7 );83 84 controlSequence[0] = 10;85 controlSequence[1] = 10;86 controlSequence[2] = 10;87 controlSequence[3] = 10;88 controlSequence[4] = 10;89 controlSequence[5] = 10;90 controlSequence[6] = 10;91 DecodeControlSequence();92 TS_ASSERT_EQUALS( controlOutput, 127 );93 94 controlSequence[0] = 10;95 controlSequence[1] = -10;96 controlSequence[2] = -10;97 controlSequence[3] = -10;98 controlSequence[4] = -10;99 controlSequence[5] = -10;100 controlSequence[6] = -10;101 DecodeControlSequence();102 TS_ASSERT_EQUALS( controlOutput, 64 );103 104 105 }106 51 107 52 }; -
experimental/components/Packetizer/trunk/Packetizer-metadata/tests/Packetizer_testsuite.h
r5236 r5237 19 19 ConfigureControl(0x00); 20 20 for (unsigned int i=0; i<NUM_CONTROL_CODES; i++) 21 TS_ASSERT_EQUALS( controlBlock[i], pn ControlCodeInv );21 TS_ASSERT_EQUALS( controlBlock[i], pn_code_7_inv ); 22 22 23 23 ConfigureControl(0x0f); 24 24 for (unsigned int i=0; i<NUM_CONTROL_CODES; i++) 25 TS_ASSERT_EQUALS( controlBlock[i], pn ControlCode);25 TS_ASSERT_EQUALS( controlBlock[i], pn_code_7 ); 26 26 27 27 ConfigureControl(0x01); 28 TS_ASSERT_EQUALS( controlBlock[0], pn ControlCodeInv );29 TS_ASSERT_EQUALS( controlBlock[1], pn ControlCodeInv );30 TS_ASSERT_EQUALS( controlBlock[2], pn ControlCodeInv );31 TS_ASSERT_EQUALS( controlBlock[3], pn ControlCode);28 TS_ASSERT_EQUALS( controlBlock[0], pn_code_7_inv ); 29 TS_ASSERT_EQUALS( controlBlock[1], pn_code_7_inv ); 30 TS_ASSERT_EQUALS( controlBlock[2], pn_code_7_inv ); 31 TS_ASSERT_EQUALS( controlBlock[3], pn_code_7 ); 32 32 33 33 } … … 47 47 AssemblePacket( input, 400, output, output_length, PACKET_RAW_400 ); 48 48 49 TS_ASSERT_SAME_DATA( output, pn SyncCode, PN_SYNC_CODE_LENGTH*sizeof(char) );49 TS_ASSERT_SAME_DATA( output, pn_code_63, PN_SYNC_CODE_LENGTH*sizeof(char) ); 50 50 TS_ASSERT_SAME_DATA( output+111, input, 400*sizeof(char) ); 51 51 TS_ASSERT_EQUALS( output_length, 512 );