kopia lustrzana https://github.com/Guenael/rtlsdr-wsprd
fix: nloop/maxloop exiting
rodzic
5d05552a0f
commit
d3009fd8e8
|
@ -90,6 +90,7 @@ struct receiver_options {
|
||||||
int32_t upconverter;
|
int32_t upconverter;
|
||||||
int32_t directsampling;
|
int32_t directsampling;
|
||||||
int32_t maxloop;
|
int32_t maxloop;
|
||||||
|
int32_t nloop;
|
||||||
int32_t device;
|
int32_t device;
|
||||||
bool selftest;
|
bool selftest;
|
||||||
bool writefile;
|
bool writefile;
|
||||||
|
@ -255,8 +256,11 @@ static void *decoder(void *arg) {
|
||||||
/* Select the previous transmission / other buffer */
|
/* Select the previous transmission / other buffer */
|
||||||
uint32_t prevBuffer = (rx_state.bufferIndex + 1) % 2;
|
uint32_t prevBuffer = (rx_state.bufferIndex + 1) % 2;
|
||||||
|
|
||||||
if (rx_state.iqIndex[prevBuffer] < ( (SIGNAL_LENGHT - 3) * SIGNAL_SAMPLE_RATE ) )
|
if (rx_state.iqIndex[prevBuffer] < ( (SIGNAL_LENGHT - 3) * SIGNAL_SAMPLE_RATE ) ) {
|
||||||
continue; /* Partial buffer during the first RX, skip it! */
|
continue; /* Partial buffer during the first RX, skip it! */
|
||||||
|
} else {
|
||||||
|
rx_options.nloop++; /* Decoding this signal, count it! */
|
||||||
|
}
|
||||||
|
|
||||||
/* Delete any previous samples tail */
|
/* Delete any previous samples tail */
|
||||||
for (int i = rx_state.iqIndex[prevBuffer]; i < SIGNAL_LENGHT * SIGNAL_SAMPLE_RATE; i++) {
|
for (int i = rx_state.iqIndex[prevBuffer]; i < SIGNAL_LENGHT * SIGNAL_SAMPLE_RATE; i++) {
|
||||||
|
@ -309,6 +313,7 @@ void initSampleStorage() {
|
||||||
rx_state.bufferIndex = 0;
|
rx_state.bufferIndex = 0;
|
||||||
rx_state.iqIndex[0] = 0;
|
rx_state.iqIndex[0] = 0;
|
||||||
rx_state.iqIndex[1] = 0;
|
rx_state.iqIndex[1] = 0;
|
||||||
|
rx_state.exit_flag = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -320,13 +325,13 @@ void initrx_options() {
|
||||||
rx_options.shift = 0;
|
rx_options.shift = 0;
|
||||||
rx_options.directsampling = 0;
|
rx_options.directsampling = 0;
|
||||||
rx_options.maxloop = 0;
|
rx_options.maxloop = 0;
|
||||||
|
rx_options.nloop = 0;
|
||||||
rx_options.device = 0;
|
rx_options.device = 0;
|
||||||
rx_options.selftest = false;
|
rx_options.selftest = false;
|
||||||
rx_options.writefile = false;
|
rx_options.writefile = false;
|
||||||
rx_options.readfile = false;
|
rx_options.readfile = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Default options for the decoder */
|
/* Default options for the decoder */
|
||||||
void initDecoder_options() {
|
void initDecoder_options() {
|
||||||
dec_options.usehashtable = 0;
|
dec_options.usehashtable = 0;
|
||||||
|
@ -822,10 +827,6 @@ int main(int argc, char **argv) {
|
||||||
initrx_options();
|
initrx_options();
|
||||||
initDecoder_options();
|
initDecoder_options();
|
||||||
|
|
||||||
/* Stop condition setup */
|
|
||||||
rx_state.exit_flag = false;
|
|
||||||
uint32_t nLoop = 0;
|
|
||||||
|
|
||||||
if (argc <= 1)
|
if (argc <= 1)
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
|
@ -1136,7 +1137,7 @@ int main(int argc, char **argv) {
|
||||||
pthread_create(&decState.thread, &decState.tattr, decoder, NULL);
|
pthread_create(&decState.thread, &decState.tattr, decoder, NULL);
|
||||||
|
|
||||||
/* Main loop : Wait, read, decode */
|
/* Main loop : Wait, read, decode */
|
||||||
while (!rx_state.exit_flag && !(rx_options.maxloop && (nLoop >= rx_options.maxloop))) {
|
while (!rx_state.exit_flag && !(rx_options.maxloop && (rx_options.nloop >= rx_options.maxloop))) {
|
||||||
/* Wait for time Sync on 2 mins */
|
/* Wait for time Sync on 2 mins */
|
||||||
gettimeofday(&lTime, NULL);
|
gettimeofday(&lTime, NULL);
|
||||||
sec = lTime.tv_sec % 120;
|
sec = lTime.tv_sec % 120;
|
||||||
|
@ -1148,18 +1149,18 @@ int main(int argc, char **argv) {
|
||||||
rx_state.bufferIndex = (rx_state.bufferIndex + 1) % 2;
|
rx_state.bufferIndex = (rx_state.bufferIndex + 1) % 2;
|
||||||
rx_state.iqIndex[rx_state.bufferIndex] = 0;
|
rx_state.iqIndex[rx_state.bufferIndex] = 0;
|
||||||
safe_cond_signal(&decState.ready_cond, &decState.ready_mutex);
|
safe_cond_signal(&decState.ready_cond, &decState.ready_mutex);
|
||||||
|
usleep(100000); /* Give a chance to the other thread to update the nloop counter */
|
||||||
nLoop++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Stop the decoder thread */
|
||||||
|
rx_state.exit_flag = true;
|
||||||
|
safe_cond_signal(&decState.ready_cond, &decState.ready_mutex);
|
||||||
|
|
||||||
/* Stop the RX and free the blocking function */
|
/* Stop the RX and free the blocking function */
|
||||||
rtlsdr_cancel_async(rtl_device);
|
rtlsdr_cancel_async(rtl_device);
|
||||||
|
|
||||||
/* Close the RTL device */
|
|
||||||
rtlsdr_close(rtl_device);
|
rtlsdr_close(rtl_device);
|
||||||
|
|
||||||
/* Wait the thread join (send a signal before to terminate the job) */
|
/* Wait the thread join (send a signal before to terminate the job) */
|
||||||
safe_cond_signal(&decState.ready_cond, &decState.ready_mutex);
|
|
||||||
pthread_join(decState.thread, NULL);
|
pthread_join(decState.thread, NULL);
|
||||||
pthread_join(dongle, NULL);
|
pthread_join(dongle, NULL);
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue