mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-15 20:50:33 +00:00
Apply coding style
This commit is contained in:
parent
ef2c2bcf6b
commit
2a9d6975e0
@ -36,19 +36,21 @@
|
|||||||
#include <gnuradio/io_signature.h>
|
#include <gnuradio/io_signature.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
|
||||||
labsat23_source_sptr labsat23_make_source(const char *signal_file_basename, int channel_selector)
|
labsat23_source_sptr labsat23_make_source(const char *signal_file_basename, int channel_selector)
|
||||||
{
|
{
|
||||||
return labsat23_source_sptr(new labsat23_source(signal_file_basename, channel_selector));
|
return labsat23_source_sptr(new labsat23_source(signal_file_basename, channel_selector));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string labsat23_source::generate_filename()
|
std::string labsat23_source::generate_filename()
|
||||||
{
|
{
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
ss << std::setw(4) << std::setfill('0') << d_current_file_number;
|
ss << std::setw(4) << std::setfill('0') << d_current_file_number;
|
||||||
return d_signal_file_basename + "_" + ss.str()+".LS3";
|
return d_signal_file_basename + "_" + ss.str()+".LS3";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
labsat23_source::labsat23_source(const char *signal_file_basename, int channel_selector) : gr::block("labsat23_source",
|
labsat23_source::labsat23_source(const char *signal_file_basename, int channel_selector) : gr::block("labsat23_source",
|
||||||
gr::io_signature::make(0, 0, 0),
|
gr::io_signature::make(0, 0, 0),
|
||||||
gr::io_signature::make(1, 1, sizeof(gr_complex)))
|
gr::io_signature::make(1, 1, sizeof(gr_complex)))
|
||||||
@ -73,12 +75,13 @@ labsat23_source::labsat23_source(const char *signal_file_basename, int channel_s
|
|||||||
if (binary_input_file->is_open())
|
if (binary_input_file->is_open())
|
||||||
{
|
{
|
||||||
std::cout << "Labsat file source is reading samples from " << signal_file << std::endl;
|
std::cout << "Labsat file source is reading samples from " << signal_file << std::endl;
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
std::cout << "Labsat file " << signal_file << " could not be opened!" << std::endl;
|
std::cout << "Labsat file " << signal_file << " could not be opened!" << std::endl;
|
||||||
delete binary_input_file;
|
delete binary_input_file;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -91,11 +94,13 @@ labsat23_source::~labsat23_source()
|
|||||||
delete binary_input_file;
|
delete binary_input_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int labsat23_source::getBit(uint8_t byte, int position)
|
int labsat23_source::getBit(uint8_t byte, int position)
|
||||||
{
|
{
|
||||||
return (byte >> position) & 0x01;
|
return (byte >> position) & 0x01;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void labsat23_source::decode_samples_one_channel(int16_t input_short, gr_complex* out, int type)
|
void labsat23_source::decode_samples_one_channel(int16_t input_short, gr_complex* out, int type)
|
||||||
{
|
{
|
||||||
std::bitset<16> bs(input_short);
|
std::bitset<16> bs(input_short);
|
||||||
@ -127,7 +132,8 @@ void labsat23_source::decode_samples_one_channel(int16_t input_short, gr_complex
|
|||||||
out[i] += gr_complex(-2,0);
|
out[i] += gr_complex(-2,0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else
|
||||||
|
{
|
||||||
if (bs[13-4*i]) //01
|
if (bs[13-4*i]) //01
|
||||||
{
|
{
|
||||||
out[i] += gr_complex(1,0);
|
out[i] += gr_complex(1,0);
|
||||||
@ -146,7 +152,8 @@ void labsat23_source::decode_samples_one_channel(int16_t input_short, gr_complex
|
|||||||
out[i] += gr_complex(0,-2);
|
out[i] += gr_complex(0,-2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else
|
||||||
|
{
|
||||||
if (bs[12-4*i]) //01
|
if (bs[12-4*i]) //01
|
||||||
{
|
{
|
||||||
out[i] += gr_complex(0,1);
|
out[i] += gr_complex(0,1);
|
||||||
@ -158,17 +165,16 @@ void labsat23_source::decode_samples_one_channel(int16_t input_short, gr_complex
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int labsat23_source::general_work(int noutput_items,
|
int labsat23_source::general_work(int noutput_items,
|
||||||
__attribute__((unused)) gr_vector_int &ninput_items,
|
__attribute__((unused)) gr_vector_int &ninput_items,
|
||||||
__attribute__((unused)) gr_vector_const_void_star &input_items,
|
__attribute__((unused)) gr_vector_const_void_star &input_items,
|
||||||
gr_vector_void_star &output_items)
|
gr_vector_void_star &output_items)
|
||||||
{
|
{
|
||||||
|
|
||||||
gr_complex *out = reinterpret_cast<gr_complex *>(output_items[0]);
|
gr_complex *out = reinterpret_cast<gr_complex *>(output_items[0]);
|
||||||
|
|
||||||
if (d_header_parsed == false)
|
if (d_header_parsed == false)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (binary_input_file->eof() == false)
|
if (binary_input_file->eof() == false)
|
||||||
{
|
{
|
||||||
char memblock[1024];
|
char memblock[1024];
|
||||||
@ -190,7 +196,6 @@ int labsat23_source::general_work(int noutput_items,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// check Labsat version
|
// check Labsat version
|
||||||
if (memblock[byte_counter] == 0x4C and memblock[byte_counter+1] == 0x53 and memblock[byte_counter+2] == 0x32)
|
if (memblock[byte_counter] == 0x4C and memblock[byte_counter+1] == 0x53 and memblock[byte_counter+2] == 0x32)
|
||||||
{
|
{
|
||||||
@ -210,10 +215,9 @@ int labsat23_source::general_work(int noutput_items,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
byte_counter += 3;
|
byte_counter += 3;
|
||||||
|
|
||||||
int sub_version=(int)memblock[byte_counter];
|
int sub_version = static_cast<int>(memblock[byte_counter]);
|
||||||
|
|
||||||
std::cout << "Labsat file sub version " << sub_version << std::endl;
|
std::cout << "Labsat file sub version " << sub_version << std::endl;
|
||||||
|
|
||||||
@ -227,7 +231,7 @@ int labsat23_source::general_work(int noutput_items,
|
|||||||
|
|
||||||
// read first section
|
// read first section
|
||||||
// section ID (little-endian)
|
// section ID (little-endian)
|
||||||
uint8_t section_id=(int)memblock[byte_counter]+(int)memblock[byte_counter+1]*256;
|
uint8_t section_id = static_cast<int>(memblock[byte_counter]) + static_cast<int>(memblock[byte_counter+1]) * 256;
|
||||||
//std::cout << "Section ID: " << (int)section_id << std::endl;
|
//std::cout << "Section ID: " << (int)section_id << std::endl;
|
||||||
byte_counter += 2;
|
byte_counter += 2;
|
||||||
|
|
||||||
@ -238,7 +242,7 @@ int labsat23_source::general_work(int noutput_items,
|
|||||||
byte_counter += 4;
|
byte_counter += 4;
|
||||||
if (section_id == 2)
|
if (section_id == 2)
|
||||||
{
|
{
|
||||||
d_ref_clock=(uint8_t)memblock[byte_counter];
|
d_ref_clock = static_cast<uint8_t>(memblock[byte_counter]);
|
||||||
switch(d_ref_clock)
|
switch(d_ref_clock)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
@ -254,10 +258,10 @@ int labsat23_source::general_work(int noutput_items,
|
|||||||
std::cout << "Labsat reference clock: external 16.386 MHz" << std::endl;
|
std::cout << "Labsat reference clock: external 16.386 MHz" << std::endl;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
std::cout<<"Labsat Unknown reference clock ID "<<(int)d_ref_clock<<std::endl;
|
std::cout << "Labsat Unknown reference clock ID " << static_cast<int>(d_ref_clock) << std::endl;
|
||||||
}
|
}
|
||||||
byte_counter++;
|
byte_counter++;
|
||||||
d_bits_per_sample=(uint8_t)memblock[byte_counter];
|
d_bits_per_sample = static_cast<uint8_t>(memblock[byte_counter]);
|
||||||
switch(d_bits_per_sample)
|
switch(d_bits_per_sample)
|
||||||
{
|
{
|
||||||
case 2:
|
case 2:
|
||||||
@ -267,12 +271,12 @@ int labsat23_source::general_work(int noutput_items,
|
|||||||
std::cout << "Labsat is using 4 bits per sample" << std::endl;
|
std::cout << "Labsat is using 4 bits per sample" << std::endl;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
std::cout<<"Labsat Unknown bits per sample ID "<<(int)d_bits_per_sample<<std::endl;
|
std::cout << "Labsat Unknown bits per sample ID " << static_cast<int>(d_bits_per_sample) << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte_counter++;
|
byte_counter++;
|
||||||
d_channel_selector=(uint8_t)memblock[byte_counter];
|
d_channel_selector = static_cast<uint8_t>(memblock[byte_counter]);
|
||||||
switch(d_channel_selector)
|
switch(d_channel_selector)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
@ -291,7 +295,7 @@ int labsat23_source::general_work(int noutput_items,
|
|||||||
std::cout << "Available channels: Channel B, 2 bit quantisation" << std::endl;
|
std::cout << "Available channels: Channel B, 2 bit quantisation" << std::endl;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
std::cout<<"Unknown channel selection ID "<<(int)d_channel_selector<<std::endl;
|
std::cout << "Unknown channel selection ID " << static_cast<int>(d_channel_selector) << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,7 +313,7 @@ int labsat23_source::general_work(int noutput_items,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
byte_counter++;
|
byte_counter++;
|
||||||
uint8_t quantization=(uint8_t)memblock[byte_counter];
|
uint8_t quantization = static_cast<uint8_t>(memblock[byte_counter]);
|
||||||
switch(quantization)
|
switch(quantization)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
@ -319,10 +323,10 @@ int labsat23_source::general_work(int noutput_items,
|
|||||||
std::cout << "2 bit per sample" << std::endl;
|
std::cout << "2 bit per sample" << std::endl;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
std::cout<<"Unknown quantization ID "<<(int)quantization<<std::endl;
|
std::cout << "Unknown quantization ID " << static_cast<int>(quantization) << std::endl;
|
||||||
}
|
}
|
||||||
byte_counter++;
|
byte_counter++;
|
||||||
uint8_t channel_a_constellation=(uint8_t)memblock[byte_counter];
|
uint8_t channel_a_constellation = static_cast<uint8_t>(memblock[byte_counter]);
|
||||||
switch(channel_a_constellation)
|
switch(channel_a_constellation)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
@ -335,10 +339,10 @@ int labsat23_source::general_work(int noutput_items,
|
|||||||
std::cout << "Labsat Channel A is BDS" << std::endl;
|
std::cout << "Labsat Channel A is BDS" << std::endl;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
std::cout<<"Unknown channel A constellation ID "<<(int)channel_a_constellation<<std::endl;
|
std::cout << "Unknown channel A constellation ID " << static_cast<int>(channel_a_constellation) << std::endl;
|
||||||
}
|
}
|
||||||
byte_counter++;
|
byte_counter++;
|
||||||
uint8_t channel_b_constellation=(uint8_t)memblock[byte_counter];
|
uint8_t channel_b_constellation = static_cast<uint8_t>(memblock[byte_counter]);
|
||||||
switch(channel_b_constellation)
|
switch(channel_b_constellation)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
@ -351,7 +355,7 @@ int labsat23_source::general_work(int noutput_items,
|
|||||||
std::cout << "Labsat Channel B is BDS" << std::endl;
|
std::cout << "Labsat Channel B is BDS" << std::endl;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
std::cout<<"Unknown channel B constellation ID "<<(int)channel_b_constellation<<std::endl;
|
std::cout << "Unknown channel B constellation ID " << static_cast<int>(channel_b_constellation) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
//end of header
|
//end of header
|
||||||
@ -360,16 +364,21 @@ int labsat23_source::general_work(int noutput_items,
|
|||||||
binary_input_file->clear();
|
binary_input_file->clear();
|
||||||
binary_input_file->seekg(header_bytes, binary_input_file->beg);
|
binary_input_file->seekg(header_bytes, binary_input_file->beg);
|
||||||
return 0;
|
return 0;
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
std::cout << "Labsat file header error: section 2 is not available." << std::endl;
|
std::cout << "Labsat file header error: section 2 is not available." << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}else{
|
else
|
||||||
|
{
|
||||||
std::cout << "Labsat file read error: file is empty." << std::endl;
|
std::cout << "Labsat file read error: file is empty." << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
//ready to start reading samples
|
//ready to start reading samples
|
||||||
switch(d_bits_per_sample)
|
switch(d_bits_per_sample)
|
||||||
{
|
{
|
||||||
@ -386,7 +395,7 @@ int labsat23_source::general_work(int noutput_items,
|
|||||||
if (n_int16_to_read > 0)
|
if (n_int16_to_read > 0)
|
||||||
{
|
{
|
||||||
int16_t memblock[n_int16_to_read];
|
int16_t memblock[n_int16_to_read];
|
||||||
binary_input_file->read((char*)memblock,n_int16_to_read*2);
|
binary_input_file->read(reinterpret_cast<char*>(memblock), n_int16_to_read * 2);
|
||||||
n_int16_to_read = binary_input_file->gcount() / 2; //from bytes to int16
|
n_int16_to_read = binary_input_file->gcount() / 2; //from bytes to int16
|
||||||
if (n_int16_to_read > 0)
|
if (n_int16_to_read > 0)
|
||||||
{
|
{
|
||||||
@ -397,7 +406,9 @@ int labsat23_source::general_work(int noutput_items,
|
|||||||
output_pointer += 8;
|
output_pointer += 8;
|
||||||
}
|
}
|
||||||
return output_pointer;
|
return output_pointer;
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
//trigger the read of the next file in the sequence
|
//trigger the read of the next file in the sequence
|
||||||
std::cout << "End of current file, reading the next Labsat file in sequence: " << generate_filename() << std::endl;
|
std::cout << "End of current file, reading the next Labsat file in sequence: " << generate_filename() << std::endl;
|
||||||
|
|
||||||
@ -407,12 +418,16 @@ int labsat23_source::general_work(int noutput_items,
|
|||||||
if (binary_input_file->is_open())
|
if (binary_input_file->is_open())
|
||||||
{
|
{
|
||||||
std::cout << "Labsat file source is reading samples from " << generate_filename() << std::endl;
|
std::cout << "Labsat file source is reading samples from " << generate_filename() << std::endl;
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
std::cout << "Last file reached, LabSat source stop" << std::endl;
|
std::cout << "Last file reached, LabSat source stop" << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -431,7 +446,7 @@ int labsat23_source::general_work(int noutput_items,
|
|||||||
if (n_int16_to_read > 0)
|
if (n_int16_to_read > 0)
|
||||||
{
|
{
|
||||||
int16_t memblock[n_int16_to_read];
|
int16_t memblock[n_int16_to_read];
|
||||||
binary_input_file->read((char*)memblock,n_int16_to_read*2);
|
binary_input_file->read(reinterpret_cast<char*>(memblock), n_int16_to_read * 2);
|
||||||
n_int16_to_read = binary_input_file->gcount() / 2; //from bytes to int16
|
n_int16_to_read = binary_input_file->gcount() / 2; //from bytes to int16
|
||||||
if (n_int16_to_read > 0)
|
if (n_int16_to_read > 0)
|
||||||
{
|
{
|
||||||
@ -442,7 +457,9 @@ int labsat23_source::general_work(int noutput_items,
|
|||||||
output_pointer += 4;
|
output_pointer += 4;
|
||||||
}
|
}
|
||||||
return output_pointer;
|
return output_pointer;
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
//trigger the read of the next file in the sequence
|
//trigger the read of the next file in the sequence
|
||||||
std::cout << "End of current file, reading the next Labsat file in sequence: " << generate_filename() << std::endl;
|
std::cout << "End of current file, reading the next Labsat file in sequence: " << generate_filename() << std::endl;
|
||||||
|
|
||||||
@ -452,12 +469,16 @@ int labsat23_source::general_work(int noutput_items,
|
|||||||
if (binary_input_file->is_open())
|
if (binary_input_file->is_open())
|
||||||
{
|
{
|
||||||
std::cout << "Labsat file source is reading samples from " << generate_filename() << std::endl;
|
std::cout << "Labsat file source is reading samples from " << generate_filename() << std::endl;
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
std::cout << "Last file reached, LabSat source stop" << std::endl;
|
std::cout << "Last file reached, LabSat source stop" << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user