-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make it work under linux with gqrx/gr-osmosdr #223
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ unsigned long Failures = 0; | |
|
||
void RadioHandlerClass::OnDataPacket() | ||
{ | ||
auto len = outputbuffer.getBlockSize() / 2 / sizeof(float); | ||
auto len = outputbuffer.getBlockSize(); | ||
|
||
while(run) | ||
{ | ||
|
@@ -30,12 +30,6 @@ void RadioHandlerClass::OnDataPacket() | |
if (!run) | ||
break; | ||
|
||
if (fc != 0.0f) | ||
{ | ||
std::unique_lock<std::mutex> lk(fc_mutex); | ||
shift_limited_unroll_C_sse_inp_c((complexf*)buf, len, stateFineTune); | ||
} | ||
|
||
#ifdef _DEBUG //PScope buffer screenshot | ||
if (saveADCsamplesflag == true) | ||
{ | ||
|
@@ -74,27 +68,40 @@ RadioHandlerClass::RadioHandlerClass() : | |
inputbuffer.setBlockSize(transferSamples); | ||
|
||
stateFineTune = new shift_limited_unroll_C_sse_data_t(); | ||
adcrate = adcnominalfreq; | ||
DbgPrintf("RadioHandlerClass::RadioHandlerClass\n"); | ||
} | ||
|
||
RadioHandlerClass::~RadioHandlerClass() | ||
{ | ||
delete stateFineTune; | ||
delete r2iqCntrl; | ||
delete hardware; | ||
delete fx3; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this class owes the fx3 instance. it is allocated by someone else. better deallocate by the owner. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That was freed by the owner while threads were still running, resulting in random crashes/freezes. That's why I did this change. I don't think, that it is better to deallocate by the owner. I think that it is better to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it should not happen at least for Windows. Can you point me the crash stacks of two threads? I can help debug. |
||
} | ||
|
||
const char *RadioHandlerClass::getName() | ||
{ | ||
return hardware->getName(); | ||
} | ||
|
||
bool RadioHandlerClass::Init(fx3class* Fx3, void (*callback)(void*context, const float*, uint32_t), r2iqControlClass *r2iqCntrl, void *context) | ||
bool RadioHandlerClass::Init(fx3class* Fx3, void (*callback)(void*context, const float*, uint32_t), r2iqControlClass *r2iqCntrlIn, void *context) | ||
{ | ||
uint8_t rdata[4]; | ||
this->fx3 = Fx3; | ||
this->Callback = callback; | ||
this->callbackContext = context; | ||
|
||
if (r2iqCntrl == nullptr) | ||
if (r2iqCntrlIn == nullptr) | ||
{ | ||
r2iqCntrl = new fft_mt_r2iq(); | ||
DbgPrintf("RadioHandlerClass::Init r2iqCntrl created\n"); | ||
} | ||
else | ||
{ | ||
r2iqCntrl = r2iqCntrlIn; | ||
DbgPrintf("RadioHandlerClass::Init r2iqCntrl assigned\n"); | ||
} | ||
|
||
Fx3->GetHardwareInfo((uint32_t*)rdata); | ||
|
||
|
@@ -137,15 +144,30 @@ bool RadioHandlerClass::Init(fx3class* Fx3, void (*callback)(void*context, const | |
DbgPrintf("WARNING no SDR connected\n"); | ||
break; | ||
} | ||
adcrate = adcnominalfreq; | ||
hardware->Initialize(adcnominalfreq); | ||
vladisslav2011 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
DbgPrintf("%s | firmware %x\n", hardware->getName(), firmware); | ||
this->r2iqCntrl = r2iqCntrl; | ||
DbgPrintf("%s | firmware %x adcrate %u\n", hardware->getName(), firmware, adcrate); | ||
r2iqCntrl->Init(hardware->getGain(), &inputbuffer, &outputbuffer); | ||
|
||
return true; | ||
} | ||
|
||
int RadioHandlerClass::SetSampleRate(int sr) | ||
{ | ||
adcrate = sr; | ||
if(adcrate < 8000000) | ||
adcrate = 8000000; | ||
if(adcrate > 128000000) | ||
adcrate = 128000000; | ||
|
||
hardware->Initialize(adcrate); | ||
return adcrate; | ||
} | ||
|
||
int RadioHandlerClass::GetSampleRate() | ||
{ | ||
return adcrate; | ||
} | ||
|
||
bool RadioHandlerClass::Start(int srate_idx) | ||
{ | ||
Stop(); | ||
|
@@ -169,6 +191,7 @@ bool RadioHandlerClass::Start(int srate_idx) | |
// 0,1,2,3,4 => 32,16,8,4,2 MHz | ||
r2iqCntrl->setDecimate(decimate); | ||
r2iqCntrl->TurnOn(); | ||
|
||
fx3->StartStream(inputbuffer, QUEUE_SIZE); | ||
|
||
submit_thread = std::thread( | ||
|
@@ -203,8 +226,8 @@ bool RadioHandlerClass::Stop() | |
submit_thread.join(); | ||
DbgPrintf("submit_thread join1\n"); | ||
|
||
hardware->FX3producerOff(); //FX3 stop the producer | ||
} | ||
hardware->FX3producerOff(); //FX3 stop the producer | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it will get called in Stop. We should either remove the other place to call this or delete this line. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where is the other place? |
||
return true; | ||
} | ||
|
||
|
@@ -247,6 +270,11 @@ int RadioHandlerClass::UpdateIFGain(int idx) | |
return 0; | ||
} | ||
|
||
int RadioHandlerClass::UpdateTunerBW(int bwHz) | ||
{ | ||
return hardware->UpdateTunerBW(bwHz); | ||
} | ||
|
||
int RadioHandlerClass::GetRFAttSteps(const float **steps) | ||
{ | ||
return hardware->getRFSteps(steps); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this get removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was unable to make decimator work as expected, so I partially removed it. Offset tuning was removed as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oscar may help and he is expert on that DSP code.