0
1
mirror of https://github.com/radio95-rnt/rds95.git synced 2026-02-27 12:53:53 +01:00

refactor RDS modulator parameters and file handling; remove deprecated commands

This commit is contained in:
2025-03-15 19:33:11 +01:00
parent 0cd72a503a
commit 222d5c7fa9
12 changed files with 219 additions and 254 deletions

View File

@@ -7,40 +7,29 @@
static int fd;
static struct pollfd poller;
/*
* Opens a file (pipe) to be used to control the RDS coder.
*/
int open_control_pipe(char *filename) {
fd = open(filename, O_RDONLY | O_NONBLOCK);
if (fd == -1) return -1;
/* setup the poller */
poller.fd = fd;
poller.events = POLLIN;
return 0;
}
/*
* Polls the control file (pipe), and if a command is received,
* calls process_ascii_cmd.
*/
void poll_control_pipe(RDSModulator* mod) {
static unsigned char pipe_buf[CTL_BUFFER_SIZE];
static unsigned char cmd_buf[CMD_BUFFER_SIZE];
int bytes_read;
char *token;
/* check for new commands - return early if none */
if (poll(&poller, 1, READ_TIMEOUT_MS) <= 0) return;
if (!(poller.revents & POLLIN)) return;
/* read data from pipe */
memset(pipe_buf, 0, CTL_BUFFER_SIZE);
bytes_read = read(fd, pipe_buf, CTL_BUFFER_SIZE - 1);
if (bytes_read <= 0) return;
/* process each command line */
token = strtok((char *)pipe_buf, "\n");
while (token != NULL) {
size_t cmd_len = strlen(token);