mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-13 19:50:34 +00:00
Updated array driver (added 16 + 16 bits snapshot transport support)
Fix compilation issues with mac osx git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@483 64b25241-fba3-4117-9849-534c7e92360d
This commit is contained in:
parent
28d6b9a122
commit
851f98f879
@ -57,7 +57,7 @@ set(Boost_ADDITIONAL_VERSIONS
|
||||
"1.60.0" "1.60" "1.61.0" "1.61" "1.62.0" "1.62" "1.63.0" "1.63" "1.64.0" "1.64"
|
||||
"1.65.0" "1.65" "1.66.0" "1.66" "1.67.0" "1.67" "1.68.0" "1.68" "1.69.0" "1.69"
|
||||
)
|
||||
find_package(Boost "1.35" COMPONENTS filesystem system)
|
||||
find_package(Boost "1.35" COMPONENTS filesystem system thread)
|
||||
|
||||
if(NOT Boost_FOUND)
|
||||
message(FATAL_ERROR "Boost required to compile dbfcttc")
|
||||
|
@ -78,6 +78,7 @@ namespace gr {
|
||||
d_fifo_full=false;
|
||||
d_last_frame_counter=0;
|
||||
d_num_rx_errors=0;
|
||||
flag_16_bits_sample=true;
|
||||
|
||||
//allocate signal samples buffer
|
||||
//TODO: Check memory pointers
|
||||
@ -279,79 +280,134 @@ namespace gr {
|
||||
}
|
||||
|
||||
void raw_array_impl::pcap_callback(u_char *args, const struct pcap_pkthdr* pkthdr,
|
||||
const u_char* packet)
|
||||
const u_char* packet)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(d_mutex); // hold mutex for duration of this function
|
||||
int numframebyte;
|
||||
short int real,imag;
|
||||
// eth frame parameters
|
||||
int number_of_channels;
|
||||
unsigned short int snapshots_per_frame;
|
||||
boost::mutex::scoped_lock lock(d_mutex); // hold mutex for duration of this function
|
||||
int numframebyte;
|
||||
short int real,imag;
|
||||
// eth frame parameters
|
||||
int number_of_channels;
|
||||
unsigned short int snapshots_per_frame;
|
||||
|
||||
// **** CTTC DBF PACKET DECODER ****
|
||||
if ((packet[12]==0xCD) & (packet[13]==0xBF))
|
||||
{
|
||||
//printf(".");
|
||||
// control parameters
|
||||
number_of_channels=(int)packet[14];
|
||||
//std::cout<<"number_of_channels="<<number_of_channels<<std::endl;
|
||||
snapshots_per_frame=packet[15] << 8 | packet[16];
|
||||
//std::cout<<"snapshots_per_frame="<<snapshots_per_frame<<std::endl;
|
||||
//snapshots reading..
|
||||
for(int i=0;i<snapshots_per_frame;i++)
|
||||
{
|
||||
if (fifo_items <= FIFO_SIZE) {
|
||||
for (int ch=0;ch<number_of_channels;ch++)
|
||||
{
|
||||
real = (signed char)packet[17 + ch*2 + i * 16];
|
||||
imag = (signed char)packet[17 + ch*2 + 1 + i * 16];
|
||||
//todo: invert IQ in FPGA
|
||||
//fifo_buff_ch[ch][fifo_write_ptr] = std::complex<float>(real, imag);
|
||||
fifo_buff_ch[ch][fifo_write_ptr] = std::complex<float>(imag, real); //inverted due to inversion in front-end
|
||||
//std::cout<<"["<<ch<<"]["<<fifo_write_ptr<<"]"<<fifo_buff_ch[ch][fifo_write_ptr]<<std::endl;
|
||||
}
|
||||
fifo_write_ptr++;
|
||||
if (fifo_write_ptr == FIFO_SIZE) fifo_write_ptr = 0;
|
||||
fifo_items++;
|
||||
}else{
|
||||
if (d_fifo_full==false)
|
||||
{
|
||||
printf("FIFO full\n");
|
||||
fflush(stdout);
|
||||
d_fifo_full=true;
|
||||
}
|
||||
}
|
||||
// **** CTTC DBF PACKET DECODER ****
|
||||
if ((packet[12]==0xCD) & (packet[13]==0xBF))
|
||||
{
|
||||
//printf(".");
|
||||
// control parameters
|
||||
number_of_channels=(int)packet[14];
|
||||
//std::cout<<"number_of_channels="<<number_of_channels<<std::endl;
|
||||
snapshots_per_frame=packet[15] << 8 | packet[16];
|
||||
//std::cout<<"snapshots_per_frame="<<snapshots_per_frame<<std::endl;
|
||||
//frame counter check for overflows!
|
||||
numframebyte=(unsigned char)packet[16+snapshots_per_frame*2*number_of_channels+1];
|
||||
//std::cout<<"numframebyte="<<numframebyte<<std::endl;
|
||||
//Overflow detector and mitigator
|
||||
if (d_flag_start_frame == true)
|
||||
{
|
||||
d_last_frame_counter=numframebyte;
|
||||
d_flag_start_frame=false;
|
||||
}else{
|
||||
|
||||
}
|
||||
//frame counter check for overflows!
|
||||
numframebyte=(unsigned char)packet[16+snapshots_per_frame*2*number_of_channels+1];
|
||||
//std::cout<<"numframebyte="<<numframebyte<<std::endl;
|
||||
//test RX
|
||||
if ((d_last_frame_counter-numframebyte)>1)
|
||||
{
|
||||
int missing_frames=abs(d_last_frame_counter-numframebyte);
|
||||
if (missing_frames!=255 )
|
||||
{
|
||||
//fake samples generation to help tracking loops
|
||||
std::complex<float> last_sample[DBFCTTC_NUM_CHANNELS];
|
||||
if (fifo_write_ptr == 0)
|
||||
{
|
||||
for (int ch=0;ch<number_of_channels;ch++)
|
||||
{
|
||||
last_sample[ch]=fifo_buff_ch[ch][FIFO_SIZE];
|
||||
}
|
||||
}else{
|
||||
for (int ch=0;ch<number_of_channels;ch++)
|
||||
{
|
||||
last_sample[ch]=fifo_buff_ch[ch][fifo_write_ptr-1];
|
||||
}
|
||||
}
|
||||
for(int i=0;i<(snapshots_per_frame*missing_frames);i++)
|
||||
{
|
||||
if (fifo_items <= FIFO_SIZE) {
|
||||
for (int ch=0;ch<number_of_channels;ch++)
|
||||
{
|
||||
fifo_buff_ch[ch][fifo_write_ptr] = last_sample[ch];
|
||||
}
|
||||
fifo_write_ptr++;
|
||||
if (fifo_write_ptr == FIFO_SIZE) fifo_write_ptr = 0;
|
||||
fifo_items++;
|
||||
if (d_fifo_full==true)
|
||||
{
|
||||
d_fifo_full=false;
|
||||
}
|
||||
}else{
|
||||
if (d_fifo_full==false)
|
||||
{
|
||||
printf("FIFO full\n");
|
||||
fflush(stdout);
|
||||
d_fifo_full=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
d_num_rx_errors=d_num_rx_errors + 1;
|
||||
printf("RAW Array driver overflow RX %d\n",numframebyte);
|
||||
}
|
||||
}
|
||||
}
|
||||
d_last_frame_counter=numframebyte;
|
||||
|
||||
// **** CTTC DBF PACKET DECODER ***
|
||||
};
|
||||
|
||||
if (d_flag_start_frame == true)
|
||||
{
|
||||
d_last_frame_counter=numframebyte;
|
||||
d_flag_start_frame=false;
|
||||
}else{
|
||||
|
||||
if ((d_last_frame_counter-numframebyte)>1)
|
||||
{
|
||||
if (abs(d_last_frame_counter-numframebyte)!=255 )
|
||||
{
|
||||
d_num_rx_errors=d_num_rx_errors + 1;
|
||||
printf("RAW Array driver overflow RX %d\n",numframebyte);
|
||||
}
|
||||
}
|
||||
}
|
||||
d_last_frame_counter=numframebyte;
|
||||
//snapshots reading..
|
||||
for(int i=0;i<snapshots_per_frame;i++)
|
||||
{
|
||||
if (fifo_items <= FIFO_SIZE) {
|
||||
for (int ch=0;ch<number_of_channels;ch++)
|
||||
{
|
||||
if (flag_16_bits_sample==true)
|
||||
{
|
||||
//(2i+2q)*8channels =32 bytes
|
||||
real=(signed short int)(packet[17 + ch*4 + i * 32] << 8 | packet[17 + ch*4 + 1 + i * 32]);
|
||||
imag=(signed short int)(packet[17 + ch*4 + 2 + i * 32] << 8 | packet[17 + ch*4 + 3 + i * 32]);
|
||||
}else{
|
||||
//(1i+1q)*8channels =16 bytes
|
||||
real = (signed char)packet[17 + ch*2 + i * 16];
|
||||
imag = (signed char)packet[17 + ch*2 + 1 + i * 16];
|
||||
}
|
||||
//todo: invert IQ in FPGA
|
||||
//fifo_buff_ch[ch][fifo_write_ptr] = std::complex<float>(real, imag);
|
||||
fifo_buff_ch[ch][fifo_write_ptr] = std::complex<float>(imag, real); //inverted due to inversion in front-end
|
||||
//std::cout<<"["<<ch<<"]["<<fifo_write_ptr<<"]"<<fifo_buff_ch[ch][fifo_write_ptr]<<std::endl;
|
||||
}
|
||||
fifo_write_ptr++;
|
||||
if (fifo_write_ptr == FIFO_SIZE) fifo_write_ptr = 0;
|
||||
fifo_items++;
|
||||
if (d_fifo_full==true)
|
||||
{
|
||||
d_fifo_full=false;
|
||||
}
|
||||
}else{
|
||||
if (d_fifo_full==false)
|
||||
{
|
||||
printf("FIFO full\n");
|
||||
fflush(stdout);
|
||||
d_fifo_full=true;
|
||||
}
|
||||
}
|
||||
|
||||
};//else{
|
||||
//std::cout<<"RX PKT ID="<<(int)packet[12]<<","<<(int)packet[13]<<std::endl;
|
||||
//}
|
||||
}
|
||||
|
||||
// // *** END CTTC DBF PACKET DECODER ***
|
||||
|
||||
//test RX
|
||||
|
||||
// **** CTTC DBF PACKET DECODER ***
|
||||
//else{
|
||||
//std::cout<<"RX PKT ID="<<(int)packet[12]<<","<<(int)packet[13]<<std::endl;
|
||||
//}
|
||||
|
||||
// // *** END CTTC DBF PACKET DECODER ***
|
||||
}
|
||||
|
||||
|
||||
|
@ -61,12 +61,14 @@ private:
|
||||
int d_inter_frame_delay;
|
||||
int d_sampling_freq;
|
||||
|
||||
bool flag_16_bits_sample;
|
||||
bool d_flag_start_frame;
|
||||
bool d_fifo_full;
|
||||
|
||||
int d_last_frame_counter;
|
||||
int d_num_rx_errors;
|
||||
|
||||
|
||||
boost::thread *d_pcap_thread;
|
||||
/*!
|
||||
* \brief
|
||||
|
Loading…
Reference in New Issue
Block a user