i did not expect that

This commit is contained in:
Kuba 2024-03-07 15:22:24 +01:00 committed by GitHub
parent 8a039fc2b4
commit e42bc40348
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 27 deletions

View File

@ -42,7 +42,7 @@ int open_control_pipe(char *filename)
* Polls the control file (pipe), non-blockingly, and if a command is received,
* processes it and updates the RDS data.
*/
ResultAndArg poll_control_pipe(bool log) {
ResultAndArg poll_control_pipe(int log) {
ResultAndArg resarg;
static char buf[CTL_BUFFER_SIZE];
@ -60,26 +60,26 @@ ResultAndArg poll_control_pipe(bool log) {
if(fifo[0] == 'P' && fifo[1] == 'S') {
arg[8] = 0;
set_rds_ps(arg);
if(log) printf("PS set to: \"%s\"\n", arg);
if(log==1) printf("PS set to: \"%s\"\n", arg);
resarg.res = CONTROL_PIPE_PS_SET;
}
else if(fifo[0] == 'R' && fifo[1] == 'T') {
arg[64] = 0;
set_rds_ab(0);
set_rds_rt(arg);
if(log) printf("RT A set to: \"%s\"\n", arg);
if(log==1) printf("RT A set to: \"%s\"\n", arg);
resarg.res = CONTROL_PIPE_RT_SET;
}
else if(fifo[0] == 'P' && fifo[1] == 'I') {
arg[4] = 0;
set_rds_pi((uint16_t) strtol(arg, NULL, 16));
if(log) printf("PI set to: \"%s\"\n", arg);
if(log==1) printf("PI set to: \"%s\"\n", arg);
resarg.res = CONTROL_PIPE_PI_SET;
}
else if(fifo[0] == 'T' && fifo[1] == 'A') {
int ta = ( strcmp(arg, "ON") == 0 );
set_rds_ta(ta);
if(log) {
if(log==1) {
printf("Set TA to ");
if(ta) printf("ON\n"); else printf("OFF\n");
}
@ -88,7 +88,7 @@ ResultAndArg poll_control_pipe(bool log) {
else if(fifo[0] == 'T' && fifo[1] == 'P') {
int tp = ( strcmp(arg, "ON") == 0 );
set_rds_tp(tp);
if(log) {
if(log==1) {
printf("Set TP to ");
if(tp) printf("ON\n"); else printf("OFF\n");
}
@ -97,7 +97,7 @@ ResultAndArg poll_control_pipe(bool log) {
else if(fifo[0] == 'M' && fifo[1] == 'S') {
int ms = ( strcmp(arg, "ON") == 0 );
set_rds_ms(ms);
if(log) {
if(log==1) {
printf("Set MS to ");
if(ms) printf("ON\n"); else printf("OFF\n");
}
@ -106,14 +106,14 @@ ResultAndArg poll_control_pipe(bool log) {
else if(fifo[0] == 'A' && fifo[1] == 'B') {
int ab = ( strcmp(arg, "ON") == 0 );
set_rds_ab(ab);
if(log) {
if(log==1) {
printf("Set AB to ");
if(ab) printf("ON\n"); else printf("OFF\n");
}
resarg.res = CONTROL_PIPE_AB_SET;
} else if(fifo[0] == 'C' && fifo[1] == 'T') {
int ct = ( strcmp(arg, "ON") == 0 );
if(log) {
if(log==1) {
printf("Set CT to ");
if(ct) printf("ON\n"); else printf("OFF\n");
}
@ -128,7 +128,7 @@ ResultAndArg poll_control_pipe(bool log) {
int pty = atoi(arg);
if (pty >= 0 && pty <= 31) {
set_rds_pty(pty);
if(log) {
if(log==1) {
if (!pty) {
printf("PTY disabled\n");
} else {
@ -143,24 +143,24 @@ ResultAndArg poll_control_pipe(bool log) {
} else if(fifo[0] == 'P' && fifo[1] == 'W' && fifo[2] == 'R') {
int power_level = atoi(arg);
resarg.arg_int = power_level;
if(log) printf("POWER set to: \"%s\"\n", arg);
if(log==1) printf("POWER set to: \"%s\"\n", arg);
resarg.res = CONTROL_PIPE_PWR_SET;
} else if(fifo[0] == 'R' && fifo[1] == 'T' && fifo[2] == 'B') {
arg[64] = 0;
set_rds_ab(1);
set_rds_rt(arg);
if(log) printf("RT B set to: \"%s\"\n", arg);
if(log==1) printf("RT B set to: \"%s\"\n", arg);
resarg.res = CONTROL_PIPE_RT_SET;
} else if(fifo[0] == 'R' && fifo[1] == 'D' && fifo[2] == 'S') {
int rds = ( strcmp(arg, "OFF") == 0 );
if(log) {
if(log==1) {
printf("Set RDS to ");
if(rds) printf("OFF\n"); else printf("ON\n");
}
resarg.res = CONTROL_PIPE_RDS_SET;
resarg.arg_int = rds;
} else if(fifo[0] == 'D' && fifo[1] == 'E' && fifo[2] == 'V') {
if(log) {
if(log==1) {
printf("Set Deviation to ");
printf(arg);
printf("\n");
@ -168,7 +168,7 @@ ResultAndArg poll_control_pipe(bool log) {
resarg.res = CONTROL_PIPE_DEVIATION_SET;
resarg.arg = arg;
} else if(fifo[0] == 'G' && fifo[1] == 'A' && fifo[2] == 'I') {
if(log) {
if(log==1) {
printf("Set Gain to ");
printf(arg);
printf("\n");
@ -177,14 +177,14 @@ ResultAndArg poll_control_pipe(bool log) {
resarg.arg = arg;
} else if(fifo[0] == 'S' && fifo[1] == 'T' && fifo[2] == 'R') {
int togg = ( strcmp(arg, "OFF") == 0 );
if(log) {
if(log==1) {
printf("Set Stereo Toggle to ");
if(!togg) printf("ON\n"); else printf("OFF\n");
}
resarg.res = CONTROL_PIPE_STEREO_SET;
resarg.arg_int = togg;
} else if(fifo[0] == 'C' && fifo[1] == 'O' && fifo[2] == 'D') {
if(log) {
if(log==1) {
printf("Set Compressor Decay to ");
printf(arg);
printf("\n");
@ -192,7 +192,7 @@ ResultAndArg poll_control_pipe(bool log) {
resarg.res = CONTROL_PIPE_COMPRESSORDECAY_SET;
resarg.arg = arg;
} else if(fifo[0] == 'C' && fifo[1] == 'O' && fifo[2] == 'A') {
if(log) {
if(log==1) {
printf("Set Compressor Attack to ");
printf(arg);
printf("\n");
@ -200,7 +200,7 @@ ResultAndArg poll_control_pipe(bool log) {
resarg.res = CONTROL_PIPE_COMPRESSORATTACK_SET;
resarg.arg = arg;
} else if(fifo[0] == 'R' && fifo[1] == 'D' && fifo[2] == 'V') {
if(log) {
if(log==1) {
printf("Set RDS Volume to ");
printf(arg);
printf("\n");
@ -209,14 +209,14 @@ ResultAndArg poll_control_pipe(bool log) {
resarg.arg = arg;
} else if(fifo[0] == 'P' && fifo[1] == 'A' && fifo[2] == 'U') {
int togg = ( strcmp(arg, "ON") == 0 );
if(log) {
if(log==1) {
printf("Set paused to ");
if(togg) printf("ON\n"); else printf("OFF\n");
}
resarg.res = CONTROL_PIPE_PAUSE_SET;
resarg.arg_int = togg;
} else if(fifo[0] == 'P' && fifo[1] == 'I' && fifo[2] == 'V') {
if(log) {
if(log==1) {
printf("Set Stereo Pilot Volume to ");
printf(arg);
printf("\n");
@ -225,7 +225,7 @@ ResultAndArg poll_control_pipe(bool log) {
resarg.arg = arg;
} else if(fifo[0] == 'M' && fifo[1] == 'P' && fifo[2] == 'X') {
int mpx = ( strcmp(arg, "ON") == 0 );
if(log) {
if(log==1) {
printf("Set Generate MPX to ");
if(mpx) printf("ON\n"); else printf("OFF\n");
}
@ -233,14 +233,14 @@ ResultAndArg poll_control_pipe(bool log) {
resarg.arg_int = mpx;
} else if(fifo[0] == 'C' && fifo[1] == 'O' && fifo[2] == 'M') {
int compressor = ( strcmp(arg, "ON") == 0 );
if(log) {
if(log==1) {
printf("Set Compressor to ");
if(compressor) printf("ON\n"); else printf("OFF\n");
}
resarg.res = CONTROL_PIPE_COMPRESSOR_SET;
resarg.arg_int = compressor; //bool is just a fancy work for 0 or 1, atleast here
} else if(fifo[0] == 'C' && fifo[1] == 'M' && fifo[2] == 'G') {
if(log) {
if(log==1) {
printf("Set Compressor Max Gain Recip to ");
printf(arg);
printf("\n");

View File

@ -36,4 +36,4 @@ typedef struct {
extern int open_control_pipe(char *filename);
extern int close_control_pipe();
extern ResultAndArg poll_control_pipe(bool log);
extern ResultAndArg poll_control_pipe(int log);

View File

@ -39,7 +39,7 @@ static void fatal(char *fmt, ...)
terminate(0);
}
int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt, char *control_pipe, int pty, int *af_array, int raw, int drds, double preemp, int power, int rawSampleRate, int rawChannels, int deviation, int ta, int tp, float cutoff_freq, float gaim, float compressor_decay, float compressor_attack, float compressor_max_gain_recip, int enablecompressor, int rds_ct_enabled, float rds_volume, float pilot_volume, int disablestereo, bool log) {
int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt, char *control_pipe, int pty, int *af_array, int raw, int drds, double preemp, int power, int rawSampleRate, int rawChannels, int deviation, int ta, int tp, float cutoff_freq, float gaim, float compressor_decay, float compressor_attack, float compressor_max_gain_recip, int enablecompressor, int rds_ct_enabled, float rds_volume, float pilot_volume, int disablestereo, int log) {
struct sigaction sa;
memset(&sa, 0, sizeof(sa));
sa.sa_handler = terminate;
@ -338,6 +338,6 @@ int main(int argc, char **argv) {
int FifoSize=DATA_SIZE*2;
//fmmod=new ngfmdmasync(carrier_freq,228000,14,FifoSize, false, gpiopin); //you can mod
fmmod=new ngfmdmasync(carrier_freq,228000,14,FifoSize, false);
int errcode = tx(carrier_freq, audio_file, pi, ps, rt, control_pipe, pty, alternative_freq, raw, drds, preemp, power, rawSampleRate, rawChannels, deviation, ta, tp, cutofffreq, gain, compressor_decay, compressor_attack, compressor_max_gain_recip, enable_compressor, ct, rds_volume, pilot_volume, dstereo, (log == 1 ? true : false));
int errcode = tx(carrier_freq, audio_file, pi, ps, rt, control_pipe, pty, alternative_freq, raw, drds, preemp, power, rawSampleRate, rawChannels, deviation, ta, tp, cutofffreq, gain, compressor_decay, compressor_attack, compressor_max_gain_recip, enable_compressor, ct, rds_volume, pilot_volume, dstereo, log);
terminate(errcode);
}