Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Continue processing data when SDR is unplugged and re-plugged in #2

Open
jiangyi1985 opened this issue Oct 14, 2020 · 4 comments
Open
Assignees
Labels
question Further information is requested

Comments

@jiangyi1985
Copy link

jiangyi1985 commented Oct 14, 2020

When usb is unplugged and re-plugged in, or if there's a bad usb connection, the program will stop processing data and remain idle. And I have to restart the service.
Is there a way to solve this?

@jiangyi1985 jiangyi1985 changed the title continue processing data when sdr is unplugged and re-plugged Continue processing data when SDR is unplugged and re-plugged in Oct 14, 2020
@sam210723
Copy link
Owner

Hi Ivan,

This is more of a limitation of the way USB works as devices are re-enumerated each time they are plugged in or power cycle.

You could setup some Linux services which have the Restart and RestartSec options set so the application will restart if it crashes when the USB device disconnects. Take a look at the Services section of the setup guide for more detail.

Sam.

@sam210723 sam210723 self-assigned this Feb 13, 2021
@sam210723 sam210723 added the question Further information is requested label Feb 13, 2021
@jiangyi1985
Copy link
Author

jiangyi1985 commented Feb 14, 2021

When the USB device disconnects, the service doesn't crash.

Feb 14 20:53:49 kali goesrecv[252377]: 2021-02-14T12:53:49Z [monitor] gain: 34.54, freq:  -124.6, omega: 18.750, vit(avg): 2092, rs(sum):    0, packets:  0, drops:  5
Feb 14 20:53:50 kali goesrecv[252377]: 2021-02-14T12:53:50Z [monitor] gain: 49.34, freq:   -21.5, omega: 18.750, vit(avg): 2081, rs(sum):    0, packets:  0, drops:  5
Feb 14 20:53:51 kali goesrecv[252377]: 2021-02-14T12:53:51Z [monitor] gain: 59.37, freq: -1266.3, omega: 18.750, vit(avg): 2088, rs(sum):    0, packets:  0, drops:  3
Feb 14 20:53:52 kali goesrecv[252377]: 2021-02-14T12:53:52Z [monitor] gain: 66.95, freq: -2333.2, omega: 18.750, vit(avg): 2085, rs(sum):    0, packets:  0, drops:  7
Feb 14 20:53:53 kali goesrecv[252377]: 2021-02-14T12:53:53Z [monitor] gain: 71.38, freq: -2227.2, omega: 18.750, vit(avg): 2083, rs(sum):    0, packets:  0, drops:  5
Feb 14 20:53:54 kali goesrecv[252377]: 2021-02-14T12:53:54Z [monitor] gain: 74.02, freq: -1871.4, omega: 18.750, vit(avg): 2093, rs(sum):    0, packets:  0, drops:  4
Feb 14 20:53:55 kali goesrecv[252377]: 2021-02-14T12:53:55Z [monitor] gain: 76.56, freq: -5412.1, omega: 18.750, vit(avg): 2084, rs(sum):    0, packets:  0, drops:  5
Feb 14 20:53:56 kali goesrecv[252377]: 2021-02-14T12:53:56Z [monitor] gain: 78.93, freq: -6645.5, omega: 18.750, vit(avg): 2095, rs(sum):    0, packets:  0, drops:  5
Feb 14 20:53:57 kali goesrecv[252377]: 2021-02-14T12:53:57Z [monitor] gain: 81.03, freq: -5471.1, omega: 18.750, vit(avg): 2086, rs(sum):    0, packets:  0, drops:  3
Feb 14 20:53:58 kali goesrecv[252377]: 2021-02-14T12:53:58Z [monitor] gain: 81.97, freq: -6902.1, omega: 18.750, vit(avg): 2086, rs(sum):    0, packets:  0, drops:  4
Feb 14 20:53:59 kali goesrecv[252377]: 2021-02-14T12:53:59Z [monitor] gain: 81.98, freq: -6142.0, omega: 18.750, vit(avg): 2091, rs(sum):    0, packets:  0, drops:  5
Feb 14 20:54:00 kali goesrecv[252377]: 2021-02-14T12:54:00Z [monitor] gain: 81.98, freq: -8111.8, omega: 18.750, vit(avg): 2097, rs(sum):    0, packets:  0, drops:  5
Feb 14 20:54:01 kali goesrecv[252377]: 2021-02-14T12:54:01Z [monitor] gain: 81.98, freq: -8817.7, omega: 18.751, vit(avg): 2091, rs(sum):    0, packets:  0, drops:  6
Feb 14 20:54:01 kali goesrecv[252377]: cb transfer status: 5, canceling...
Feb 14 20:54:01 kali goesrecv[252377]: cb transfer status: 5, canceling...
Feb 14 20:54:01 kali goesrecv[252377]: cb transfer status: 5, canceling...
Feb 14 20:54:01 kali goesrecv[252377]: cb transfer status: 5, canceling...
Feb 14 20:54:01 kali goesrecv[252377]: cb transfer status: 5, canceling...
Feb 14 20:54:01 kali goesrecv[252377]: cb transfer status: 5, canceling...
Feb 14 20:54:02 kali goesrecv[252377]: 2021-02-14T12:54:02Z [monitor] gain: 81.98, freq: -9166.3, omega: 18.751, vit(avg): 2096, rs(sum):    0, packets:  0, drops:  3
Feb 14 20:54:03 kali goesrecv[252377]: 2021-02-14T12:54:03Z [monitor] gain:  0.00, freq:     0.0, omega: 0.000, vit(avg):    0, rs(sum):    0, packets:  0, drops:  0
Feb 14 20:54:04 kali goesrecv[252377]: 2021-02-14T12:54:04Z [monitor] gain:  0.00, freq:     0.0, omega: 0.000, vit(avg):    0, rs(sum):    0, packets:  0, drops:  0
Feb 14 20:54:05 kali goesrecv[252377]: 2021-02-14T12:54:05Z [monitor] gain:  0.00, freq:     0.0, omega: 0.000, vit(avg):    0, rs(sum):    0, packets:  0, drops:  0
Feb 14 20:54:06 kali goesrecv[252377]: 2021-02-14T12:54:06Z [monitor] gain:  0.00, freq:     0.0, omega: 0.000, vit(avg):    0, rs(sum):    0, packets:  0, drops:  0
Feb 14 20:54:07 kali goesrecv[252377]: 2021-02-14T12:54:07Z [monitor] gain:  0.00, freq:     0.0, omega: 0.000, vit(avg):    0, rs(sum):    0, packets:  0, drops:  0
//
//USB device re-connected at this point
//
Feb 14 20:54:08 kali goesrecv[252377]: 2021-02-14T12:54:08Z [monitor] gain:  0.00, freq:     0.0, omega: 0.000, vit(avg):    0, rs(sum):    0, packets:  0, drops:  0
Feb 14 20:54:09 kali goesrecv[252377]: 2021-02-14T12:54:09Z [monitor] gain:  0.00, freq:     0.0, omega: 0.000, vit(avg):    0, rs(sum):    0, packets:  0, drops:  0
Feb 14 20:54:10 kali goesrecv[252377]: 2021-02-14T12:54:10Z [monitor] gain:  0.00, freq:     0.0, omega: 0.000, vit(avg):    0, rs(sum):    0, packets:  0, drops:  0
Feb 14 20:54:11 kali goesrecv[252377]: 2021-02-14T12:54:11Z [monitor] gain:  0.00, freq:     0.0, omega: 0.000, vit(avg):    0, rs(sum):    0, packets:  0, drops:  0
Feb 14 20:54:12 kali goesrecv[252377]: 2021-02-14T12:54:12Z [monitor] gain:  0.00, freq:     0.0, omega: 0.000, vit(avg):    0, rs(sum):    0, packets:  0, drops:  0
Feb 14 20:54:13 kali goesrecv[252377]: 2021-02-14T12:54:13Z [monitor] gain:  0.00, freq:     0.0, omega: 0.000, vit(avg):    0, rs(sum):    0, packets:  0, drops:  0
Feb 14 20:54:14 kali goesrecv[252377]: 2021-02-14T12:54:14Z [monitor] gain:  0.00, freq:     0.0, omega: 0.000, vit(avg):    0, rs(sum):    0, packets:  0, drops:  0
Feb 14 20:54:15 kali goesrecv[252377]: 2021-02-14T12:54:15Z [monitor] gain:  0.00, freq:     0.0, omega: 0.000, vit(avg):    0, rs(sum):    0, packets:  0, drops:  0
Feb 14 20:54:16 kali goesrecv[252377]: 2021-02-14T12:54:16Z [monitor] gain:  0.00, freq:     0.0, omega: 0.000, vit(avg):    0, rs(sum):    0, packets:  0, drops:  0

And when the USB device reconnects, it doesn't do anything. There will be no data.

I guess what I need to do is to change the code and make the program crash whenever the USB device disconnects, so that systemctl can then restart it?

Which lines of code should I change?

@sam210723
Copy link
Owner

Hi Ivan,

It seems the source queue used in the main loop of demodulator.cc is not closing correctly when the device is unplugged. I'll do some testing of this so it cleanly exits with an error code when no more samples are being received from the device.

Are you using an Airspy or RTL-SDR?

@jiangyi1985
Copy link
Author

Hi Sam,

I’m using RTL-SDR

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants