pull/19/head
Paul 2022-01-07 13:34:03 +01:00
rodzic 8ba7f0daa5
commit 0cb314d8ad
3 zmienionych plików z 0 dodań i 38 usunięć

Wyświetl plik

@ -145,7 +145,4 @@ class SoapyRadioberry : public SoapySDR::Device{
std::unique_ptr<rpihw::driver::i2c> i2c_ptr;
bool i2c_available = false;
radioberrysdrStreamFormat streamFormat;
uint32_t m_count;
uint32_t m_highwater, m_lowwater;
__useconds_t m_sleep;
};

Wyświetl plik

@ -11,11 +11,6 @@ SoapyRadioberry::SoapyRadioberry( const SoapySDR::Kwargs &args ){
SoapySDR_log(SOAPY_SDR_INFO, "SoapyRadioberry::SoapyRadioberry constructor called");
no_channels = 1;
m_count = 0;
m_lowwater = RADIOBERRY_BUFFER_SIZE / 3;
m_highwater = (RADIOBERRY_BUFFER_SIZE * 2) / 3 ; // assume 64 K buffer
m_sleep = (__useconds_t)(1000000.0 / 48000.0 * (double)(m_highwater - m_lowwater));
m_sleep = m_sleep - m_sleep / 10;
fd_rb = open("/dev/radioberry", O_RDWR);
try
{

Wyświetl plik

@ -109,8 +109,6 @@ SoapySDR::Stream *SoapyRadioberry::setupStream(
{
SoapySDR_log(SOAPY_SDR_INFO, "Using format CS16.");
streamFormat = RADIOBERRY_SDR_CS16;
m_count = 0;
printf("sleep %d\n", m_sleep);
}
else
{
@ -211,20 +209,6 @@ int SoapyRadioberry::writeStream(SoapySDR::Stream *stream, const void * const *b
tx.i16TxBuffer[0] = (int16_t)(target_buffer[iq++] * 16384.0f);
tx.i16TxBuffer[1] = (int16_t)(target_buffer[iq++] * 16384.0f);
ret = write(fd_rb, &tx, 4 * sizeof(uint8_t));
m_count++;
if (ret == 0)
{
auto now = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> timePassed = now - startTime;
printf("Time passed %4.2f radioberry buffer full count %d", timePassed.count(), m_count);
fflush(NULL);
}
if(m_count > m_highwater)
{
m_count = m_lowwater;
usleep(m_sleep);
}
}
}
if (streamFormat == RADIOBERRY_SDR_CS16)
@ -243,20 +227,6 @@ int SoapyRadioberry::writeStream(SoapySDR::Stream *stream, const void * const *b
ret = write(fd_rb, &tx, sizeof(uint32_t));
j += 2;
m_count++;
// Measure the time until a high watermark apears
if ((m_count > m_highwater) || (ret == 0))
{
auto now = std::chrono::high_resolution_clock::now();
//auto timePassed = std::chrono::duration_cast<std::chrono::microseconds>(now - startTime);
std::chrono::duration<double> timePassed = now - startTime;
//printf("Time passed %4.2f micro seconds\n", timePassed.count() * 1000000.0);
m_count = m_lowwater;
startTime = std::chrono::high_resolution_clock::now();
// Time to sleep is 1/3 of buffer times 50 uSec
usleep(m_sleep); // (1/48K about 20usec /sample * difference between high and low water mark)
}
}
}
return numElems;