Skip to content

Commit

Permalink
Fix mirisdr and add to docker builds (#462)
Browse files Browse the repository at this point in the history
* add installing libmirisdr-4 to both docker and CI builds
* fix warnings in input-mirisdr.cpp
  • Loading branch information
charlie-foxtrot authored Feb 5, 2024
1 parent 5b734c1 commit 5e5e46c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
10 changes: 10 additions & 0 deletions .github/install_dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ case "${unameOut}" in
librtlsdr-dev \
libsoapysdr-dev \
libpulse-dev

(
git clone https://github.com/f4exb/libmirisdr-4
cd libmirisdr-4
mkdir build
cd build
cmake ../
sudo make install
sudo ldconfig
)
;;

Darwin*)
Expand Down
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ RUN git clone https://github.com/rtlsdrblog/rtl-sdr-blog && \
dpkg -i librtlsdr-dev_*.deb && \
dpkg -i rtl-sdr_*.deb

# compile / install libmirisdr-4
RUN git clone https://github.com/f4exb/libmirisdr-4 && \
cd libmirisdr-4 && \
mkdir build && \
cd build && \
cmake ../ && \
VERBOSE=1 make install && \
ldconfig

# TODO: build anything from source?

Expand Down Expand Up @@ -90,6 +98,9 @@ RUN dpkg -i /tmp/librtlsdr0_*.deb && \
echo 'blacklist rtl2832' | tee --append /etc/modprobe.d/rtl_sdr.conf && \
echo 'blacklist rtl2830' | tee --append /etc/modprobe.d/rtl_sdr.conf

# install (from build container) libmirisdr-4
COPY --from=build /usr/local/lib/libmirisdr.so.4 /usr/local/lib/

# Copy rtl_airband from the build container
COPY LICENSE /opt/rtl_airband/
COPY --from=build /rtl_airband_build/build_dir/src/unittests /opt/rtl_airband/
Expand Down
14 changes: 8 additions & 6 deletions src/input-mirisdr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,12 @@ static bool mirisdr_nearest_gain(mirisdr_dev_t *dev, int target_gain, int *neare
}

static int mirisdr_find_device_by_serial(char const * const s) {
int device_count;
char vendor[256] = {0}, product[256] = {0}, serial[256] = {0};
device_count = mirisdr_get_device_count();
if(device_count < 1) {
int count = mirisdr_get_device_count();
if(count < 1) {
return -1;
}
for(int i = 0; i < device_count; i++) {
for(int i = 0; i < count; i++) {
mirisdr_get_device_usb_strings(i, vendor, product, serial);
if (strcmp(s, serial) != 0) {
continue;
Expand All @@ -102,8 +101,11 @@ int mirisdr_init(input_t * const input) {
error();
}

char transfer_str[] = "BULK";
char sample_format_str[] = "504_S8";

mirisdr_dev_t *miri = dev_data->dev;
int r = mirisdr_set_transfer(miri, (char *)"BULK");
int r = mirisdr_set_transfer(miri, transfer_str);
if (r < 0) {
log(LOG_ERR, "Failed to set bulk transfer mode for MiriSDR device #%d: error %d\n", dev_data->index, r);
error();
Expand Down Expand Up @@ -132,7 +134,7 @@ int mirisdr_init(input_t * const input) {
log(LOG_INFO, "Device #%d: gain set to %d dB\n", dev_data->index,
mirisdr_get_tuner_gain(miri));
}
r = mirisdr_set_sample_format(miri, (char *)"504_S8");
r = mirisdr_set_sample_format(miri, sample_format_str);
if (r < 0) {
log(LOG_ERR, "Failed to set sample format for device #%d: error %d\n", dev_data->index, r);
error();
Expand Down

0 comments on commit 5e5e46c

Please sign in to comment.