fm95 commit coming in a moment

This commit is contained in:
2026-07-11 22:40:28 +02:00
parent 898f1a846d
commit 4c1037be81
3 changed files with 29 additions and 0 deletions
+23
View File
@@ -27,6 +27,29 @@ void ipc_close(IPC_Client *client) {
client->fd = -1;
}
int ipc_send_streams(IPC_Client *client, uint8_t streams) {
if (client->fd < 0) return -1;
uint8_t msg[2];
msg[0] = 113;
msg[1] = streams;
ssize_t sent = send(client->fd, msg, sizeof(msg), 0);
if (sent != (ssize_t)sizeof(msg)) {
fprintf(stderr, "fm95 ipc: short/failed send\n");
return -1;
}
uint8_t reply;
if (recv(client->fd, &reply, 1, 0) <= 0) {
fprintf(stderr, "fm95 ipc: no reply / disconnected\n");
return -1;
}
if (reply == 1) fprintf(stderr, "fm95 rejected message (unknown opcode?)\n");
return 0;
}
// Pulls one group's worth of bits (BITS_PER_GROUP), differentially encodes,
// packs 8-to-a-byte, sends as opcode 112 with the stream index.
int ipc_send_bits(IPC_Client *client, RDSEncoder *enc, uint8_t stream) {
+1
View File
@@ -8,4 +8,5 @@ typedef struct {
int ipc_connect(IPC_Client *client, const char *socket_path);
void ipc_close(IPC_Client *client);
int ipc_send_streams(IPC_Client *client, uint8_t streams);
int ipc_send_bits(IPC_Client *client, RDSEncoder *enc, uint8_t stream);
+5
View File
@@ -188,11 +188,16 @@ int main(int argc, char **argv) {
IPC_Client client;
if (ipc_connect(&client, "/etc/fm95/ctl.socket") < 0) goto exit;
uint8_t sent_num = config.num_streams; ipc_send_streams(&client, sent_num);
while (!stop_rds) {
for (uint8_t s = 0; s < config.num_streams; s++) {
ipc_send_bits(&client, &rdsEncoder, s);
}
sleep_until_next_group(BITS_PER_GROUP, 1187.5);
if(config.num_streams != sent_num) {
sent_num = config.num_streams; ipc_send_streams(&client, sent_num);
}
}
ipc_close(&client);