mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-14 20:20:35 +00:00
Merge branch 'Geontech-add-cfloat-to-udp-source' into next
This commit is contained in:
commit
9af02a3bbd
@ -48,6 +48,9 @@ SPDX-FileCopyrightText: 2011-2020 Carles Fernandez-Prades <carles.fernandez@cttc
|
|||||||
and `SignalSource.throttle_frequency_sps`, thus allowing the emulation of
|
and `SignalSource.throttle_frequency_sps`, thus allowing the emulation of
|
||||||
real-time operation.
|
real-time operation.
|
||||||
- Improved General Block diagram, both in content and in image resolution.
|
- Improved General Block diagram, both in content and in image resolution.
|
||||||
|
- The `Custom_UDP_Signal_Source` implementation now accepts
|
||||||
|
`SignalSource.sample_type=cfloat`, in addition to the existing 4 and 8-bit
|
||||||
|
length sample types.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -118,6 +118,11 @@ Gr_Complex_Ip_Packet_Source::Gr_Complex_Ip_Packet_Source(std::string src_device,
|
|||||||
d_wire_sample_type = 2;
|
d_wire_sample_type = 2;
|
||||||
d_bytes_per_sample = d_n_baseband_channels;
|
d_bytes_per_sample = d_n_baseband_channels;
|
||||||
}
|
}
|
||||||
|
else if (wire_sample_type == "cfloat")
|
||||||
|
{
|
||||||
|
d_wire_sample_type = 3;
|
||||||
|
d_bytes_per_sample = d_n_baseband_channels * 8;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "Unknown wire sample type\n";
|
std::cout << "Unknown wire sample type\n";
|
||||||
@ -319,9 +324,6 @@ void Gr_Complex_Ip_Packet_Source::my_pcap_loop_thread(pcap_t *pcap_handle)
|
|||||||
|
|
||||||
void Gr_Complex_Ip_Packet_Source::demux_samples(const gr_vector_void_star &output_items, int num_samples_readed)
|
void Gr_Complex_Ip_Packet_Source::demux_samples(const gr_vector_void_star &output_items, int num_samples_readed)
|
||||||
{
|
{
|
||||||
int8_t real;
|
|
||||||
int8_t imag;
|
|
||||||
uint8_t tmp_char2;
|
|
||||||
for (int n = 0; n < num_samples_readed; n++)
|
for (int n = 0; n < num_samples_readed; n++)
|
||||||
{
|
{
|
||||||
switch (d_wire_sample_type)
|
switch (d_wire_sample_type)
|
||||||
@ -329,6 +331,8 @@ void Gr_Complex_Ip_Packet_Source::demux_samples(const gr_vector_void_star &outpu
|
|||||||
case 1: // interleaved byte samples
|
case 1: // interleaved byte samples
|
||||||
for (auto &output_item : output_items)
|
for (auto &output_item : output_items)
|
||||||
{
|
{
|
||||||
|
int8_t real;
|
||||||
|
int8_t imag;
|
||||||
real = fifo_buff[fifo_read_ptr++];
|
real = fifo_buff[fifo_read_ptr++];
|
||||||
imag = fifo_buff[fifo_read_ptr++];
|
imag = fifo_buff[fifo_read_ptr++];
|
||||||
if (d_IQ_swap)
|
if (d_IQ_swap)
|
||||||
@ -344,6 +348,9 @@ void Gr_Complex_Ip_Packet_Source::demux_samples(const gr_vector_void_star &outpu
|
|||||||
case 2: // 4-bit samples
|
case 2: // 4-bit samples
|
||||||
for (auto &output_item : output_items)
|
for (auto &output_item : output_items)
|
||||||
{
|
{
|
||||||
|
int8_t real;
|
||||||
|
int8_t imag;
|
||||||
|
uint8_t tmp_char2;
|
||||||
tmp_char2 = fifo_buff[fifo_read_ptr] & 0x0F;
|
tmp_char2 = fifo_buff[fifo_read_ptr] & 0x0F;
|
||||||
if (tmp_char2 >= 8)
|
if (tmp_char2 >= 8)
|
||||||
{
|
{
|
||||||
@ -373,6 +380,25 @@ void Gr_Complex_Ip_Packet_Source::demux_samples(const gr_vector_void_star &outpu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 3: // interleaved float samples
|
||||||
|
for (auto &output_item : output_items)
|
||||||
|
{
|
||||||
|
float real;
|
||||||
|
float imag;
|
||||||
|
memcpy(&real, &fifo_buff[fifo_read_ptr], sizeof(real));
|
||||||
|
fifo_read_ptr += 4; // Four bytes in float
|
||||||
|
memcpy(&imag, &fifo_buff[fifo_read_ptr], sizeof(imag));
|
||||||
|
fifo_read_ptr += 4; // Four bytes in float
|
||||||
|
if (d_IQ_swap)
|
||||||
|
{
|
||||||
|
static_cast<gr_complex *>(output_item)[n] = gr_complex(real, imag);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
static_cast<gr_complex *>(output_item)[n] = gr_complex(imag, real);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
std::cout << "Unknown wire sample type\n";
|
std::cout << "Unknown wire sample type\n";
|
||||||
exit(0);
|
exit(0);
|
||||||
@ -407,6 +433,7 @@ int Gr_Complex_Ip_Packet_Source::work(int noutput_items,
|
|||||||
{
|
{
|
||||||
case 1: // complex byte samples
|
case 1: // complex byte samples
|
||||||
case 2: // complex 4 bits samples
|
case 2: // complex 4 bits samples
|
||||||
|
case 3: // complex float samples
|
||||||
bytes_requested = noutput_items * d_bytes_per_sample;
|
bytes_requested = noutput_items * d_bytes_per_sample;
|
||||||
if (bytes_requested < fifo_items)
|
if (bytes_requested < fifo_items)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user