fix pcalls

This commit is contained in:
2026-03-10 17:15:42 +01:00
parent ad4f80c2b9
commit ca44cf83dc
6 changed files with 7 additions and 13 deletions
+1 -1
View File
@@ -92,7 +92,7 @@ local function get_data()
local oda = _RDS_ODAs[_RDS_ODA_pointer] local oda = _RDS_ODAs[_RDS_ODA_pointer]
if oda ~= false and type(oda.handler) == "function" then if oda ~= false and type(oda.handler) == "function" then
local ok, generated, b, c, d = pcall(oda.handler()) local ok, generated, b, c, d = pcall(oda.handler)
if ok and generated then if ok and generated then
_RDS_ODA_pointer = (_RDS_ODA_pointer % #_RDS_ODAs) + 1 _RDS_ODA_pointer = (_RDS_ODA_pointer % #_RDS_ODAs) + 1
b = b | oda.group << 12 b = b | oda.group << 12
+1 -1
View File
@@ -100,7 +100,7 @@ function rds2_group(stream)
local generated = false local generated = false
checked = 0 checked = 0
while generated == false and checked < #_RDS2_ODAs do while generated == false and checked < #_RDS2_ODAs do
local ok, generated, a, b, c, d = pcall(oda.handler(stream)) local ok, generated, a, b, c, d = pcall(oda.handler, stream)
if not (generated and ok) then if not (generated and ok) then
_RDS2_ODA_pointer = _RDS2_ODA_pointer + 1 _RDS2_ODA_pointer = _RDS2_ODA_pointer + 1
if _RDS2_ODA_pointer > #_RDS2_ODAs then _RDS2_ODA_pointer = 1 end if _RDS2_ODA_pointer > #_RDS2_ODAs then _RDS2_ODA_pointer = 1 end
+1 -2
View File
@@ -295,8 +295,7 @@ uint16_t offset_words_typeb[] = {
0x1B4, /* D */ 0x1B4, /* D */
}; };
void add_checkwords(RDSGroup *group, uint8_t *bits) void add_checkwords(RDSGroup *group, uint8_t *bits) {
{
uint16_t* offset_words; uint16_t* offset_words;
if(group->is_type_b) offset_words = offset_words_typeb; if(group->is_type_b) offset_words = offset_words_typeb;
else offset_words = offset_words_typea; else offset_words = offset_words_typea;
+1 -1
View File
@@ -173,7 +173,7 @@ int main(int argc, char **argv) {
init_rds_modulator(&rdsModulator, &rdsEncoder, config.num_streams); init_rds_modulator(&rdsModulator, &rdsEncoder, config.num_streams);
init_rds_encoder(&rdsEncoder); init_rds_encoder(&rdsEncoder);
if(open_udp_server(config.udp_port, &rdsModulator) == 0) { if(open_udp_server(config.udp_port) == 0) {
printf("Reading control commands on UDP:%d.\n", config.udp_port); printf("Reading control commands on UDP:%d.\n", config.udp_port);
int r = pthread_create(&udp_server_thread, &attr, udp_server_worker, NULL); int r = pthread_create(&udp_server_thread, &attr, udp_server_worker, NULL);
if (r < 0) { if (r < 0) {
+1 -5
View File
@@ -8,9 +8,7 @@ static struct pollfd poller;
static struct sockaddr_in client_addr; static struct sockaddr_in client_addr;
static socklen_t client_len = sizeof(client_addr); static socklen_t client_len = sizeof(client_addr);
static RDSModulator* mod = NULL; int open_udp_server(int port) {
int open_udp_server(int port, RDSModulator* rds_mod) {
sockfd = socket(AF_INET, SOCK_DGRAM, 0); sockfd = socket(AF_INET, SOCK_DGRAM, 0);
if (sockfd < 0) return -1; if (sockfd < 0) return -1;
@@ -30,8 +28,6 @@ int open_udp_server(int port, RDSModulator* rds_mod) {
poller.fd = sockfd; poller.fd = sockfd;
poller.events = POLLIN; poller.events = POLLIN;
mod = rds_mod;
return 0; return 0;
} }
+1 -2
View File
@@ -10,13 +10,12 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/types.h> #include <sys/types.h>
#include <netinet/in.h> #include <netinet/in.h>
#include "modulator.h"
#include "lua_rds.h" #include "lua_rds.h"
#define CMD_BUFFER_SIZE 255 #define CMD_BUFFER_SIZE 255
#define CTL_BUFFER_SIZE (CMD_BUFFER_SIZE * 2) #define CTL_BUFFER_SIZE (CMD_BUFFER_SIZE * 2)
#define READ_TIMEOUT_MS 225 #define READ_TIMEOUT_MS 225
int open_udp_server(int port, RDSModulator *rds_mod); int open_udp_server(int port);
void poll_udp_server(); void poll_udp_server();
void close_udp_server(); void close_udp_server();