DMR: Fix forced refresh items; #339

P25: Tweak Tait Talker Alias 7-bit to check for ASCII values >= 0x20;

RTL: Tweaks to RMS;
This commit is contained in:
lwvmobile
2026-02-27 14:44:40 -05:00
parent b7cd501cc1
commit f6f5f80361
3 changed files with 33 additions and 31 deletions

View File

@@ -702,8 +702,8 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
} }
else if (state->payload_algid == 0x02) else if (state->payload_algid == 0x02)
{ {
hytera_enhanced_alg_refresh(state);
state->currentslot = 0; state->currentslot = 0;
hytera_enhanced_alg_refresh(state);
dmr_alg_refresh (opts, state); dmr_alg_refresh (opts, state);
} }
if (state->payload_algidR >= 0x21) if (state->payload_algidR >= 0x21)
@@ -713,8 +713,8 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
} }
else if (state->payload_algidR == 0x02) else if (state->payload_algidR == 0x02)
{ {
hytera_enhanced_alg_refresh(state);
state->currentslot = 1; state->currentslot = 1;
hytera_enhanced_alg_refresh(state);
dmr_alg_refresh (opts, state); dmr_alg_refresh (opts, state);
} }
@@ -1069,10 +1069,10 @@ void dmrBSBootstrap (dsd_opts * opts, dsd_state * state)
state->currentslot = 1; state->currentslot = 1;
dmr_alg_refresh (opts, state); dmr_alg_refresh (opts, state);
} }
else if (state->payload_algid == 0x02) else if (state->payload_algidR == 0x02)
{ {
hytera_enhanced_alg_refresh(state);
state->currentslot = 1; state->currentslot = 1;
hytera_enhanced_alg_refresh(state);
dmr_alg_refresh (opts, state); dmr_alg_refresh (opts, state);
} }

View File

@@ -581,11 +581,15 @@ void tait_iso7_embedded_alias_decode (dsd_opts * opts, dsd_state * state, uint8_
for (uint8_t i = 0; i < len; i++) for (uint8_t i = 0; i < len; i++)
{ {
alias[i] = (uint8_t)ConvertBitIntoBytes(&input[16+(i*7)], 7); alias[i] = (uint8_t)ConvertBitIntoBytes(&input[16+(i*7)], 7);
fprintf (stderr, "%c", alias[i]);
// fprintf (stderr, "%X,", alias[i]); //debug
if (alias[i] == 0x2C) //change a comma to a dot if (alias[i] == 0x2C) //change a comma to a dot
alias[i] = 0x2E; alias[i] = 0x2E;
else if (alias[i] < 0x20) //change any garble / control chars to a space else if (alias[i] < 0x20) //change any garble / control chars to a space
alias[i] = 0x20; alias[i] = 0x20;
fprintf (stderr, "%c", alias[i]);
} }
//flag to indicate this already exists in import or group struct //flag to indicate this already exists in import or group struct

View File

@@ -465,27 +465,27 @@ void dc_block_filter(struct demod_state *fm)
} }
long int rms(int16_t *samples, int len, int step) long int rms(int16_t *samples, int len, int step)
/* largely lifted from rtl_power */
{ {
int i; int i;
long int rms; long int rms_val;
long p, t, s; int64_t p = 0, t = 0;
double dc, err; int64_t s;
p = t = 0L;
for (i = 0; i < len; i += step) { for (i = 0; i < len; i += step) {
s = (long)samples[i]; s = samples[i];
t += s; t += s;
p += s * s; p += s * s;
} }
/* correct for dc offset in squares */
dc = (double)(t*step) / (double)len;
err = t * 2 * dc - dc * dc * len;
rms = (long int)sqrt((p-err) / len); double dc = (double)(t * (int64_t)step) / (double)len;
//going with a value that's easy to figure out when its done the thing double err = (double)t * 2.0 * dc - dc * dc * (double)len;
if (rms < 0){ rms = 999; }
return rms; double val = ((double)p - err) / (double)len;
if (val < 0.0) val = 0.0;
rms_val = (long int)sqrt(val);
if (rms_val < 0) rms_val = 999;
return rms_val;
} }
void full_demod(struct demod_state *d) void full_demod(struct demod_state *d)
@@ -1214,20 +1214,18 @@ void rtl_dev_tune(dsd_opts * opts, long int frequency)
} }
//return RMS value (root means square) power level -- used as soft squelch inside of framesync static long int prev_rms = 0;
long int rtl_return_rms() long int rtl_return_rms()
{ {
long int sr = 0;
// #ifdef __arm__ long int sr = rms(demod.lowpassed, 512, 1); //change 512 to 160 if using too much CPU
// sr = 100;
// #else // simple 4-block IIR average for stability
//debug -- on main machine, lp_len is around 6420, so this probably contributes to very high CPU usage sr = (prev_rms * 3 + sr) / 4;
// fprintf (stderr, "LP_LEN: %d \n", demod.lp_len); prev_rms = sr;
//I've found that just using a sample size of 160 will give us a good approximation without killing the CPU
// sr = rms(demod.lowpassed, demod.lp_len, 1); return sr;
sr = rms(demod.lowpassed, 160, 1); //I wonder what a reasonable value would be for #2 (input len) there
// #endif
return (sr);
} }
//simple function to clear the rtl sample queue when tuning and during other events (ncurses menu open/close) //simple function to clear the rtl sample queue when tuning and during other events (ncurses menu open/close)