mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-11-10 04:03:02 +00:00
Replace std::endl by \n character. There is no need to always flush the stream.
This commit is contained in:
@@ -123,7 +123,7 @@ Gr_Complex_Ip_Packet_Source::Gr_Complex_Ip_Packet_Source(std::string src_device,
|
||||
std::cout << "Unknown wire sample type\n";
|
||||
exit(0);
|
||||
}
|
||||
std::cout << "d_wire_sample_type:" << d_wire_sample_type << std::endl;
|
||||
std::cout << "d_wire_sample_type:" << d_wire_sample_type << '\n';
|
||||
d_src_device = std::move(src_device);
|
||||
d_udp_port = udp_port;
|
||||
d_udp_payload_size = udp_packet_size;
|
||||
@@ -186,15 +186,15 @@ bool Gr_Complex_Ip_Packet_Source::open()
|
||||
descr = pcap_open_live(d_src_device.c_str(), 1500, 1, 1000, errbuf.data());
|
||||
if (descr == nullptr)
|
||||
{
|
||||
std::cout << "Error opening Ethernet device " << d_src_device << std::endl;
|
||||
std::cout << "Fatal Error in pcap_open_live(): " << std::string(errbuf.data()) << std::endl;
|
||||
std::cout << "Error opening Ethernet device " << d_src_device << '\n';
|
||||
std::cout << "Fatal Error in pcap_open_live(): " << std::string(errbuf.data()) << '\n';
|
||||
return false;
|
||||
}
|
||||
// bind UDP port to avoid automatic reply with ICMP port unreachable packets from kernel
|
||||
d_sock_raw = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||
if (d_sock_raw == -1)
|
||||
{
|
||||
std::cout << "Error opening UDP socket" << std::endl;
|
||||
std::cout << "Error opening UDP socket\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ bool Gr_Complex_Ip_Packet_Source::open()
|
||||
// bind socket to port
|
||||
if (bind(d_sock_raw, reinterpret_cast<struct sockaddr *>(&si_me), sizeof(si_me)) == -1)
|
||||
{
|
||||
std::cout << "Error opening UDP socket" << std::endl;
|
||||
std::cout << "Error opening UDP socket\n";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -273,7 +273,7 @@ void Gr_Complex_Ip_Packet_Source::pcap_callback(__attribute__((unused)) u_char *
|
||||
// ih->daddr.byte3,
|
||||
// ih->daddr.byte4,
|
||||
// dport);
|
||||
// std::cout<<"uh->len:"<<ntohs(uh->len)<<std::endl;
|
||||
// std::cout<<"uh->len:"<<ntohs(uh->len)<< '\n';
|
||||
|
||||
int payload_length_bytes = ntohs(uh->len) - 8; // total udp packet length minus the header length
|
||||
// read the payload bytes and insert them into the shared circular buffer
|
||||
|
||||
@@ -45,7 +45,7 @@ labsat23_source::labsat23_source(const char *signal_file_basename,
|
||||
{
|
||||
if (channel_selector < 1 or channel_selector > 2)
|
||||
{
|
||||
std::cout << "Labsat source config error: channel selection out of bounds, check gnss-sdr config file" << std::endl;
|
||||
std::cout << "Labsat source config error: channel selection out of bounds, check gnss-sdr config file\n";
|
||||
exit(1);
|
||||
}
|
||||
d_channel_selector_config = channel_selector;
|
||||
@@ -64,11 +64,11 @@ labsat23_source::labsat23_source(const char *signal_file_basename,
|
||||
|
||||
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 << '\n';
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Labsat file " << signal_file << " could not be opened!" << std::endl;
|
||||
std::cout << "Labsat file " << signal_file << " could not be opened!\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@@ -219,7 +219,7 @@ int labsat23_source::general_work(int noutput_items,
|
||||
|
||||
if (preamble_ok == false)
|
||||
{
|
||||
std::cout << "Labsat source do not detect the preamble in the selected file" << std::endl;
|
||||
std::cout << "Labsat source do not detect the preamble in the selected file\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -227,18 +227,18 @@ int labsat23_source::general_work(int noutput_items,
|
||||
if (memblock[byte_counter] == 0x4C and memblock[byte_counter + 1] == 0x53 and memblock[byte_counter + 2] == 0x32)
|
||||
{
|
||||
d_labsat_version = 2;
|
||||
std::cout << "Labsat file version 2 detected" << std::endl;
|
||||
std::cout << "Labsat file version 2 detected\n";
|
||||
}
|
||||
|
||||
if (memblock[byte_counter] == 0x4C and memblock[byte_counter + 1] == 0x53 and memblock[byte_counter + 2] == 0x33)
|
||||
{
|
||||
d_labsat_version = 3;
|
||||
std::cout << "Labsat file version 3 detected" << std::endl;
|
||||
std::cout << "Labsat file version 3 detected\n";
|
||||
}
|
||||
|
||||
if (d_labsat_version == 0)
|
||||
{
|
||||
std::cout << "Labsat source do not detect the labsat version in file header" << std::endl;
|
||||
std::cout << "Labsat source do not detect the labsat version in file header\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ int labsat23_source::general_work(int noutput_items,
|
||||
|
||||
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 << '\n';
|
||||
|
||||
byte_counter++;
|
||||
|
||||
@@ -270,32 +270,32 @@ int labsat23_source::general_work(int noutput_items,
|
||||
switch (d_ref_clock)
|
||||
{
|
||||
case 0:
|
||||
std::cout << "Labsat reference clock: internal OCXO" << std::endl;
|
||||
std::cout << "Labsat reference clock: internal OCXO\n";
|
||||
break;
|
||||
case 1:
|
||||
std::cout << "Labsat reference clock: internal TCXO" << std::endl;
|
||||
std::cout << "Labsat reference clock: internal TCXO\n";
|
||||
break;
|
||||
case 2:
|
||||
std::cout << "Labsat reference clock: external 10 MHz" << std::endl;
|
||||
std::cout << "Labsat reference clock: external 10 MHz\n";
|
||||
break;
|
||||
case 3:
|
||||
std::cout << "Labsat reference clock: external 16.386 MHz" << std::endl;
|
||||
std::cout << "Labsat reference clock: external 16.386 MHz\n";
|
||||
break;
|
||||
default:
|
||||
std::cout << "Labsat Unknown reference clock ID " << static_cast<int>(d_ref_clock) << std::endl;
|
||||
std::cout << "Labsat Unknown reference clock ID " << static_cast<int>(d_ref_clock) << '\n';
|
||||
}
|
||||
byte_counter++;
|
||||
d_bits_per_sample = static_cast<uint8_t>(memblock[byte_counter]);
|
||||
switch (d_bits_per_sample)
|
||||
{
|
||||
case 2:
|
||||
std::cout << "Labsat is using 2 bits per sample" << std::endl;
|
||||
std::cout << "Labsat is using 2 bits per sample\n";
|
||||
break;
|
||||
case 4:
|
||||
std::cout << "Labsat is using 4 bits per sample" << std::endl;
|
||||
std::cout << "Labsat is using 4 bits per sample\n";
|
||||
break;
|
||||
default:
|
||||
std::cout << "Labsat Unknown bits per sample ID " << static_cast<int>(d_bits_per_sample) << std::endl;
|
||||
std::cout << "Labsat Unknown bits per sample ID " << static_cast<int>(d_bits_per_sample) << '\n';
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -304,36 +304,36 @@ int labsat23_source::general_work(int noutput_items,
|
||||
switch (d_channel_selector)
|
||||
{
|
||||
case 0:
|
||||
std::cout << "Available channels: Channel A + B, 1 bit quantisation (I & Q)" << std::endl;
|
||||
std::cout << "Available channels: Channel A + B, 1 bit quantisation (I & Q)\n";
|
||||
break;
|
||||
case 1:
|
||||
std::cout << "Available channels: Channel A, 1 bit quantisation (I & Q)" << std::endl;
|
||||
std::cout << "Available channels: Channel A, 1 bit quantisation (I & Q)\n";
|
||||
break;
|
||||
case 2:
|
||||
std::cout << "Available channels: Channel B, 1 bit quantisation (I & Q)" << std::endl;
|
||||
std::cout << "Available channels: Channel B, 1 bit quantisation (I & Q)\n";
|
||||
break;
|
||||
case 3:
|
||||
std::cout << "Available channels: Channel A, 2 bit quantisation (I & Q)" << std::endl;
|
||||
std::cout << "Available channels: Channel A, 2 bit quantisation (I & Q)\n";
|
||||
break;
|
||||
case 4:
|
||||
std::cout << "Available channels: Channel B, 2 bit quantisation (I & Q)" << std::endl;
|
||||
std::cout << "Available channels: Channel B, 2 bit quantisation (I & Q)\n";
|
||||
break;
|
||||
default:
|
||||
std::cout << "Unknown channel selection ID " << static_cast<int>(d_channel_selector) << std::endl;
|
||||
std::cout << "Unknown channel selection ID " << static_cast<int>(d_channel_selector) << '\n';
|
||||
return -1;
|
||||
}
|
||||
|
||||
// check if the selected channel in config file match the file encoding
|
||||
if (d_channel_selector_config == 2 and d_channel_selector != 0)
|
||||
{
|
||||
std::cout << "Labsat source channel config inconsistency: channel 2 is selected but the file has only one channel" << std::endl;
|
||||
std::cout << "Labsat source channel config inconsistency: channel 2 is selected but the file has only one channel\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
// todo: Add support for dual channel files
|
||||
if (d_channel_selector == 0)
|
||||
{
|
||||
std::cout << "ERROR: Labsat file contains more than one channel and it is not currently supported by Labsat signal source." << std::endl;
|
||||
std::cout << "ERROR: Labsat file contains more than one channel and it is not currently supported by Labsat signal source.\n";
|
||||
return -1;
|
||||
}
|
||||
byte_counter++;
|
||||
@@ -343,48 +343,48 @@ int labsat23_source::general_work(int noutput_items,
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
std::cout << "1 bit per sample" << std::endl;
|
||||
std::cout << "1 bit per sample\n";
|
||||
break;
|
||||
case 2:
|
||||
std::cout << "2 bit per sample" << std::endl;
|
||||
std::cout << "2 bit per sample\n";
|
||||
break;
|
||||
default:
|
||||
std::cout << "Unknown quantization ID " << static_cast<int>(quantization) << std::endl;
|
||||
std::cout << "Unknown quantization ID " << static_cast<int>(quantization) << '\n';
|
||||
}
|
||||
byte_counter++;
|
||||
auto channel_a_constellation = static_cast<uint8_t>(memblock[byte_counter]);
|
||||
switch (channel_a_constellation)
|
||||
{
|
||||
case 0:
|
||||
std::cout << "Labsat Channel A is GPS" << std::endl;
|
||||
std::cout << "Labsat Channel A is GPS\n";
|
||||
break;
|
||||
case 1:
|
||||
std::cout << "Labsat Channel A is GLONASS" << std::endl;
|
||||
std::cout << "Labsat Channel A is GLONASS\n";
|
||||
break;
|
||||
case 2:
|
||||
std::cout << "Labsat Channel A is BDS" << std::endl;
|
||||
std::cout << "Labsat Channel A is BDS\n";
|
||||
break;
|
||||
default:
|
||||
std::cout << "Unknown channel A constellation ID " << static_cast<int>(channel_a_constellation) << std::endl;
|
||||
std::cout << "Unknown channel A constellation ID " << static_cast<int>(channel_a_constellation) << '\n';
|
||||
}
|
||||
byte_counter++;
|
||||
auto channel_b_constellation = static_cast<uint8_t>(memblock[byte_counter]);
|
||||
switch (channel_b_constellation)
|
||||
{
|
||||
case 0:
|
||||
std::cout << "Labsat Channel B is GPS" << std::endl;
|
||||
std::cout << "Labsat Channel B is GPS\n";
|
||||
break;
|
||||
case 1:
|
||||
std::cout << "Labsat Channel B is GLONASS" << std::endl;
|
||||
std::cout << "Labsat Channel B is GLONASS\n";
|
||||
break;
|
||||
case 2:
|
||||
std::cout << "Labsat Channel B is BDS" << std::endl;
|
||||
std::cout << "Labsat Channel B is BDS\n";
|
||||
break;
|
||||
case 255:
|
||||
// No channel B
|
||||
break;
|
||||
default:
|
||||
std::cout << "Unknown channel B constellation ID " << static_cast<int>(channel_b_constellation) << std::endl;
|
||||
std::cout << "Unknown channel B constellation ID " << static_cast<int>(channel_b_constellation) << '\n';
|
||||
}
|
||||
|
||||
// end of header
|
||||
@@ -394,10 +394,10 @@ int labsat23_source::general_work(int noutput_items,
|
||||
binary_input_file.seekg(header_bytes, binary_input_file.beg);
|
||||
return 0;
|
||||
}
|
||||
std::cout << "Labsat file header error: section 2 is not available." << std::endl;
|
||||
std::cout << "Labsat file header error: section 2 is not available.\n";
|
||||
return -1;
|
||||
}
|
||||
std::cout << "Labsat file read error: file is empty." << std::endl;
|
||||
std::cout << "Labsat file read error: file is empty.\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -434,23 +434,23 @@ int labsat23_source::general_work(int noutput_items,
|
||||
d_current_file_number++;
|
||||
if (d_labsat_version == 3)
|
||||
{
|
||||
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() << '\n';
|
||||
}
|
||||
binary_input_file.close();
|
||||
binary_input_file.open(generate_filename().c_str(), std::ios::in | std::ios::binary);
|
||||
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() << '\n';
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (d_labsat_version == 3)
|
||||
{
|
||||
std::cout << "Last file reached, LabSat source stop" << std::endl;
|
||||
std::cout << "Last file reached, LabSat source stop\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "End of file reached, LabSat source stop" << std::endl;
|
||||
std::cout << "End of file reached, LabSat source stop\n";
|
||||
}
|
||||
|
||||
d_queue->push(pmt::make_any(command_event_make(200, 0)));
|
||||
@@ -492,23 +492,23 @@ int labsat23_source::general_work(int noutput_items,
|
||||
d_current_file_number++;
|
||||
if (d_labsat_version == 3)
|
||||
{
|
||||
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() << '\n';
|
||||
}
|
||||
binary_input_file.close();
|
||||
binary_input_file.open(generate_filename().c_str(), std::ios::in | std::ios::binary);
|
||||
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() << '\n';
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (d_labsat_version == 3)
|
||||
{
|
||||
std::cout << "Last file reached, LabSat source stop" << std::endl;
|
||||
std::cout << "Last file reached, LabSat source stop\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "End of file reached, LabSat source stop" << std::endl;
|
||||
std::cout << "End of file reached, LabSat source stop\n";
|
||||
}
|
||||
d_queue->push(pmt::make_any(command_event_make(200, 0)));
|
||||
return -1;
|
||||
@@ -523,6 +523,6 @@ int labsat23_source::general_work(int noutput_items,
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::cout << "Warning!!" << std::endl;
|
||||
std::cout << "Warning!!\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ rtl_tcp_signal_source_c::rtl_tcp_signal_source_c(const std::string &address,
|
||||
ip::address addr = ip::address::from_string(address, ec);
|
||||
if (ec)
|
||||
{
|
||||
std::cout << address << " is not an IP address" << std::endl;
|
||||
std::cout << address << " is not an IP address\n";
|
||||
LOG(ERROR) << address << " is not an IP address";
|
||||
return;
|
||||
}
|
||||
@@ -81,20 +81,20 @@ rtl_tcp_signal_source_c::rtl_tcp_signal_source_c(const std::string &address,
|
||||
socket_.open(ep.protocol(), ec);
|
||||
if (ec)
|
||||
{
|
||||
std::cout << "Failed to open socket." << std::endl;
|
||||
std::cout << "Failed to open socket.\n";
|
||||
LOG(ERROR) << "Failed to open socket.";
|
||||
}
|
||||
|
||||
socket_.set_option(boost::asio::socket_base::reuse_address(true), ec);
|
||||
if (ec)
|
||||
{
|
||||
std::cout << "Failed to set reuse address option: " << ec << std::endl;
|
||||
std::cout << "Failed to set reuse address option: " << ec << '\n';
|
||||
LOG(WARNING) << "Failed to set reuse address option";
|
||||
}
|
||||
socket_.set_option(boost::asio::socket_base::linger(true, 0), ec);
|
||||
if (ec)
|
||||
{
|
||||
std::cout << "Failed to set linger option: " << ec << std::endl;
|
||||
std::cout << "Failed to set linger option: " << ec << '\n';
|
||||
LOG(WARNING) << "Failed to set linger option";
|
||||
}
|
||||
|
||||
@@ -104,19 +104,19 @@ rtl_tcp_signal_source_c::rtl_tcp_signal_source_c(const std::string &address,
|
||||
if (ec)
|
||||
{
|
||||
std::cout << "Failed to connect to " << addr << ":" << port
|
||||
<< "(" << ec << ")" << std::endl;
|
||||
<< "(" << ec << ")\n";
|
||||
LOG(ERROR) << "Failed to connect to " << addr << ":" << port
|
||||
<< "(" << ec << ")";
|
||||
return;
|
||||
}
|
||||
std::cout << "Connected to " << addr << ":" << port << std::endl;
|
||||
std::cout << "Connected to " << addr << ":" << port << '\n';
|
||||
LOG(INFO) << "Connected to " << addr << ":" << port;
|
||||
|
||||
// 4. Set nodelay
|
||||
socket_.set_option(tcp::no_delay(true), ec);
|
||||
if (ec)
|
||||
{
|
||||
std::cout << "Failed to set no delay option." << std::endl;
|
||||
std::cout << "Failed to set no delay option.\n";
|
||||
LOG(WARNING) << "Failed to set no delay option";
|
||||
}
|
||||
|
||||
@@ -124,12 +124,12 @@ rtl_tcp_signal_source_c::rtl_tcp_signal_source_c(const std::string &address,
|
||||
ec = info_.read(socket_);
|
||||
if (ec)
|
||||
{
|
||||
std::cout << "Failed to read dongle info." << std::endl;
|
||||
std::cout << "Failed to read dongle info.\n";
|
||||
LOG(WARNING) << "Failed to read dongle info";
|
||||
}
|
||||
else if (info_.is_valid())
|
||||
{
|
||||
std::cout << "Found " << info_.get_type_name() << " tuner." << std::endl;
|
||||
std::cout << "Found " << info_.get_type_name() << " tuner.\n";
|
||||
LOG(INFO) << "Found " << info_.get_type_name() << " tuner.";
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ void rtl_tcp_signal_source_c::set_frequency(int frequency)
|
||||
rtl_tcp_command(RTL_TCP_SET_FREQUENCY, frequency, socket_);
|
||||
if (ec)
|
||||
{
|
||||
std::cout << "Failed to set frequency" << std::endl;
|
||||
std::cout << "Failed to set frequency\n";
|
||||
LOG(WARNING) << "Failed to set frequency";
|
||||
}
|
||||
}
|
||||
@@ -178,7 +178,7 @@ void rtl_tcp_signal_source_c::set_sample_rate(int sample_rate)
|
||||
rtl_tcp_command(RTL_TCP_SET_SAMPLE_RATE, sample_rate, socket_);
|
||||
if (ec)
|
||||
{
|
||||
std::cout << "Failed to set sample rate" << std::endl;
|
||||
std::cout << "Failed to set sample rate\n";
|
||||
LOG(WARNING) << "Failed to set sample rate";
|
||||
}
|
||||
}
|
||||
@@ -190,13 +190,13 @@ void rtl_tcp_signal_source_c::set_agc_mode(bool agc)
|
||||
rtl_tcp_command(RTL_TCP_SET_GAIN_MODE, !agc, socket_);
|
||||
if (ec)
|
||||
{
|
||||
std::cout << "Failed to set gain mode" << std::endl;
|
||||
std::cout << "Failed to set gain mode\n";
|
||||
LOG(WARNING) << "Failed to set gain mode";
|
||||
}
|
||||
ec = rtl_tcp_command(RTL_TCP_SET_AGC_MODE, agc, socket_);
|
||||
if (ec)
|
||||
{
|
||||
std::cout << "Failed to set gain mode" << std::endl;
|
||||
std::cout << "Failed to set gain mode\n";
|
||||
LOG(WARNING) << "Failed to set gain mode";
|
||||
}
|
||||
}
|
||||
@@ -208,7 +208,7 @@ void rtl_tcp_signal_source_c::set_gain(int gain)
|
||||
boost::system::error_code ec = rtl_tcp_command(RTL_TCP_SET_GAIN, clipped, socket_);
|
||||
if (ec)
|
||||
{
|
||||
std::cout << "Failed to set gain" << std::endl;
|
||||
std::cout << "Failed to set gain\n";
|
||||
LOG(WARNING) << "Failed to set gain";
|
||||
}
|
||||
}
|
||||
@@ -275,7 +275,7 @@ void rtl_tcp_signal_source_c::set_if_gain(int gain)
|
||||
boost::system::error_code ec = rtl_tcp_command(RTL_TCP_SET_IF_GAIN, param, socket_);
|
||||
if (ec)
|
||||
{
|
||||
std::cout << "Failed to set if gain" << std::endl;
|
||||
std::cout << "Failed to set if gain\n";
|
||||
LOG(WARNING) << "Failed to set if gain";
|
||||
}
|
||||
}
|
||||
@@ -287,7 +287,7 @@ void rtl_tcp_signal_source_c::handle_read(const boost::system::error_code &ec,
|
||||
{
|
||||
if (ec)
|
||||
{
|
||||
std::cout << "Error during read: " << ec << std::endl;
|
||||
std::cout << "Error during read: " << ec << '\n';
|
||||
LOG(WARNING) << "Error during read: " << ec;
|
||||
boost::mutex::scoped_lock lock(mutex_);
|
||||
io_context_.stop();
|
||||
|
||||
Reference in New Issue
Block a user