add synchronous mode and hack around mutex problems, allowing rtl_fm to work.
This commit is contained in:
parent
46d38aa884
commit
777ce0e01f
@ -1,8 +1,9 @@
|
||||
# $OpenBSD: Makefile,v 1.1.1.1 2013/04/21 11:45:08 sthen Exp $
|
||||
# $OpenBSD: Makefile,v 1.2 2013/04/23 14:50:19 sthen Exp $
|
||||
|
||||
COMMENT= software to turn RTL2832U into an SDR
|
||||
|
||||
DISTNAME= rtl-sdr-0.20130412
|
||||
REVISION= 0
|
||||
|
||||
SHARED_LIBS= rtlsdr 0.0
|
||||
|
||||
@ -32,6 +33,6 @@ NO_TEST= Yes
|
||||
# issues (unlocking already-unlocked mutex). other programs have been
|
||||
# patched to force synchronous mode. update DESCR if fixing these.
|
||||
post-install:
|
||||
cd ${PREFIX}/bin && rm rtl_adsb rtl_fm rtl_tcp
|
||||
cd ${PREFIX}/bin && rm rtl_adsb rtl_tcp
|
||||
|
||||
.include <bsd.port.mk>
|
||||
|
75
comms/rtl-sdr/patches/patch-src_rtl_fm_c
Normal file
75
comms/rtl-sdr/patches/patch-src_rtl_fm_c
Normal file
@ -0,0 +1,75 @@
|
||||
$OpenBSD: patch-src_rtl_fm_c,v 1.1 2013/04/23 14:50:19 sthen Exp $
|
||||
--- src/rtl_fm.c.orig Fri Apr 12 21:51:14 2013
|
||||
+++ src/rtl_fm.c Tue Apr 23 15:42:34 2013
|
||||
@@ -128,6 +128,7 @@ void usage(void)
|
||||
"\t[-E sets lower edge tuning (default: center)]\n"
|
||||
"\t[-N enables NBFM mode (default: on)]\n"
|
||||
"\t[-W enables WBFM mode (default: off)]\n"
|
||||
+ "\t[-S force sync output (default: async)]\n"
|
||||
"\t (-N -s 170k -o 4 -A fast -r 32k -l 0 -D)\n"
|
||||
"\tfilename (a '-' dumps samples to stdout)\n"
|
||||
"\t (omitting the filename also uses stdout)\n\n"
|
||||
@@ -723,12 +724,22 @@ int main(int argc, char **argv)
|
||||
uint32_t dev_index = 0;
|
||||
int device_count;
|
||||
int ppm_error = 0;
|
||||
+#ifdef __OpenBSD__
|
||||
+ int sync_mode = 1;
|
||||
+#else
|
||||
+ int sync_mode = 0;
|
||||
+#endif
|
||||
char vendor[256], product[256], serial[256];
|
||||
+ pthread_mutexattr_t attr;
|
||||
+
|
||||
fm_init(&fm);
|
||||
- pthread_mutex_init(&data_ready, NULL);
|
||||
- pthread_mutex_init(&data_write, NULL);
|
||||
+ pthread_mutexattr_init(&attr);
|
||||
+ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL);
|
||||
+ pthread_mutex_init(&data_ready, &attr);
|
||||
+ pthread_mutex_init(&data_write, &attr);
|
||||
+ pthread_mutexattr_destroy(&attr);
|
||||
|
||||
- while ((opt = getopt(argc, argv, "d:f:g:s:b:l:o:t:r:p:EFA:NWMULRDC")) != -1) {
|
||||
+ while ((opt = getopt(argc, argv, "d:f:g:s:b:l:o:t:r:p:EFA:NWMULRDSC")) != -1) {
|
||||
switch (opt) {
|
||||
case 'd':
|
||||
dev_index = atoi(optarg);
|
||||
@@ -815,6 +826,9 @@ int main(int argc, char **argv)
|
||||
case 'R':
|
||||
fm.mode_demod = &raw_demod;
|
||||
break;
|
||||
+ case 'S':
|
||||
+ sync_mode = 1;
|
||||
+ break;
|
||||
default:
|
||||
usage();
|
||||
break;
|
||||
@@ -921,9 +935,24 @@ int main(int argc, char **argv)
|
||||
fprintf(stderr, "WARNING: Failed to reset buffers.\n");}
|
||||
|
||||
pthread_create(&demod_thread, NULL, demod_thread_fn, (void *)(&fm));
|
||||
- rtlsdr_read_async(dev, rtlsdr_callback, (void *)(&fm),
|
||||
- DEFAULT_ASYNC_BUF_NUMBER,
|
||||
- lcm_post[fm.post_downsample] * DEFAULT_BUF_LENGTH);
|
||||
+ if (sync_mode) {
|
||||
+ fprintf(stderr, "Reading samples in sync mode...\n");
|
||||
+ while (!do_exit) {
|
||||
+ r = rtlsdr_read_sync(dev, &fm.buf,
|
||||
+ lcm_post[fm.post_downsample] * DEFAULT_BUF_LENGTH,
|
||||
+ &fm.buf_len);
|
||||
+ if (r < 0) {
|
||||
+ fprintf(stderr, "WARNING: sync read failed.\n");
|
||||
+ break;
|
||||
+ }
|
||||
+ full_demod(&fm);
|
||||
+ }
|
||||
+ } else {
|
||||
+ fprintf(stderr, "Reading samples in async mode...\n");
|
||||
+ rtlsdr_read_async(dev, rtlsdr_callback, (void *)(&fm),
|
||||
+ DEFAULT_ASYNC_BUF_NUMBER,
|
||||
+ lcm_post[fm.post_downsample] * DEFAULT_BUF_LENGTH);
|
||||
+ }
|
||||
|
||||
if (do_exit) {
|
||||
fprintf(stderr, "\nUser cancel, exiting...\n");}
|
@ -5,14 +5,14 @@ samples to the host, which is officially used for DAB/DAB+/FM demodulation.
|
||||
RTL-SDR provides some tools to work with these devices:
|
||||
|
||||
rtl_eeprom: EEPROM programming tool
|
||||
rtl_fm: general purpose analogue demodulator
|
||||
(narrow band FM, wide band FM, AM and SSB)
|
||||
rtl_sdr: tunes the device and captures raw data to a file
|
||||
rtl_test: check the possible tuning range
|
||||
|
||||
Asynchronous mode is NOT currently supported on OpenBSD. rtl_sdr and rtl_test
|
||||
have been modified to force synchronous mode, and the following are not yet
|
||||
Asynchronous mode is NOT currently supported on OpenBSD; some programs
|
||||
have been modified to force synchronous mode, the following are not yet
|
||||
available:
|
||||
|
||||
rtl_adsb: simple ADS-B decoder (aircraft tracking)
|
||||
rtl_fm: general purpose analogue demodulator
|
||||
(narrow band FM, wide band FM, AM and SSB)
|
||||
rtl_tcp: provides a network server for remote access to an SDR
|
||||
|
@ -1,5 +1,6 @@
|
||||
@comment $OpenBSD: PLIST,v 1.1.1.1 2013/04/21 11:45:08 sthen Exp $
|
||||
@comment $OpenBSD: PLIST,v 1.2 2013/04/23 14:50:19 sthen Exp $
|
||||
@bin bin/rtl_eeprom
|
||||
@bin bin/rtl_fm
|
||||
@bin bin/rtl_sdr
|
||||
@bin bin/rtl_test
|
||||
include/rtl-sdr.h
|
||||
|
Loading…
Reference in New Issue
Block a user