mirror of
https://github.com/radio95-rnt/rds95.git
synced 2026-02-26 20:33:53 +01:00
more commands
This commit is contained in:
6
.vscode/settings.json
vendored
6
.vscode/settings.json
vendored
@@ -50,6 +50,10 @@
|
||||
"set_rds_rt2",
|
||||
"set_rds_rt1",
|
||||
"set_rds_lps",
|
||||
"set_rds_ert"
|
||||
"set_rds_ert",
|
||||
"set_rds_link",
|
||||
"set_rds_rt_switching_period",
|
||||
"set_rds_program",
|
||||
"set_rds_level"
|
||||
]
|
||||
}
|
||||
@@ -279,6 +279,9 @@ Sets the rds generator level:
|
||||
|
||||
`RDSGEN=1`
|
||||
|
||||
### Don't like the commands?
|
||||
Implement them yourself then smartass, go on, look into the command.lua file
|
||||
|
||||
## Disclaimer
|
||||
|
||||
RDS95 is based on [Anthony96922](https://github.com/Anthony96922/)'s [MiniRDS](https://github.com/Anthony96922/MiniRDS)
|
||||
|
||||
@@ -135,16 +135,6 @@ static void handle_ertp(char *arg, RDSModulator* mod, char* output) {
|
||||
} else strcpy(output, "-");
|
||||
}
|
||||
|
||||
static void handle_link(char *arg, RDSModulator* mod, char* output) {
|
||||
if(arg[0] == 0) {
|
||||
mod->enc->state[mod->enc->program].eon_linkage = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
mod->enc->state[mod->enc->program].eon_linkage = atoi(arg);
|
||||
strcpy(output, "+");
|
||||
}
|
||||
|
||||
static void handle_adr(char *arg, RDSModulator* mod, char* output) {
|
||||
uint16_t ids[2];
|
||||
int count = sscanf(arg, "%4hu,%4hu", &ids[0], &ids[1]);
|
||||
@@ -191,12 +181,6 @@ static void handle_g(char *arg, RDSModulator* mod, char* output) {
|
||||
strcpy(output, "+");
|
||||
}
|
||||
|
||||
static void handle_rtper(char *arg, RDSModulator* mod, char* output) {
|
||||
mod->enc->data[mod->enc->program].rt_switching_period = atoi(arg);
|
||||
mod->enc->state[mod->enc->program].rt_switching_period_state = mod->enc->data[mod->enc->program].rt_switching_period;
|
||||
strcpy(output, "+");
|
||||
}
|
||||
|
||||
static void handle_rtprun(char *arg, RDSModulator *mod, char *output) {
|
||||
int flag1 = 0, flag2 = 0;
|
||||
if (sscanf(arg, "%d,%d", &flag1, &flag2) < 1) flag1 = atoi(arg);
|
||||
@@ -215,20 +199,6 @@ static void handle_ertprun(char *arg, RDSModulator* mod, char* output) {
|
||||
strcpy(output, "+");
|
||||
}
|
||||
|
||||
static void handle_program(char *arg, RDSModulator* mod, char* output) {
|
||||
int16_t program = atoi(arg)-1;
|
||||
if(program == 0) {
|
||||
strcpy(output, "-");
|
||||
return;
|
||||
}
|
||||
if(program >= PROGRAMS) program = (PROGRAMS-1);
|
||||
if(program < 0) program = 0;
|
||||
mod->enc->data[mod->enc->program].ta = 0;
|
||||
mod->enc->data[(uint8_t)program].ta = 0;
|
||||
mod->enc->program = (uint8_t)program;
|
||||
strcpy(output, "+");
|
||||
}
|
||||
|
||||
static void handle_grpseq(char *arg, RDSModulator* mod, char* output) {
|
||||
if (arg[0] == 0) set_rds_grpseq(mod->enc, DEFAULT_GRPSQC);
|
||||
else set_rds_grpseq(mod->enc, arg);
|
||||
@@ -246,11 +216,6 @@ static void handle_dttmout(char *arg, RDSModulator* mod, char* output) {
|
||||
strcpy(output, "+");
|
||||
}
|
||||
|
||||
static void handle_level(char *arg, RDSModulator* mod, char* output) {
|
||||
mod->params.level = atoi(arg)/255.0f;
|
||||
strcpy(output, "+");
|
||||
}
|
||||
|
||||
static void handle_reset(char *arg, RDSModulator* mod, char* output) {
|
||||
(void)arg;
|
||||
encoder_loadFromFile(mod->enc);
|
||||
@@ -358,7 +323,6 @@ static const command_handler_t commands_eq4[] = {
|
||||
|
||||
static const command_handler_t commands_eq5[] = {
|
||||
{"ERTP", handle_ertp, 4},
|
||||
{"LINK", handle_link, 4},
|
||||
{"SITE", handle_site, 4}
|
||||
};
|
||||
|
||||
@@ -366,18 +330,12 @@ static const command_handler_t commands_eq2[] = {
|
||||
{"G", handle_g, 1}
|
||||
};
|
||||
|
||||
static const command_handler_t commands_eq6[] = {
|
||||
{"RTPER", handle_rtper, 5},
|
||||
{"LEVEL", handle_level, 5},
|
||||
};
|
||||
|
||||
static const command_handler_t commands_eq7[] = {
|
||||
{"RTPRUN", handle_rtprun, 6},
|
||||
{"GRPSEQ", handle_grpseq, 6},
|
||||
};
|
||||
|
||||
static const command_handler_t commands_eq8[] = {
|
||||
{"PROGRAM", handle_program, 7},
|
||||
{"GRPSEQ2", handle_grpseq2, 7},
|
||||
{"DTTMOUT", handle_dttmout, 7},
|
||||
{"ERTPRUN", handle_ertprun, 7},
|
||||
@@ -512,10 +470,6 @@ void process_ascii_cmd(RDSModulator* mod, char *str, char *cmd_output) {
|
||||
table = commands_eq5;
|
||||
table_size = sizeof(commands_eq5) / sizeof(command_handler_t);
|
||||
break;
|
||||
case 5:
|
||||
table = commands_eq6;
|
||||
table_size = sizeof(commands_eq6) / sizeof(command_handler_t);
|
||||
break;
|
||||
case 6:
|
||||
table = commands_eq7;
|
||||
table_size = sizeof(commands_eq7) / sizeof(command_handler_t);
|
||||
|
||||
@@ -3,7 +3,7 @@ if type(data) == "string" then
|
||||
if cmd == nil then
|
||||
data = data:lower()
|
||||
if data == "ver" then
|
||||
return string.format("rds95 v. %s - (C) 2025 radio95", core_version)
|
||||
return string.format("rds95 v. %s - (C) 2025 radio95 - lua parser", core_version)
|
||||
end
|
||||
end
|
||||
cmd = cmd:lower()
|
||||
@@ -99,6 +99,26 @@ if type(data) == "string" then
|
||||
elseif cmd == "ert" then
|
||||
set_rds_ert(value)
|
||||
return "+"
|
||||
elseif cmd == "link" then
|
||||
local link = tonumber(value)
|
||||
if not link then return "-" end
|
||||
set_rds_link(link)
|
||||
return "+"
|
||||
elseif cmd == "rtper" then
|
||||
local period = tonumber(value)
|
||||
if not period then return "-" end
|
||||
set_rds_rt_switching_period(period)
|
||||
return "+"
|
||||
elseif cmd == "program" then
|
||||
local program = tonumber(value)
|
||||
if not program then return "-" end
|
||||
set_rds_program(program-1)
|
||||
return "+"
|
||||
elseif cmd == "level" then
|
||||
local level = tonumber(value)
|
||||
if not level then return "-" end
|
||||
set_rds_level(level/255)
|
||||
return "+"
|
||||
else
|
||||
return "?"
|
||||
end
|
||||
|
||||
177
src/lua_rds.c
177
src/lua_rds.c
@@ -3,54 +3,143 @@
|
||||
static RDSModulator* mod = NULL;
|
||||
static lua_State *L = NULL;
|
||||
|
||||
#define INT_NONRETURN_HANDLER(name) \
|
||||
#define INT_SETTER(name) \
|
||||
int lua_set_rds_##name(lua_State *localL) { \
|
||||
mod->enc->data[mod->enc->program].name = luaL_checkinteger(localL, 1); \
|
||||
return 0; \
|
||||
}
|
||||
#define STR_NONRETURN_HANDLER(name, function) \
|
||||
#define STR_SETTER(name, function) \
|
||||
int lua_set_rds_##name(lua_State *localL) { \
|
||||
const char* str = luaL_checklstring(localL, 1, NULL); \
|
||||
function(mod->enc, convert_to_rdscharset(str)); \
|
||||
return 0; \
|
||||
}
|
||||
#define STR_RAW_NONRETURN_HANDLER(name, function) \
|
||||
#define STR_RAW_SETTER(name, function) \
|
||||
int lua_set_rds_##name(lua_State *localL) { \
|
||||
const char* str = luaL_checklstring(localL, 1, NULL); \
|
||||
function(mod->enc, str); \
|
||||
return 0; \
|
||||
}
|
||||
|
||||
#define INT_GETTER(name) \
|
||||
int lua_get_rds_##name(lua_State *localL) { \
|
||||
lua_pushinteger(localL, mod->enc->data[mod->enc->program].name); \
|
||||
return 1; \
|
||||
}
|
||||
#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; \
|
||||
}
|
||||
INT_SETTER(pi)
|
||||
INT_GETTER(pi)
|
||||
|
||||
INT_SETTER(pty)
|
||||
INT_GETTER(pty)
|
||||
|
||||
INT_SETTER(ecc)
|
||||
INT_GETTER(ecc)
|
||||
|
||||
INT_SETTER(slc_data)
|
||||
INT_GETTER(slc_data)
|
||||
|
||||
INT_SETTER(ct)
|
||||
INT_GETTER(ct)
|
||||
|
||||
INT_SETTER(dpty)
|
||||
INT_GETTER(dpty)
|
||||
|
||||
INT_SETTER(tp)
|
||||
INT_GETTER(tp)
|
||||
|
||||
INT_SETTER(ta)
|
||||
INT_GETTER(ta)
|
||||
|
||||
INT_SETTER(rt1_enabled)
|
||||
INT_GETTER(rt1_enabled)
|
||||
|
||||
INT_SETTER(rt2_enabled)
|
||||
INT_GETTER(rt2_enabled)
|
||||
|
||||
INT_SETTER(ptyn_enabled)
|
||||
INT_GETTER(ptyn_enabled)
|
||||
|
||||
INT_SETTER(rt_type)
|
||||
INT_GETTER(rt_type)
|
||||
|
||||
INT_NONRETURN_HANDLER(pi)
|
||||
INT_NONRETURN_HANDLER(pty)
|
||||
INT_NONRETURN_HANDLER(ecc)
|
||||
INT_NONRETURN_HANDLER(slc_data)
|
||||
INT_NONRETURN_HANDLER(ct)
|
||||
INT_NONRETURN_HANDLER(dpty)
|
||||
INT_NONRETURN_HANDLER(tp)
|
||||
INT_NONRETURN_HANDLER(ta)
|
||||
INT_NONRETURN_HANDLER(rt1_enabled)
|
||||
INT_NONRETURN_HANDLER(rt2_enabled)
|
||||
INT_NONRETURN_HANDLER(ptyn_enabled)
|
||||
INT_NONRETURN_HANDLER(rt_type)
|
||||
int lua_set_rds_rds2mod(lua_State *localL) {
|
||||
mod->enc->encoder_data.rds2_mode = luaL_checkinteger(localL, 1);
|
||||
return 0;
|
||||
}
|
||||
int lua_get_rds_rds2mod(lua_State *localL) {
|
||||
lua_pushinteger(localL, mod->enc->encoder_data.rds2_mode);
|
||||
return 1;
|
||||
}
|
||||
int lua_set_rds_rdsgen(lua_State *localL) {
|
||||
mod->params.rdsgen = luaL_checkinteger(localL, 1);
|
||||
return 0;
|
||||
}
|
||||
int lua_get_rds_rdsgen(lua_State *localL) {
|
||||
lua_pushinteger(localL, mod->params.rdsgen);
|
||||
return 1;
|
||||
}
|
||||
|
||||
STR_NONRETURN_HANDLER(ptyn, set_rds_ptyn)
|
||||
STR_NONRETURN_HANDLER(ps, set_rds_ps)
|
||||
STR_NONRETURN_HANDLER(tps, set_rds_tps)
|
||||
STR_NONRETURN_HANDLER(rt1, set_rds_rt1)
|
||||
STR_NONRETURN_HANDLER(rt2, set_rds_rt2)
|
||||
int lua_set_rds_link(lua_State *localL) {
|
||||
mod->enc->state[mod->enc->program].eon_linkage = luaL_checkinteger(localL, 1);
|
||||
return 0;
|
||||
}
|
||||
int lua_get_rds_link(lua_State *localL) {
|
||||
lua_pushinteger(localL, mod->enc->state[mod->enc->program].eon_linkage);
|
||||
return 1;
|
||||
}
|
||||
|
||||
STR_RAW_NONRETURN_HANDLER(lps, set_rds_lps)
|
||||
STR_RAW_NONRETURN_HANDLER(ert, set_rds_ert)
|
||||
int lua_set_rds_program(lua_State *localL) {
|
||||
int program = luaL_checkinteger(localL, 1);
|
||||
if(program >= PROGRAMS) program = (PROGRAMS-1);
|
||||
if(program < 0) program = 0;
|
||||
|
||||
if(mod->enc->program == program) return 0;
|
||||
|
||||
mod->enc->data[mod->enc->program].ta = 0;
|
||||
mod->enc->data[(uint8_t)program].ta = 0;
|
||||
mod->enc->program = (uint8_t)program;
|
||||
return 0;
|
||||
}
|
||||
int lua_get_rds_program(lua_State *localL) {
|
||||
lua_pushinteger(localL, mod->enc->program);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int lua_set_rds_rt_switching_period(lua_State *localL) {
|
||||
mod->enc->data[mod->enc->program].rt_switching_period = luaL_checkinteger(localL, 1);
|
||||
mod->enc->state[mod->enc->program].rt_switching_period_state = mod->enc->data[mod->enc->program].rt_switching_period;
|
||||
return 0;
|
||||
}
|
||||
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_level(lua_State *localL) {
|
||||
mod->params.level = luaL_checknumber(localL, 1);
|
||||
return 0;
|
||||
}
|
||||
int lua_get_rds_level(lua_State *localL) {
|
||||
lua_pushnumber(localL, mod->params.level);
|
||||
return 1;
|
||||
}
|
||||
|
||||
STR_SETTER(ptyn, set_rds_ptyn)
|
||||
STR_SETTER(ps, set_rds_ps)
|
||||
STR_SETTER(tps, set_rds_tps)
|
||||
STR_SETTER(rt1, set_rds_rt1)
|
||||
STR_SETTER(rt2, set_rds_rt2)
|
||||
|
||||
STR_RAW_SETTER(lps, set_rds_lps)
|
||||
STR_RAW_GETTER(lps)
|
||||
|
||||
STR_RAW_SETTER(ert, set_rds_ert)
|
||||
STR_RAW_GETTER(ert)
|
||||
|
||||
void init_lua(RDSModulator* rds_mod) {
|
||||
mod = rds_mod;
|
||||
@@ -68,26 +157,70 @@ void init_lua(RDSModulator* rds_mod) {
|
||||
lua_setglobal(L, "core_version");
|
||||
|
||||
lua_register(L, "set_rds_pi", lua_set_rds_pi);
|
||||
lua_register(L, "get_rds_pi", lua_get_rds_pi);
|
||||
|
||||
lua_register(L, "set_rds_pty", lua_set_rds_pty);
|
||||
lua_register(L, "get_rds_pty", lua_get_rds_pty);
|
||||
|
||||
lua_register(L, "set_rds_ecc", lua_set_rds_ecc);
|
||||
lua_register(L, "get_rds_ecc", lua_get_rds_ecc);
|
||||
|
||||
lua_register(L, "set_rds_slc_data", lua_set_rds_slc_data);
|
||||
lua_register(L, "get_rds_slc_data", lua_get_rds_slc_data);
|
||||
|
||||
lua_register(L, "set_rds_ct", lua_set_rds_ct);
|
||||
lua_register(L, "get_rds_ct", lua_get_rds_ct);
|
||||
|
||||
lua_register(L, "set_rds_dpty", lua_set_rds_dpty);
|
||||
lua_register(L, "get_rds_dpty", lua_get_rds_dpty);
|
||||
|
||||
lua_register(L, "set_rds_tp", lua_set_rds_tp);
|
||||
lua_register(L, "get_rds_tp", lua_get_rds_tp);
|
||||
|
||||
lua_register(L, "set_rds_ta", lua_set_rds_ta);
|
||||
lua_register(L, "get_rds_ta", lua_get_rds_ta);
|
||||
|
||||
lua_register(L, "set_rds_rt1_enabled", lua_set_rds_rt1_enabled);
|
||||
lua_register(L, "get_rds_rt1_enabled", lua_get_rds_rt1_enabled);
|
||||
|
||||
lua_register(L, "set_rds_rt2_enabled", lua_set_rds_rt2_enabled);
|
||||
lua_register(L, "get_rds_rt2_enabled", lua_get_rds_rt2_enabled);
|
||||
|
||||
lua_register(L, "set_rds_ptyn_enabled", lua_set_rds_ptyn_enabled);
|
||||
lua_register(L, "get_rds_ptyn_enabled", lua_get_rds_ptyn_enabled);
|
||||
|
||||
lua_register(L, "set_rds_rt_type", lua_set_rds_rt_type);
|
||||
lua_register(L, "get_rds_rt_type", lua_get_rds_rt_type);
|
||||
|
||||
lua_register(L, "set_rds_rds2mod", lua_set_rds_rds2mod);
|
||||
lua_register(L, "get_rds_rds2mod", lua_get_rds_rds2mod);
|
||||
|
||||
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_link", lua_set_rds_link);
|
||||
lua_register(L, "get_rds_link", lua_get_rds_link);
|
||||
|
||||
lua_register(L, "set_rds_program", lua_set_rds_program);
|
||||
lua_register(L, "get_rds_program", lua_get_rds_program);
|
||||
|
||||
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_level", lua_set_rds_level);
|
||||
lua_register(L, "get_rds_level", lua_get_rds_level);
|
||||
|
||||
lua_register(L, "set_rds_ptyn", lua_set_rds_ptyn);
|
||||
lua_register(L, "set_rds_ps", lua_set_rds_ps);
|
||||
lua_register(L, "set_rds_tps", lua_set_rds_tps);
|
||||
lua_register(L, "set_rds_rt1", lua_set_rds_rt1);
|
||||
lua_register(L, "set_rds_rt2", lua_set_rds_rt2);
|
||||
|
||||
lua_register(L, "set_rds_lps", lua_set_rds_lps);
|
||||
lua_register(L, "get_rds_lps", lua_get_rds_lps);
|
||||
|
||||
lua_register(L, "set_rds_ert", lua_set_rds_ert);
|
||||
lua_register(L, "get_rds_ert", lua_get_rds_ert);
|
||||
}
|
||||
|
||||
void run_lua(char *str, char *cmd_output) {
|
||||
|
||||
Reference in New Issue
Block a user