From: baobrien Date: Sun, 10 Apr 2016 05:29:40 +0000 (+0000) Subject: Deframer unit test written X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=9ee5cea4620448c9128f64cf30437453d02612ea;p=freetel-svn-tracking.git Deframer unit test written git-svn-id: https://svn.code.sf.net/p/freetel/code@2778 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2-dev/unittest/CMakeLists.txt b/codec2-dev/unittest/CMakeLists.txt index 732ac7d8..e365cd7b 100644 --- a/codec2-dev/unittest/CMakeLists.txt +++ b/codec2-dev/unittest/CMakeLists.txt @@ -69,6 +69,9 @@ target_link_libraries(tfsk m) add_executable(tfmfsk tfmfsk.c ../src/octave.c ../src/modem_probe.c) target_link_libraries(tfmfsk m) +add_executable(tdeframer tdeframer.c) +target_link_libraries(tdeframer m codec2) + #add_executable(t48_8 t48_8.c ../src/fdmdv.c ../src/kiss_fft.c) #target_link_libraries(t48_8 codec2) diff --git a/codec2-dev/unittest/tdeframer.c b/codec2-dev/unittest/tdeframer.c new file mode 100644 index 00000000..5725eae2 --- /dev/null +++ b/codec2-dev/unittest/tdeframer.c @@ -0,0 +1,120 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: tdeframer.c + AUTHOR......: Brady O'Brien + DATE CREATED: 8 April 2016 + + C unit test for the VHF framer/deframer used by modes 2400A and 2400B. + The deframer should sync up within one frame at a BER of 10e-3 +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2016 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. This program is + distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program; if not, see . +*/ + +/* BER of test */ +#define TESTBER 0.01 + +/* Frame count */ +#define FRCNT 1500 + +/* Random bits leading frame */ +#define LRCNT 142 + +#include +#include +#include +#include +#include + +/* The main loop of the test driver */ +int main(int argc,char *argv[]){ + uint8_t * bit_buffer; + uint8_t c2_buffer[7] = {0,0,0,0,0,0,0}; + struct freedv_vhf_deframer * fvd; + int i,p,k; + int bitbufferlen = (LRCNT+96*FRCNT); + + srand(1); + golay23_init(); + + /* Set up the deframer */ + fvd = fvhff_create_deframer(FREEDV_VHF_FRAME_A,1); + + /* Allocate bit buffer */ + bit_buffer = (uint8_t *) malloc(sizeof(uint8_t)*bitbufferlen); + p = 0; + + /* Fill out front of buffer */ + for(i=0; i>8 )&0xFF; + c2_buffer[2] = (k>>16)&0x7F; + /* Frame the bits */ + fvhff_frame_bits(FREEDV_VHF_FRAME_A, &bit_buffer[p+(i*96)], c2_buffer,NULL,NULL); + } + + /* Flip bits */ + for(i=0; i>11; + printf("Got frame %d\n",p); + total_extract++; + if(first_extract==0) + first_extract=p; + } + } + + float measured_ber = (float)err_count/(float)(23*total_extract); + + printf("First extracted frame %d\n",first_extract); + printf("Extracted %d frames of %d, %f hit rate\n",total_extract,FRCNT,((float)total_extract/(float)FRCNT)); + printf("Bit error rate %f measured\n",measured_ber); + /* Check test condition */ + if(first_extract<2){ + printf("Test passed at test BER of %f!\n",TESTBER); + exit(0); + }else{ + printf("** Test failed at test BER of %f!\n",TESTBER); + exit(1); + } +}