mirror of
https://github.com/smittix/intercept.git
synced 2026-07-22 08:18:09 -07:00
Add device reservation to DMR mode and improve USB busy error message
DMR was missing checkDeviceAvailability/reserveDevice/releaseDevice calls that other modes (SSTV, listening post) use, so the device dropdown showed device 0 as available even when another process held it. Also detect USB claim errors from rtl_fm and surface a clear message telling the user to pick a different device. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+7
-4
@@ -334,11 +334,14 @@ def start_dmr() -> Response:
|
|||||||
if dmr_active_device is not None:
|
if dmr_active_device is not None:
|
||||||
app_module.release_sdr_device(dmr_active_device)
|
app_module.release_sdr_device(dmr_active_device)
|
||||||
dmr_active_device = None
|
dmr_active_device = None
|
||||||
# Surface the most relevant error to the user
|
# Surface a clear error to the user
|
||||||
detail = rtl_err.strip() or dsd_err.strip()
|
detail = rtl_err.strip() or dsd_err.strip()
|
||||||
msg = 'Failed to start DSD pipeline'
|
if 'usb_claim_interface' in rtl_err or 'Failed to open' in rtl_err:
|
||||||
if detail:
|
msg = f'SDR device {device} is busy — it may be in use by another mode or process. Try a different device.'
|
||||||
msg += f': {detail}'
|
elif detail:
|
||||||
|
msg = f'Failed to start DSD pipeline: {detail}'
|
||||||
|
else:
|
||||||
|
msg = 'Failed to start DSD pipeline'
|
||||||
return jsonify({'status': 'error', 'message': msg}), 500
|
return jsonify({'status': 'error', 'message': msg}), 500
|
||||||
|
|
||||||
# Drain rtl_fm stderr in background to prevent pipe blocking
|
# Drain rtl_fm stderr in background to prevent pipe blocking
|
||||||
|
|||||||
@@ -59,6 +59,11 @@ function startDmr() {
|
|||||||
const gain = parseInt(document.getElementById('dmrGain')?.value || 40);
|
const gain = parseInt(document.getElementById('dmrGain')?.value || 40);
|
||||||
const device = typeof getSelectedDevice === 'function' ? getSelectedDevice() : 0;
|
const device = typeof getSelectedDevice === 'function' ? getSelectedDevice() : 0;
|
||||||
|
|
||||||
|
// Check device availability before starting
|
||||||
|
if (typeof checkDeviceAvailability === 'function' && !checkDeviceAvailability('dmr')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
fetch('/dmr/start', {
|
fetch('/dmr/start', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
@@ -80,6 +85,9 @@ function startDmr() {
|
|||||||
updateDmrSynthStatus();
|
updateDmrSynthStatus();
|
||||||
const statusEl = document.getElementById('dmrStatus');
|
const statusEl = document.getElementById('dmrStatus');
|
||||||
if (statusEl) statusEl.textContent = 'DECODING';
|
if (statusEl) statusEl.textContent = 'DECODING';
|
||||||
|
if (typeof reserveDevice === 'function') {
|
||||||
|
reserveDevice(parseInt(device), 'dmr');
|
||||||
|
}
|
||||||
if (typeof showNotification === 'function') {
|
if (typeof showNotification === 'function') {
|
||||||
showNotification('DMR', `Decoding ${frequency} MHz (${protocol.toUpperCase()})`);
|
showNotification('DMR', `Decoding ${frequency} MHz (${protocol.toUpperCase()})`);
|
||||||
}
|
}
|
||||||
@@ -104,6 +112,9 @@ function stopDmr() {
|
|||||||
updateDmrSynthStatus();
|
updateDmrSynthStatus();
|
||||||
const statusEl = document.getElementById('dmrStatus');
|
const statusEl = document.getElementById('dmrStatus');
|
||||||
if (statusEl) statusEl.textContent = 'STOPPED';
|
if (statusEl) statusEl.textContent = 'STOPPED';
|
||||||
|
if (typeof releaseDevice === 'function') {
|
||||||
|
releaseDevice('dmr');
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(err => console.error('[DMR] Stop error:', err));
|
.catch(err => console.error('[DMR] Stop error:', err));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user