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:
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@@ -54,6 +54,8 @@
|
|||||||
"set_rds_link",
|
"set_rds_link",
|
||||||
"set_rds_rt_switching_period",
|
"set_rds_rt_switching_period",
|
||||||
"set_rds_program",
|
"set_rds_program",
|
||||||
"set_rds_level"
|
"set_rds_level",
|
||||||
|
"set_rds_rt_text_timeout",
|
||||||
|
"set_rds_program_defaults"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -204,17 +204,6 @@ static void handle_grpseq(char *arg, RDSModulator* mod, char* output) {
|
|||||||
else set_rds_grpseq(mod->enc, arg);
|
else set_rds_grpseq(mod->enc, arg);
|
||||||
strcpy(output, "+");
|
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) {
|
static void handle_reset(char *arg, RDSModulator* mod, char* output) {
|
||||||
(void)arg;
|
(void)arg;
|
||||||
@@ -224,12 +213,6 @@ static void handle_reset(char *arg, RDSModulator* mod, char* output) {
|
|||||||
strcpy(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) {
|
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);
|
mod->enc->data[mod->enc->program].eon[atoi(pattern)-1].enabled = atoi(arg);
|
||||||
strcpy(output, "+");
|
strcpy(output, "+");
|
||||||
@@ -336,12 +319,9 @@ static const command_handler_t commands_eq7[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static const command_handler_t commands_eq8[] = {
|
static const command_handler_t commands_eq8[] = {
|
||||||
{"GRPSEQ2", handle_grpseq2, 7},
|
|
||||||
{"DTTMOUT", handle_dttmout, 7},
|
|
||||||
{"ERTPRUN", handle_ertprun, 7},
|
{"ERTPRUN", handle_ertprun, 7},
|
||||||
};
|
};
|
||||||
static const command_handler_t commands_exact[] = {
|
static const command_handler_t commands_exact[] = {
|
||||||
{"INIT", handle_init, 4},
|
|
||||||
{"RESET", handle_reset, 5},
|
{"RESET", handle_reset, 5},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ if type(data) == "string" then
|
|||||||
data = data:lower()
|
data = data:lower()
|
||||||
if data == "ver" then
|
if data == "ver" then
|
||||||
return string.format("rds95 v. %s - (C) 2025 radio95 - lua parser", core_version)
|
return string.format("rds95 v. %s - (C) 2025 radio95 - lua parser", core_version)
|
||||||
|
elseif data == "init" then
|
||||||
|
set_rds_program_defaults()
|
||||||
|
return "+"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
cmd = cmd:lower()
|
cmd = cmd:lower()
|
||||||
@@ -112,6 +115,7 @@ if type(data) == "string" then
|
|||||||
elseif cmd == "program" then
|
elseif cmd == "program" then
|
||||||
local program = tonumber(value)
|
local program = tonumber(value)
|
||||||
if not program then return "-" end
|
if not program then return "-" end
|
||||||
|
if program < 1 then return "-" end
|
||||||
set_rds_program(program-1)
|
set_rds_program(program-1)
|
||||||
return "+"
|
return "+"
|
||||||
elseif cmd == "level" then
|
elseif cmd == "level" then
|
||||||
@@ -119,6 +123,11 @@ if type(data) == "string" then
|
|||||||
if not level then return "-" end
|
if not level then return "-" end
|
||||||
set_rds_level(level/255)
|
set_rds_level(level/255)
|
||||||
return "+"
|
return "+"
|
||||||
|
elseif cmd == "dttmout" then
|
||||||
|
local timeout = tonumber(value)
|
||||||
|
if not timeout then return "-" end
|
||||||
|
set_rds_rt_text_timeout(timeout)
|
||||||
|
return "+"
|
||||||
else
|
else
|
||||||
return "?"
|
return "?"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,6 +3,11 @@
|
|||||||
static RDSModulator* mod = NULL;
|
static RDSModulator* mod = NULL;
|
||||||
static lua_State *L = 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) \
|
#define INT_SETTER(name) \
|
||||||
int lua_set_rds_##name(lua_State *localL) { \
|
int lua_set_rds_##name(lua_State *localL) { \
|
||||||
mod->enc->data[mod->enc->program].name = luaL_checkinteger(localL, 1); \
|
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) \
|
#define STR_RAW_GETTER(name) \
|
||||||
int lua_get_rds_##name(lua_State *localL) { \
|
int lua_get_rds_##name(lua_State *localL) { \
|
||||||
lua_pushstring(localL, mod->enc->data[mod->enc->program].name); \
|
lua_pushstring(localL, mod->enc->data[mod->enc->program].name); \
|
||||||
return 0; \
|
return 1; \
|
||||||
}
|
}
|
||||||
INT_SETTER(pi)
|
INT_SETTER(pi)
|
||||||
INT_GETTER(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);
|
lua_pushinteger(localL, mod->enc->data[mod->enc->program].rt_switching_period);
|
||||||
return 1;
|
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) {
|
int lua_set_rds_level(lua_State *localL) {
|
||||||
mod->params.level = luaL_checknumber(localL, 1);
|
mod->params.level = luaL_checknumber(localL, 1);
|
||||||
@@ -129,6 +143,47 @@ int lua_get_rds_level(lua_State *localL) {
|
|||||||
return 1;
|
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(ptyn, set_rds_ptyn)
|
||||||
STR_SETTER(ps, set_rds_ps)
|
STR_SETTER(ps, set_rds_ps)
|
||||||
STR_SETTER(tps, set_rds_tps)
|
STR_SETTER(tps, set_rds_tps)
|
||||||
@@ -141,6 +196,12 @@ STR_RAW_GETTER(lps)
|
|||||||
STR_RAW_SETTER(ert, set_rds_ert)
|
STR_RAW_SETTER(ert, set_rds_ert)
|
||||||
STR_RAW_GETTER(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) {
|
void init_lua(RDSModulator* rds_mod) {
|
||||||
mod = rds_mod;
|
mod = rds_mod;
|
||||||
L = luaL_newstate();
|
L = luaL_newstate();
|
||||||
@@ -156,6 +217,8 @@ void init_lua(RDSModulator* rds_mod) {
|
|||||||
lua_pushstring(L, VERSION);
|
lua_pushstring(L, VERSION);
|
||||||
lua_setglobal(L, "core_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, "set_rds_pi", lua_set_rds_pi);
|
||||||
lua_register(L, "get_rds_pi", lua_get_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, "set_rds_rdsgen", lua_set_rds_rdsgen);
|
||||||
lua_register(L, "get_rds_rdsgen", lua_get_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, "set_rds_link", lua_set_rds_link);
|
||||||
lua_register(L, "get_rds_link", lua_get_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, "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, "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, "set_rds_level", lua_set_rds_level);
|
||||||
lua_register(L, "get_rds_level", lua_get_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, "set_rds_ert", lua_set_rds_ert);
|
||||||
lua_register(L, "get_rds_ert", lua_get_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) {
|
void run_lua(char *str, char *cmd_output) {
|
||||||
|
|||||||
Reference in New Issue
Block a user