diff --git a/silent_1-second.wav b/silent_1-second.wav new file mode 100644 index 0000000..3ab8fb9 Binary files /dev/null and b/silent_1-second.wav differ diff --git a/src/pifmrds/control_pipe.c b/src/pifmrds/control_pipe.c index 866ad4e..4a1b1bf 100644 --- a/src/pifmrds/control_pipe.c +++ b/src/pifmrds/control_pipe.c @@ -7,7 +7,6 @@ #include #include -#include #include #include #include @@ -16,6 +15,10 @@ #include "control_pipe.h" #define CTL_BUFFER_SIZE 70 +#define GPIO_PAD_0_27 (0x2C/4) +#define GPIO_PAD_28_45 (0x30/4) + +static volatile uint32_t *pad_reg; int fd; FILE *f_ctl; @@ -23,7 +26,9 @@ FILE *f_ctl; /* * Opens a file (pipe) to be used to control the RDS coder, in non-blocking mode. */ -int open_control_pipe(char *filename) { +int open_control_pipe(char *filename, volatile uint32_t *padreg) +{ + pad_reg = padreg; fd = open(filename, O_RDWR | O_NONBLOCK); if(fd == -1) return -1; @@ -37,7 +42,20 @@ int open_control_pipe(char *filename) { return 0; } - +//for bad rds, as most rds decoders won't decode these +void removeDiacritics(char *str) { + char diacritics[] = "ąćęłńóśźżĄĆĘŁŃÓŚŹŻ"; + char replacements[] = "acelnoszzACELNOSZZ"; + + for (size_t i = 0; i < strlen(str); i++) { + for (size_t j = 0; j < strlen(diacritics); j++) { + if (str[i] == diacritics[j]) { + str[i] = replacements[j]; + break; + } + } + } +} /* * Polls the control file (pipe), non-blockingly, and if a command is received, @@ -119,6 +137,18 @@ int poll_control_pipe() { printf("Wrong PTY identifier! The PTY range is 0 - 31.\n"); } res = CONTROL_PIPE_PTY_SET; + } else if(fifo[0] == 'U' && fifo[1] == 'R' && fifo[2] == 'T') { + arg[64] = 0; + removeDiacritics(arg); + set_rds_rt(arg); + printf("RT set to: \"%s\"\n", arg); + res = CONTROL_PIPE_RT_SET; + } else if(fifo[0] == 'P' && fifo[1] == 'W' && fifo[2] == 'R') { + arg[1] = 0; + pad_reg[GPIO_PAD_0_27] = 0x5a000018 + atoi(arg); + pad_reg[GPIO_PAD_28_45] = 0x5a000018 + atoi(arg); + printf("POWER set to: \"%s\"\n", arg); + res = CONTROL_PIPE_PWR_SET; } } @@ -129,4 +159,4 @@ int close_control_pipe() { if(f_ctl) fclose(f_ctl); if(fd) return close(fd); else return 0; -} +} \ No newline at end of file diff --git a/src/pifmrds/control_pipe.h b/src/pifmrds/control_pipe.h index 6d1fd37..51e5345 100644 --- a/src/pifmrds/control_pipe.h +++ b/src/pifmrds/control_pipe.h @@ -4,7 +4,7 @@ See https://github.com/Miegl/PiFmAdv */ - +#include #define CONTROL_PIPE_PS_SET 1 #define CONTROL_PIPE_RT_SET 2 #define CONTROL_PIPE_TA_SET 3 @@ -13,7 +13,8 @@ #define CONTROL_PIPE_MS_SET 6 #define CONTROL_PIPE_AB_SET 7 #define CONTROL_PIPE_PI_SET 8 +#define CONTROL_PIPE_PWR_SET 9 -extern int open_control_pipe(char *filename); +extern int open_control_pipe(char *filename, volatile uint32_t *padreg); extern int close_control_pipe(); extern int poll_control_pipe(); diff --git a/src/pifmrds/fm_mpx.c b/src/pifmrds/fm_mpx.c index fd30251..9bc58b2 100644 --- a/src/pifmrds/fm_mpx.c +++ b/src/pifmrds/fm_mpx.c @@ -328,7 +328,7 @@ int fm_mpx_get_samples(float *mpx_buffer, int drds) { else { mpx_buffer[i] = - mpx_buffer[i] + // RDS data samples are currently in mpx_buffer :to be Remove in NBFM + mpx_buffer[i] + // RDS data samples are currently in mpx_buffer :to be Remove in NFM 9.0*out_left; // Unmodulated monophonic signal } diff --git a/src/pifmrds/pi_fm_rds.cpp b/src/pifmrds/pi_fm_rds.cpp index e326861..8ec2ef9 100644 --- a/src/pifmrds/pi_fm_rds.cpp +++ b/src/pifmrds/pi_fm_rds.cpp @@ -118,7 +118,7 @@ int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt, set_rds_rt(rt); set_rds_pty(pty); set_rds_ab(0); - set_rds_ms(0); + set_rds_ms(1); set_rds_tp(0); set_rds_ta(0); uint16_t count = 0; @@ -149,7 +149,7 @@ int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt, // Initialize the control pipe reader if(control_pipe) { - if(open_control_pipe(control_pipe) == 0) { + if(open_control_pipe(control_pipe, pad_reg) == 0) { printf("Reading control commands on %s.\n", control_pipe); } else { printf("Failed to open control pipe: %s.\n", control_pipe); @@ -301,7 +301,7 @@ int main(int argc, char **argv) { } else if(strcmp("-af", arg)==0 && param != NULL) { i++; af_size++; - alternative_freq[af_size] = (int)(10*atof(optarg))-875; + alternative_freq[af_size] = (int)(10*atof(param))-875; if(alternative_freq[af_size] < 1 || alternative_freq[af_size] > 204) fatal("Alternative Frequency has to be set in range of 87.6 Mhz - 107.9 Mhz\n"); //honestly i have no idea why 87.5 and 108 isn't in here, i copied this code, okay? }