From cc8b97ca791b74c64d04aafbe9346c2a05bd8601 Mon Sep 17 00:00:00 2001 From: Kuba <132459354+KubaPro010@users.noreply.github.com> Date: Mon, 30 Oct 2023 19:35:23 +0000 Subject: [PATCH] trying somthing --- src/pifmrds/control_pipe.c | 12 ++++++++---- src/pifmrds/control_pipe.h | 7 ++++++- src/pifmrds/pi_fm_rds.cpp | 14 ++++++++++++-- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/pifmrds/control_pipe.c b/src/pifmrds/control_pipe.c index 9653f30..8cb1f7d 100644 --- a/src/pifmrds/control_pipe.c +++ b/src/pifmrds/control_pipe.c @@ -47,18 +47,21 @@ int open_control_pipe(char *filename, volatile uint32_t *padreg) * Polls the control file (pipe), non-blockingly, and if a command is received, * processes it and updates the RDS data. */ -int poll_control_pipe() { +ResultAndArg poll_control_pipe() { + ResultAndArg resarg; int res = -1; static char buf[CTL_BUFFER_SIZE]; char *fifo = fgets(buf, CTL_BUFFER_SIZE, f_ctl); if(fifo == NULL) { - return res; + resarg.res = -1; + return resarg; } if(strlen(fifo) > 3 && fifo[2] == ' ') { char *arg = fifo+3; + resarg.arg = arg; if(arg[strlen(arg)-1] == '\n') arg[strlen(arg)-1] = 0; if(fifo[0] == 'P' && fifo[1] == 'S') { arg[8] = 0; @@ -109,6 +112,7 @@ int poll_control_pipe() { } } else if(strlen(fifo) > 4 && fifo[3] == ' ') { char *arg = fifo+4; + resarg.arg = arg; if(arg[strlen(arg)-1] == '\n') arg[strlen(arg)-1] = 0; if(fifo[0] == 'P' && fifo[1] == 'T' && fifo[2] == 'Y') { int pty = atoi(arg); @@ -138,8 +142,8 @@ int poll_control_pipe() { res = CONTROL_PIPE_RT_SET; } } - - return res; + resarg.res = res; + return resarg; } int close_control_pipe() { diff --git a/src/pifmrds/control_pipe.h b/src/pifmrds/control_pipe.h index 51e5345..4f0562b 100644 --- a/src/pifmrds/control_pipe.h +++ b/src/pifmrds/control_pipe.h @@ -15,6 +15,11 @@ #define CONTROL_PIPE_PI_SET 8 #define CONTROL_PIPE_PWR_SET 9 +typedef struct { + int res; + char arg[70]; +} ResultAndArg; + extern int open_control_pipe(char *filename, volatile uint32_t *padreg); extern int close_control_pipe(); -extern int poll_control_pipe(); +extern ResultAndArg poll_control_pipe(); diff --git a/src/pifmrds/pi_fm_rds.cpp b/src/pifmrds/pi_fm_rds.cpp index efc558a..6cb9971 100644 --- a/src/pifmrds/pi_fm_rds.cpp +++ b/src/pifmrds/pi_fm_rds.cpp @@ -183,8 +183,11 @@ int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt, } } - if(control_pipe && poll_control_pipe() == CONTROL_PIPE_PS_SET) { - varying_ps = 0; + if(control_pipe) { + ResultAndArg pollResult = poll_control_pipe(); + if(pollResult.res == CONTROL_PIPE_PS_SET) { + varying_ps = 0; + } } if( fm_mpx_get_samples(data, drds, compressor_decay, compressor_attack, compressor_max_gain_recip) < 0 ) { @@ -226,6 +229,7 @@ int main(int argc, char **argv) { float gain = 1; int rawSampleRate = 44100; int rawChannels = 2; + int compressorchanges = 0; double preemp = 50e-6; //eu int deviation = 75000; int alternative_freq[100] = {}; @@ -260,12 +264,15 @@ int main(int argc, char **argv) { } else if(strcmp("-compressordecay", arg)==0 && param != NULL) { i++; compressor_decay = atof(param); + compressorchanges = 1; } else if(strcmp("-compressorattack", arg)==0 && param != NULL) { i++; compressor_attack = atof(param); + compressorchanges = 1; } else if(strcmp("-compressormaxgainrecip", arg)==0 && param != NULL) { i++; compressor_max_gain_recip = atof(param); + compressorchanges = 1; } else if(strcmp("-pty", arg)==0 && param != NULL) { i++; pty = atoi(param); @@ -345,6 +352,9 @@ int main(int argc, char **argv) { " [-ps ps_text] [-rt rt_text] [-ctl control_pipe] [-pty program_type] [-raw play raw audio from stdin] [-disablerds] [-af alt freq] [-preemphasis us] [-rawchannels when using the raw option you can change this] [-rawsamplerate same business] [-deviation the deviation, default is 75000, there are 2 predefined other cases: ukf (for old radios such as the UNITRA Jowita), nfm] [-tp] [-ta]\n", arg); } } + if(compressorchanges) { + printf("You've changed the compressor settings, just don't set it too low, so the deviation won't go crazy\n"); + } alternative_freq[0] = af_size; int FifoSize=DATA_SIZE*2; fmmod=new ngfmdmasync(carrier_freq,228000,14,FifoSize, false, gpiopin);