mirror of
https://github.com/radio95-rnt/rds95.git
synced 2026-02-27 04:43:52 +01:00
more and more
This commit is contained in:
13
.vscode/settings.json
vendored
13
.vscode/settings.json
vendored
@@ -22,9 +22,6 @@
|
|||||||
"ranges": "c",
|
"ranges": "c",
|
||||||
"span": "c"
|
"span": "c"
|
||||||
},
|
},
|
||||||
"C_Cpp.codeAnalysis.clangTidy.checks.disabled": [
|
|
||||||
"clang-diagnostic-error"
|
|
||||||
],
|
|
||||||
"Lua.diagnostics.globals": [
|
"Lua.diagnostics.globals": [
|
||||||
"set_rds_pi",
|
"set_rds_pi",
|
||||||
"set_rds_ecc",
|
"set_rds_ecc",
|
||||||
@@ -69,5 +66,13 @@
|
|||||||
"get_rds_tp",
|
"get_rds_tp",
|
||||||
"get_rds_ta"
|
"get_rds_ta"
|
||||||
],
|
],
|
||||||
"Lua.runtime.plugin": "plugin.lua"
|
"Lua.runtime.plugin": "plugin.lua",
|
||||||
|
"Lua.runtime.builtin": {
|
||||||
|
"io": "disable",
|
||||||
|
"debug": "disable",
|
||||||
|
"os": "disable",
|
||||||
|
"jit": "disable",
|
||||||
|
"ffi": "disable",
|
||||||
|
"package": "disable"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
15
plugin.lua
15
plugin.lua
@@ -175,4 +175,17 @@ function set_rds_ertplus_tags(t1, s1, l1, t2, s2, l2) end
|
|||||||
|
|
||||||
---Gets eRT+ tags: type1, start1, len1, type2, start2, len2
|
---Gets eRT+ tags: type1, start1, len1, type2, start2, len2
|
||||||
---@return integer, integer, integer, integer, integer, integer
|
---@return integer, integer, integer, integer, integer, integer
|
||||||
function get_rds_ertplus_tags() end
|
function get_rds_ertplus_tags() end
|
||||||
|
|
||||||
|
---Puts in a RDS1 group in the buffer, note that block A is filled in always
|
||||||
|
---@param b integer
|
||||||
|
---@param c integer
|
||||||
|
---@param d integer
|
||||||
|
function put_rds_custom_group(b, c, d) end
|
||||||
|
|
||||||
|
---Puts in a RDS2 group in the buffer
|
||||||
|
---@param a integer
|
||||||
|
---@param b integer
|
||||||
|
---@param c integer
|
||||||
|
---@param d integer
|
||||||
|
function put_rds2_custom_group(a, b, c, d) end
|
||||||
@@ -117,24 +117,6 @@ static void handle_udg2(char *arg, char *pattern, RDSModulator* mod, char* outpu
|
|||||||
else strcpy(output, "/");
|
else strcpy(output, "/");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_rtp(char *arg, RDSModulator* mod, char* output) {
|
|
||||||
uint8_t tags[6];
|
|
||||||
|
|
||||||
if (sscanf(arg, "%hhu,%hhu,%hhu,%hhu,%hhu,%hhu", &tags[0], &tags[1], &tags[2], &tags[3], &tags[4], &tags[5]) == 6) {
|
|
||||||
set_rds_rtplus_tags(mod->enc, tags);
|
|
||||||
strcpy(output, "+");
|
|
||||||
} else strcpy(output, "-");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void handle_ertp(char *arg, RDSModulator* mod, char* output) {
|
|
||||||
uint8_t tags[6];
|
|
||||||
|
|
||||||
if (sscanf(arg, "%hhu,%hhu,%hhu,%hhu,%hhu,%hhu", &tags[0], &tags[1], &tags[2], &tags[3], &tags[4], &tags[5]) == 6) {
|
|
||||||
set_rds_ertplus_tags(mod->enc, tags);
|
|
||||||
strcpy(output, "+");
|
|
||||||
} else strcpy(output, "-");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void handle_adr(char *arg, RDSModulator* mod, char* output) {
|
static void handle_adr(char *arg, RDSModulator* mod, char* output) {
|
||||||
uint16_t ids[2];
|
uint16_t ids[2];
|
||||||
int count = sscanf(arg, "%4hu,%4hu", &ids[0], &ids[1]);
|
int count = sscanf(arg, "%4hu,%4hu", &ids[0], &ids[1]);
|
||||||
@@ -163,24 +145,6 @@ static void handle_site(char *arg, RDSModulator* mod, char* output) {
|
|||||||
strcpy(output, "+");
|
strcpy(output, "+");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_g(char *arg, RDSModulator* mod, char* output) {
|
|
||||||
uint16_t blocks[4];
|
|
||||||
int count = sscanf(arg, "%4hx%4hx%4hx%4hx", &blocks[0], &blocks[1], &blocks[2], &blocks[3]);
|
|
||||||
if (count == 3) {
|
|
||||||
mod->enc->state[mod->enc->program].custom_group[0] = 1;
|
|
||||||
mod->enc->state[mod->enc->program].custom_group[1] = blocks[0];
|
|
||||||
mod->enc->state[mod->enc->program].custom_group[2] = blocks[1];
|
|
||||||
mod->enc->state[mod->enc->program].custom_group[3] = blocks[2];
|
|
||||||
} else if(count == 4) {
|
|
||||||
mod->enc->state[mod->enc->program].custom_group2[0] = 1;
|
|
||||||
mod->enc->state[mod->enc->program].custom_group2[1] = blocks[0];
|
|
||||||
mod->enc->state[mod->enc->program].custom_group2[2] = blocks[1];
|
|
||||||
mod->enc->state[mod->enc->program].custom_group2[3] = blocks[2];
|
|
||||||
mod->enc->state[mod->enc->program].custom_group2[4] = blocks[3];
|
|
||||||
} else strcpy(output, "-");
|
|
||||||
strcpy(output, "+");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void handle_rtprun(char *arg, RDSModulator *mod, char *output) {
|
static void handle_rtprun(char *arg, RDSModulator *mod, char *output) {
|
||||||
int flag1 = 0, flag2 = 0;
|
int flag1 = 0, flag2 = 0;
|
||||||
if (sscanf(arg, "%d,%d", &flag1, &flag2) < 1) flag1 = atoi(arg);
|
if (sscanf(arg, "%d,%d", &flag1, &flag2) < 1) flag1 = atoi(arg);
|
||||||
@@ -285,20 +249,14 @@ static const command_handler_t commands_eq3[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static const command_handler_t commands_eq4[] = {
|
static const command_handler_t commands_eq4[] = {
|
||||||
{"RTP", handle_rtp, 3},
|
|
||||||
{"AFO", handle_afo, 3},
|
{"AFO", handle_afo, 3},
|
||||||
{"ADR", handle_adr, 3}
|
{"ADR", handle_adr, 3}
|
||||||
};
|
};
|
||||||
|
|
||||||
static const command_handler_t commands_eq5[] = {
|
static const command_handler_t commands_eq5[] = {
|
||||||
{"ERTP", handle_ertp, 4},
|
|
||||||
{"SITE", handle_site, 4}
|
{"SITE", handle_site, 4}
|
||||||
};
|
};
|
||||||
|
|
||||||
static const command_handler_t commands_eq2[] = {
|
|
||||||
{"G", handle_g, 1}
|
|
||||||
};
|
|
||||||
|
|
||||||
static const command_handler_t commands_eq7[] = {
|
static const command_handler_t commands_eq7[] = {
|
||||||
{"RTPRUN", handle_rtprun, 6},
|
{"RTPRUN", handle_rtprun, 6},
|
||||||
};
|
};
|
||||||
@@ -408,10 +366,6 @@ void process_ascii_cmd(RDSModulator* mod, char *str, char *cmd_output) {
|
|||||||
size_t table_size = 0;
|
size_t table_size = 0;
|
||||||
|
|
||||||
switch (eq_pos) {
|
switch (eq_pos) {
|
||||||
case 1:
|
|
||||||
table = commands_eq2;
|
|
||||||
table_size = sizeof(commands_eq2) / sizeof(command_handler_t);
|
|
||||||
break;
|
|
||||||
case 2:
|
case 2:
|
||||||
table = commands_eq3;
|
table = commands_eq3;
|
||||||
table_size = sizeof(commands_eq3) / sizeof(command_handler_t);
|
table_size = sizeof(commands_eq3) / sizeof(command_handler_t);
|
||||||
|
|||||||
@@ -18,6 +18,12 @@ if type(data) == "string" and data ~= nil then
|
|||||||
elseif data == "dpty" then return string.format("DPTY=%s\r\n", string.format("%d", get_rds_dpty()))
|
elseif data == "dpty" then return string.format("DPTY=%s\r\n", string.format("%d", get_rds_dpty()))
|
||||||
elseif data == "tp" then return string.format("TP=%s\r\n", string.format("%d", get_rds_tp()))
|
elseif data == "tp" then return string.format("TP=%s\r\n", string.format("%d", get_rds_tp()))
|
||||||
elseif data == "ta" then return string.format("TA=%s\r\n", string.format("%d", get_rds_ta()))
|
elseif data == "ta" then return string.format("TA=%s\r\n", string.format("%d", get_rds_ta()))
|
||||||
|
elseif data == "rtp" then
|
||||||
|
local t1, s1, l1, t2, s2, l2 = get_rds_rtplus_tags()
|
||||||
|
return string.format("RTP=%d,%d,%d,%d,%d,%d\r\n", t1, s1, l1, t2, s2, l2)
|
||||||
|
elseif data == "ertp" then
|
||||||
|
local t1, s1, l1, t2, s2, l2 = get_rds_ertplus_tags()
|
||||||
|
return string.format("ERTP=%d,%d,%d,%d,%d,%d\r\n", t1, s1, l1, t2, s2, l2)
|
||||||
else return "?" end
|
else return "?" end
|
||||||
-- TODO: more
|
-- TODO: more
|
||||||
end
|
end
|
||||||
@@ -146,6 +152,33 @@ if type(data) == "string" and data ~= nil then
|
|||||||
elseif cmd == "grpseq2" then
|
elseif cmd == "grpseq2" then
|
||||||
set_rds_grpseq2(value)
|
set_rds_grpseq2(value)
|
||||||
return "+"
|
return "+"
|
||||||
|
elseif cmd == "rtp" then
|
||||||
|
local t1, s1, l1, t2, s2, l2 = value:match("(%d+),(%d+),(%d+),(%d+),(%d+),(%d+)")
|
||||||
|
if not t1 or not l2 then return "-" end
|
||||||
|
---@diagnostic disable-next-line: param-type-mismatch
|
||||||
|
set_rds_rtplus_tags(tonumber(t1), tonumber(s1), tonumber(l1), tonumber(t2), tonumber(s2), tonumber(l2))
|
||||||
|
return "+"
|
||||||
|
|
||||||
|
elseif cmd == "ertp" then
|
||||||
|
local t1, s1, l1, t2, s2, l2 = value:match("(%d+),(%d+),(%d+),(%d+),(%d+),(%d+)")
|
||||||
|
if not t1 or not l2 then return "-" end
|
||||||
|
---@diagnostic disable-next-line: param-type-mismatch
|
||||||
|
set_rds_ertplus_tags(tonumber(t1), tonumber(s1), tonumber(l1), tonumber(t2), tonumber(s2), tonumber(l2))
|
||||||
|
return "+"
|
||||||
|
elseif cmd == "g" then
|
||||||
|
local a, b, c, d = value:match("^(%x%x%x%x)(%x%x%x%x)(%x%x%x%x)(%x%x%x%x)$")
|
||||||
|
if a and b and c and d then
|
||||||
|
put_rds2_custom_group(tonumber(a, 16), tonumber(b, 16), tonumber(c, 16), tonumber(d, 16))
|
||||||
|
return "+"
|
||||||
|
end
|
||||||
|
|
||||||
|
local b1, c1, d1 = value:match("^(%x%x%x%x)(%x%x%x%x)(%x%x%x%x)$")
|
||||||
|
if b1 and c1 and d1 then
|
||||||
|
put_rds_custom_group(tonumber(b1, 16), tonumber(c1, 16), tonumber(d1, 16))
|
||||||
|
return "+"
|
||||||
|
end
|
||||||
|
|
||||||
|
return "-"
|
||||||
else
|
else
|
||||||
return "?"
|
return "?"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -196,6 +196,22 @@ int lua_get_rds_ertplus_tags(lua_State *localL) {
|
|||||||
return 6;
|
return 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int lua_put_rds_custom_group(lua_State *localL) {
|
||||||
|
mod->enc->state[mod->enc->program].custom_group[0] = 1;
|
||||||
|
mod->enc->state[mod->enc->program].custom_group[1] = luaL_checkinteger(localL, 1);
|
||||||
|
mod->enc->state[mod->enc->program].custom_group[2] = luaL_checkinteger(localL, 2);
|
||||||
|
mod->enc->state[mod->enc->program].custom_group[3] = luaL_checkinteger(localL, 3);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int lua_put_rds2_custom_group(lua_State *localL) {
|
||||||
|
mod->enc->state[mod->enc->program].custom_group2[0] = 1;
|
||||||
|
mod->enc->state[mod->enc->program].custom_group2[1] = luaL_checkinteger(localL, 1);
|
||||||
|
mod->enc->state[mod->enc->program].custom_group2[2] = luaL_checkinteger(localL, 2);
|
||||||
|
mod->enc->state[mod->enc->program].custom_group2[3] = luaL_checkinteger(localL, 3);
|
||||||
|
mod->enc->state[mod->enc->program].custom_group2[4] = luaL_checkinteger(localL, 4);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
@@ -325,6 +341,9 @@ void init_lua(RDSModulator* rds_mod) {
|
|||||||
|
|
||||||
lua_register(L, "set_rds_ertplus_tags", lua_set_rds_ertplus_tags);
|
lua_register(L, "set_rds_ertplus_tags", lua_set_rds_ertplus_tags);
|
||||||
lua_register(L, "get_rds_ertplus_tags", lua_get_rds_ertplus_tags);
|
lua_register(L, "get_rds_ertplus_tags", lua_get_rds_ertplus_tags);
|
||||||
|
|
||||||
|
lua_register(L, "put_rds_custom_group", lua_put_rds_custom_group);
|
||||||
|
lua_register(L, "put_rds2_custom_group", lua_put_rds2_custom_group);
|
||||||
}
|
}
|
||||||
|
|
||||||
void run_lua(char *str, char *cmd_output) {
|
void run_lua(char *str, char *cmd_output) {
|
||||||
|
|||||||
Reference in New Issue
Block a user