This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/osmocom-sdr@lists.osmocom.org/.
Nuno Gonçalves nunojpg at gmail.comI'm not sure it this was overlooked or if I should format it any other way... Regards, Nuno ---------- Forwarded message ---------- From: Nuno Gonçalves <nunojpg at gmail.com> Date: Sun, Apr 21, 2013 at 6:59 PM Subject: rtl_test patch To: osmocom-sdr at lists.osmocom.org Corrects bugs where: Cumulative PPM error is always "342" if execution stopped before first PPM_DURATION. PPM error alias to wrong values if over +-1045 (this happens quite a lot actually due to bug reported at [1]). Behavior changes: Cumulative PPM error value is now printed every PPM_DURATION so the user can check when it is settled. [1] http://lists.osmocom.org/pipermail/osmocom-sdr/2013-April/000584.html Thanks, Nuno Signed-off-by: Nuno Goncalves <nunojpg at gmail.com> diff --git a/src/rtl_test.c b/src/rtl_test.c index f5a56b8..c705e04 100644 --- a/src/rtl_test.c +++ b/src/rtl_test.c @@ -55,6 +55,8 @@ static int ppm_benchmark = 0; static int64_t ppm_count = 0L; static int64_t ppm_total = 0L; +static uint32_t samp_rate = DEFAULT_SAMPLE_RATE; + #ifndef _WIN32 static struct timespec ppm_start; static struct timespec ppm_recent; @@ -108,6 +110,7 @@ static void rtlsdr_callback(unsigned char *buf, uint32_t len, void *ctx) { uint32_t i, lost = 0; int64_t ns; + int real_rate; if (uninit) { bcnt = buf[0]; @@ -141,17 +144,23 @@ static void rtlsdr_callback(unsigned char *buf, uint32_t len, void *ctx) if (ppm_now.tv_sec - ppm_recent.tv_sec > PPM_DURATION) { ns = 1000000000L * (int64_t)(ppm_now.tv_sec - ppm_recent.tv_sec); ns += (int64_t)(ppm_now.tv_nsec - ppm_recent.tv_nsec); - printf("real sample rate: %i\n", + printf("real sample rate: %i", (int)((1000000000L * ppm_count / 2L) / ns)); - #ifndef __APPLE__ - clock_gettime(CLOCK_REALTIME, &ppm_recent); - #else - gettimeofday(&tv, NULL); - ppm_recent.tv_sec = tv.tv_sec; - ppm_recent.tv_nsec = tv.tv_usec*1000; - #endif + ppm_total += ppm_count / 2L; ppm_count = 0L; + + #ifndef _WIN32 + ns = 1000000000L * (int64_t)(ppm_now.tv_sec - ppm_start.tv_sec); + ns += (int64_t)(ppm_now.tv_nsec - ppm_start.tv_nsec); + real_rate = (int)(ppm_total * 1000000000L / ns); + printf(" cumulative PPM error: %.1f\n", + (1000000.0 * (real_rate - (int)samp_rate)) / samp_rate); + #else + printf("\n"); + #endif + + ppm_recent = ppm_now; } #endif } @@ -213,13 +222,10 @@ int main(int argc, char **argv) int sync_mode = 0; uint8_t *buffer; uint32_t dev_index = 0; - uint32_t samp_rate = DEFAULT_SAMPLE_RATE; uint32_t out_block_size = DEFAULT_BUF_LENGTH; int device_count; int count; int gains[100]; - int real_rate; - int64_t ns; while ((opt = getopt(argc, argv, "d:s:b:tpS::")) != -1) { switch (opt) { @@ -365,15 +371,6 @@ int main(int argc, char **argv) if (do_exit) { fprintf(stderr, "\nUser cancel, exiting...\n"); - if (ppm_benchmark) { -#ifndef _WIN32 - ns = 1000000000L * (int64_t)(ppm_recent.tv_sec - ppm_start.tv_sec); - ns += (int64_t)(ppm_recent.tv_nsec - ppm_start.tv_nsec); - real_rate = (int)(ppm_total * 1000000000L / ns); - printf("Cumulative PPM error: %i\n", - (int)round((double)(1000000 * (real_rate - (int)samp_rate)) / (double)samp_rate)); -#endif - } } else fprintf(stderr, "\nLibrary error %d, exiting...\n", r); -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/osmocom-sdr/attachments/20131102/caa662a8/attachment.htm> -------------- next part -------------- A non-text attachment was scrubbed... Name: patch_ppm.diff Type: application/octet-stream Size: 2512 bytes Desc: not available URL: <http://lists.osmocom.org/pipermail/osmocom-sdr/attachments/20131102/caa662a8/attachment.obj>