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

more commands and even more in lua api

This commit is contained in:
2025-12-22 18:18:01 +01:00
parent bd16b9c4a3
commit 2f30bfb925
4 changed files with 85 additions and 22 deletions

View File

@@ -54,6 +54,8 @@
"set_rds_link",
"set_rds_rt_switching_period",
"set_rds_program",
"set_rds_level"
"set_rds_level",
"set_rds_rt_text_timeout",
"set_rds_program_defaults"
]
}

View File

@@ -204,17 +204,6 @@ static void handle_grpseq(char *arg, RDSModulator* mod, char* output) {
else set_rds_grpseq(mod->enc, arg);
strcpy(output, "+");
}
static void handle_grpseq2(char *arg, RDSModulator* mod, char* output) {
if (arg[0] == 0) set_rds_grpseq2(mod->enc, "\0");
else set_rds_grpseq2(mod->enc, arg);
strcpy(output, "+");
}
static void handle_dttmout(char *arg, RDSModulator* mod, char* output) {
mod->enc->data[mod->enc->program].rt_text_timeout = atoi(arg);
mod->enc->state[mod->enc->program].rt_text_timeout_state = mod->enc->data[mod->enc->program].rt_text_timeout;
strcpy(output, "+");
}
static void handle_reset(char *arg, RDSModulator* mod, char* output) {
(void)arg;
@@ -224,12 +213,6 @@ static void handle_reset(char *arg, RDSModulator* mod, char* output) {
strcpy(output, "+");
}
static void handle_init(char *arg, RDSModulator* mod, char* output) {
(void)arg;
set_rds_defaults(mod->enc, mod->enc->program);
strcpy(output, "+");
}
static void handle_eonen(char *arg, char *pattern, RDSModulator* mod, char* output) {
mod->enc->data[mod->enc->program].eon[atoi(pattern)-1].enabled = atoi(arg);
strcpy(output, "+");
@@ -336,12 +319,9 @@ static const command_handler_t commands_eq7[] = {
};
static const command_handler_t commands_eq8[] = {
{"GRPSEQ2", handle_grpseq2, 7},
{"DTTMOUT", handle_dttmout, 7},
{"ERTPRUN", handle_ertprun, 7},
};
static const command_handler_t commands_exact[] = {
{"INIT", handle_init, 4},
{"RESET", handle_reset, 5},
};

View File

@@ -4,6 +4,9 @@ if type(data) == "string" then
data = data:lower()
if data == "ver" then
return string.format("rds95 v. %s - (C) 2025 radio95 - lua parser", core_version)
elseif data == "init" then
set_rds_program_defaults()
return "+"
end
end
cmd = cmd:lower()
@@ -112,6 +115,7 @@ if type(data) == "string" then
elseif cmd == "program" then
local program = tonumber(value)
if not program then return "-" end
if program < 1 then return "-" end
set_rds_program(program-1)
return "+"
elseif cmd == "level" then
@@ -119,6 +123,11 @@ if type(data) == "string" then
if not level then return "-" end
set_rds_level(level/255)
return "+"
elseif cmd == "dttmout" then
local timeout = tonumber(value)
if not timeout then return "-" end
set_rds_rt_text_timeout(timeout)
return "+"
else
return "?"
end

View File

@@ -3,6 +3,11 @@
static RDSModulator* mod = NULL;
static lua_State *L = NULL;
int lua_set_rds_program_defaults(lua_State *localL) {
set_rds_defaults(mod->enc, mod->enc->program);
return 0;
}
#define INT_SETTER(name) \
int lua_set_rds_##name(lua_State *localL) { \
mod->enc->data[mod->enc->program].name = luaL_checkinteger(localL, 1); \
@@ -29,7 +34,7 @@ int lua_get_rds_##name(lua_State *localL) { \
#define STR_RAW_GETTER(name) \
int lua_get_rds_##name(lua_State *localL) { \
lua_pushstring(localL, mod->enc->data[mod->enc->program].name); \
return 0; \
return 1; \
}
INT_SETTER(pi)
INT_GETTER(pi)
@@ -119,6 +124,15 @@ int lua_get_rds_rt_switching_period(lua_State *localL) {
lua_pushinteger(localL, mod->enc->data[mod->enc->program].rt_switching_period);
return 1;
}
int lua_set_rds_rt_text_timeout(lua_State *localL) {
mod->enc->data[mod->enc->program].rt_text_timeout = luaL_checkinteger(localL, 1);
mod->enc->state[mod->enc->program].rt_text_timeout_state = mod->enc->data[mod->enc->program].rt_text_timeout;
return 0;
}
int lua_get_rds_rt_text_timeout(lua_State *localL) {
lua_pushinteger(localL, mod->enc->data[mod->enc->program].rt_text_timeout);
return 1;
}
int lua_set_rds_level(lua_State *localL) {
mod->params.level = luaL_checknumber(localL, 1);
@@ -129,6 +143,47 @@ int lua_get_rds_level(lua_State *localL) {
return 1;
}
int lua_set_rds_rtplus_tags(lua_State *localL) {
uint8_t tags[6];
tags[0] = luaL_checkinteger(localL, 1);
tags[1] = luaL_checkinteger(localL, 2);
tags[2] = luaL_checkinteger(localL, 3);
tags[3] = luaL_checkinteger(localL, 4);
tags[4] = luaL_checkinteger(localL, 5);
tags[5] = luaL_checkinteger(localL, 6);
set_rds_rtplus_tags(mod->enc, tags);
return 0;
}
int lua_get_rds_rtplus_tags(lua_State *localL) {
lua_pushinteger(localL, mod->enc->rtpData[mod->enc->program][0].type[0]);
lua_pushinteger(localL, mod->enc->rtpData[mod->enc->program][0].start[0]);
lua_pushinteger(localL, mod->enc->rtpData[mod->enc->program][0].len[0]);
lua_pushinteger(localL, mod->enc->rtpData[mod->enc->program][0].type[1]);
lua_pushinteger(localL, mod->enc->rtpData[mod->enc->program][0].start[1]);
lua_pushinteger(localL, mod->enc->rtpData[mod->enc->program][0].len[1]);
return 6;
}
int lua_set_rds_ertplus_tags(lua_State *localL) {
uint8_t tags[6];
tags[0] = luaL_checkinteger(localL, 1);
tags[1] = luaL_checkinteger(localL, 2);
tags[2] = luaL_checkinteger(localL, 3);
tags[3] = luaL_checkinteger(localL, 4);
tags[4] = luaL_checkinteger(localL, 5);
tags[5] = luaL_checkinteger(localL, 6);
set_rds_ertplus_tags(mod->enc, tags);
return 0;
}
int lua_get_rds_ertplus_tags(lua_State *localL) {
lua_pushinteger(localL, mod->enc->rtpData[mod->enc->program][1].type[0]);
lua_pushinteger(localL, mod->enc->rtpData[mod->enc->program][1].start[0]);
lua_pushinteger(localL, mod->enc->rtpData[mod->enc->program][1].len[0]);
lua_pushinteger(localL, mod->enc->rtpData[mod->enc->program][1].type[1]);
lua_pushinteger(localL, mod->enc->rtpData[mod->enc->program][1].start[1]);
lua_pushinteger(localL, mod->enc->rtpData[mod->enc->program][1].len[1]);
return 6;
}
STR_SETTER(ptyn, set_rds_ptyn)
STR_SETTER(ps, set_rds_ps)
STR_SETTER(tps, set_rds_tps)
@@ -141,6 +196,12 @@ STR_RAW_GETTER(lps)
STR_RAW_SETTER(ert, set_rds_ert)
STR_RAW_GETTER(ert)
STR_RAW_SETTER(grpseq2, handle_grpseq2)
int lua_get_rds_grpseq2(lua_State *localL) {
lua_pushstring(localL, mod->enc->data[mod->enc->program].grp_sqc_rds2);
return 1;
}
void init_lua(RDSModulator* rds_mod) {
mod = rds_mod;
L = luaL_newstate();
@@ -155,6 +216,8 @@ void init_lua(RDSModulator* rds_mod) {
lua_pushstring(L, VERSION);
lua_setglobal(L, "core_version");
lua_register(L, "set_rds_program_defaults", lua_set_rds_program_defaults);
lua_register(L, "set_rds_pi", lua_set_rds_pi);
lua_register(L, "get_rds_pi", lua_get_rds_pi);
@@ -198,6 +261,9 @@ void init_lua(RDSModulator* rds_mod) {
lua_register(L, "set_rds_rdsgen", lua_set_rds_rdsgen);
lua_register(L, "get_rds_rdsgen", lua_get_rds_rdsgen);
lua_register(L, "set_rds_grpseq2", lua_set_rds_grpseq2);
lua_register(L, "get_rds_grpseq2", lua_get_rds_grpseq2);
lua_register(L, "set_rds_link", lua_set_rds_link);
lua_register(L, "get_rds_link", lua_get_rds_link);
@@ -207,6 +273,9 @@ void init_lua(RDSModulator* rds_mod) {
lua_register(L, "set_rds_rt_switching_period", lua_set_rds_rt_switching_period);
lua_register(L, "get_rds_rt_switching_period", lua_get_rds_rt_switching_period);
lua_register(L, "set_rds_rt_text_timeout", lua_set_rds_rt_text_timeout);
lua_register(L, "get_rds_rt_text_timeout", lua_get_rds_rt_text_timeout);
lua_register(L, "set_rds_level", lua_set_rds_level);
lua_register(L, "get_rds_level", lua_get_rds_level);
@@ -221,6 +290,9 @@ void init_lua(RDSModulator* rds_mod) {
lua_register(L, "set_rds_ert", lua_set_rds_ert);
lua_register(L, "get_rds_ert", lua_get_rds_ert);
lua_register(L, "set_rds_rtplus_tags", lua_set_rds_rtplus_tags);
lua_register(L, "get_rds_rtplus_tags", lua_get_rds_rtplus_tags);
}
void run_lua(char *str, char *cmd_output) {