-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
2,108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
src/waveform_*.wav | ||
src/pydemod | ||
src/test | ||
*.o | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
CC = gcc | ||
STD_CFLAGS = -Wall -std=gnu99 -c -g -O3 | ||
|
||
# Enable ARM-specific options only on ARM, and compilation of the app only on ARM | ||
UNAME := $(shell uname -m) | ||
|
||
# Determine the hardware platform. Below, pi1 stands for the RaspberryPi 1 (the original one), | ||
# and pi2 stands for both the RaspberryPi 2 and 3. | ||
ifeq ($(UNAME), armv6l) | ||
CFLAGS = $(STD_CFLAGS) -march=armv6 -mtune=arm1176jzf-s -mfloat-abi=hard -mfpu=vfp -ffast-math -DRASPI=1 | ||
TARGET = pi1 | ||
else ifeq ($(UNAME), armv7l) | ||
CFLAGS = $(STD_CFLAGS) -march=armv7-a -mtune=arm1176jzf-s -mfloat-abi=hard -mfpu=vfp -ffast-math -DRASPI=2 | ||
TARGET = pi2 | ||
else | ||
CFLAGS = $(STD_CFLAGS) | ||
TARGET = other | ||
endif | ||
|
||
ifneq ($(TARGET), other) | ||
|
||
app: rds.o waveforms.o pi_fm_adv.o fm_mpx.o control_pipe.o mailbox.o | ||
$(CC) -o pi_fm_adv rds.o waveforms.o mailbox.o pi_fm_adv.o fm_mpx.o control_pipe.o -lm -lsndfile | ||
|
||
endif | ||
|
||
|
||
rds_wav: rds.o waveforms.o rds_wav.o fm_mpx.o | ||
$(CC) -o rds_wav rds_wav.o rds.o waveforms.o fm_mpx.o -lm -lsndfile | ||
|
||
rds.o: rds.c waveforms.h | ||
$(CC) $(CFLAGS) rds.c | ||
|
||
control_pipe.o: control_pipe.c control_pipe.h rds.h | ||
$(CC) $(CFLAGS) control_pipe.c | ||
|
||
waveforms.o: waveforms.c waveforms.h | ||
$(CC) $(CFLAGS) waveforms.c | ||
|
||
mailbox.o: mailbox.c mailbox.h | ||
$(CC) $(CFLAGS) mailbox.c | ||
|
||
pi_fm_rds.o: pi_fm_adv.c control_pipe.h fm_mpx.h rds.h mailbox.h | ||
$(CC) $(CFLAGS) pi_fm_adv.c | ||
|
||
rds_wav.o: rds_wav.c | ||
$(CC) $(CFLAGS) rds_wav.c | ||
|
||
fm_mpx.o: fm_mpx.c fm_mpx.h | ||
$(CC) $(CFLAGS) fm_mpx.c | ||
|
||
clean: | ||
rm -f *.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
/* | ||
PiFmAdv - FM/RDS transmitter for the Raspberry Pi | ||
Copyright (C) 2017 Miegl | ||
See https://github.com/Miegl/PiFmAdv | ||
rds_wav.c is a test program that writes a RDS baseband signal to a WAV | ||
file. It requires libsndfile. | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <fcntl.h> | ||
#include <stdio.h> | ||
#include <unistd.h> | ||
#include <errno.h> | ||
|
||
#include "rds.h" | ||
#include "control_pipe.h" | ||
|
||
#define CTL_BUFFER_SIZE 100 | ||
|
||
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 fd = open(filename, O_RDONLY | O_NONBLOCK); | ||
if(fd == -1) return -1; | ||
|
||
int flags; | ||
flags = fcntl(fd, F_GETFL, 0); | ||
flags |= O_NONBLOCK; | ||
if( fcntl(fd, F_SETFL, flags) == -1 ) return -1; | ||
|
||
f_ctl = fdopen(fd, "r"); | ||
if(f_ctl == NULL) return -1; | ||
|
||
return 0; | ||
} | ||
|
||
|
||
/* | ||
* Polls the control file (pipe), non-blockingly, and if a command is received, | ||
* processes it and updates the RDS data. | ||
*/ | ||
int poll_control_pipe() { | ||
static char buf[CTL_BUFFER_SIZE]; | ||
|
||
char *res = fgets(buf, CTL_BUFFER_SIZE, f_ctl); | ||
if(res == NULL) return -1; | ||
if(strlen(res) > 3 && res[2] == ' ') { | ||
char *arg = res+3; | ||
if(arg[strlen(arg)-1] == '\n') arg[strlen(arg)-1] = 0; | ||
if(res[0] == 'P' && res[1] == 'S') { | ||
arg[8] = 0; | ||
set_rds_ps(arg); | ||
printf("PS set to: \"%s\"\n", arg); | ||
return CONTROL_PIPE_PS_SET; | ||
} | ||
if(res[0] == 'R' && res[1] == 'T') { | ||
arg[64] = 0; | ||
set_rds_rt(arg); | ||
printf("RT set to: \"%s\"\n", arg); | ||
return CONTROL_PIPE_RT_SET; | ||
} | ||
if(res[0] == 'T' && res[1] == 'A') { | ||
int ta = ( strcmp(arg, "ON") == 0 ); | ||
set_rds_ta(ta); | ||
printf("Set TA to "); | ||
if(ta) printf("ON\n"); else printf("OFF\n"); | ||
return CONTROL_PIPE_TA_SET; | ||
} | ||
} | ||
|
||
if(strlen(res) > 4 && res[3] == ' ') { | ||
char *arg = res+4; | ||
if(arg[strlen(arg)-1] == '\n') arg[strlen(arg)-1] = 0; | ||
if(res[0] == 'P' && res[1] == 'T' && res[2] == 'Y') { | ||
int pty = atoi(arg); | ||
if (pty >= 0 && pty <= 31) { | ||
set_rds_pty(pty); | ||
if (pty == 0) { | ||
printf("PTY disabled\n"); | ||
} | ||
else { | ||
printf("PTY set to: %i\n", pty); | ||
} | ||
} | ||
else { | ||
printf("Wrong PTY code! The PTY code range is 0 - 31.\n"); | ||
} | ||
return CONTROL_PIPE_PTY_SET; | ||
} | ||
} | ||
|
||
return -1; | ||
} | ||
|
||
/* | ||
* Closes the control pipe. | ||
*/ | ||
int close_control_pipe() { | ||
if(f_ctl) return fclose(f_ctl); | ||
else return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
PiFmAdv - FM/RDS transmitter for the Raspberry Pi | ||
Copyright (C) 2017 Miegl | ||
See https://github.com/Miegl/PiFmAdv | ||
rds_wav.c is a test program that writes a RDS baseband signal to a WAV | ||
file. It requires libsndfile. | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
|
||
#define CONTROL_PIPE_PS_SET 1 | ||
#define CONTROL_PIPE_RT_SET 2 | ||
#define CONTROL_PIPE_TA_SET 3 | ||
#define CONTROL_PIPE_PTY_SET 4 | ||
|
||
extern int open_control_pipe(char *filename); | ||
extern int close_control_pipe(); | ||
extern int poll_control_pipe(); |
Oops, something went wrong.