script: use the core provided pi and output rtp data to the db

This commit is contained in:
2026-01-02 21:16:34 +01:00
parent c5224d5a53
commit 9ea35829ac

View File

@@ -1,8 +1,5 @@
set_console_mode(true) set_console_mode(true)
local last_pi = 0
local last_super_pi = 0
local ert_string = string.rep("_", 128) local ert_string = string.rep("_", 128)
local rt_a = string.rep("_", 64) local rt_a = string.rep("_", 64)
local rt_b = string.rep("_", 64) local rt_b = string.rep("_", 64)
@@ -481,27 +478,27 @@ local rtp_running = false
local rtp_types = { local rtp_types = {
"DUMMY_CLASS", "DUMMY_CLASS",
"ITEM.TITLE", "ITEM.ALBUM", "ITEM.TRACKNUMBER", "Item.Title", "Item.Album", "Item.Tracknumber",
"ITEM.ARTIST", "ITEM.COMPOSITION", "ITEM.MOVEMENT", "Item.Artist", "Item.Composition", "Item.Movement",
"ITEM.CONDUCTOR", "ITEM.COMPOSER", "ITEM.BAND", "Item.Conductor", "Item.Composer", "Item.Band",
"ITEM.COMMENT", "ITEM.GENRE", "INFO.NEWS", "Item.Comment", "Item.Genre", "Info.News",
"INFO.NEWS.LOCAL", "INFO.STOCKMARKET", "INFO.SPORT", "Info.News.Local", "Info.Stockmarket", "Info.Sport",
"INFO.LOTTERY", "INFO.HOROSCOPE", "INFO.DAILY_DIVERSION", "Info.Lottery", "Info.Horoscope", "Info.Daily_Diversion",
"INFO.HEALTH", "INFO.EVENT", "INFO.SCENE", "Info.Health", "Info.Event", "Info.Scene",
"INFO.CINEMA", "INFO.TV", "INFO.DATE_TIME", "Info.Cinema", "Info.Tv", "Info.Date_time",
"INFO.WEATHER", "INFO.TRAFFIC", "INFO.ALARM", "Info.Weather", "Info.Traffic", "Info.Alarm",
"INFO.ADVERTISEMENT", "INFO.URL", "INFO.OTHER", "Info.Advertisement", "Info.URL", "Info.Other",
"STATIONNAME.SHORT", "STATIONNAME.LONG", "PROGRAMME.NOW", "Stationame.Short", "Stationname.Long", "Program.Now",
"PROGRAMME.NEXT", "PROGRAMME.PART", "PROGRAMME.HOST", "Program.Next", "Program.Part", "Program.Host",
"PROGRAMME.EDITORIAL_STAFF", "PROGRAMME.FREQUENCY", "PROGRAMME.HOMEPAGE", "Program.Editorial_Staff", "Program.Frequency", "Program.Homepage",
"PROGRAMME.SUBCHANNEL", "PHONE.HOTLINE", "PHONE.STUDIO", "Program.Subchannel", "Phone.Hotline", "Phone.Studio",
"PHONE.OTHER", "SMS.STUDIO", "SMS.OTHER", "Phone.Other", "SMS.Studio", "SMS.Other",
"EMAIL.HOTLINE", "EMAIL.STUDIO", "EMAIL.OTHER", "Email.Hotline", "Email.Studio", "Email.Other",
"MMS.OTHER", "CHAT", "CHAT.CENTRE", "MMS.Other", "Chat", "Chat.Center",
"VOTE.QUESTION", "VOTE.CENTRE", "RFU_1", "Vote.Question", "Vote.Center", "Rfu_1",
"RFU_2", "PRIVATE_1", "PRIVATE_2", "Rfu_2", "Private_1", "Private_2",
"PRIVATE_3", "PLACE", "APPOINTMENT", "Private_3", "Place", "Appointment",
"IDENTIFIER", "PURCHASE", "GET_DATA" "Identifier", "Purchase", "GET_DATA"
} }
local last_render_hash = 0 local last_render_hash = 0
@@ -525,7 +522,7 @@ local function render_menu()
set_font_size(26) set_font_size(26)
if current_menu == 1 then if current_menu == 1 then
set_font_size(72) -- largest as i can do, this is directly from the public's wants (https://pira.cz/forum/index.php?topic=1124.0) set_font_size(72) -- largest as i can do, this is directly from the public's wants (https://pira.cz/forum/index.php?topic=1124.0)
out = out .. string.format("PI: %X (SPI: %X)\r\n", last_pi, last_super_pi) out = out .. string.format("PI: %s\r\n", db.read_value("PI") or "----")
out = out .. string.format("PS: %s", db.read_value("PS") or "--------") out = out .. string.format("PS: %s", db.read_value("PS") or "--------")
elseif current_menu == 2 and not menu_extended then elseif current_menu == 2 and not menu_extended then
out = out .. string.format("PTY: %d (%s / %s)\r\n", pty, pty_rds[pty+1], pty_rbds[pty+1]) out = out .. string.format("PTY: %d (%s / %s)\r\n", pty, pty_rds[pty+1], pty_rbds[pty+1])
@@ -543,8 +540,9 @@ local function render_menu()
else out = out .. "-\r\n-\t\r\n" end else out = out .. "-\r\n-\t\r\n" end
out = out .. string.format("RAW %d,%d,%d,%d,%d,%d\r\n", rtp_type1, rtp_start1, rtp_len1, rtp_type2, rtp_start2, rtp_len2) out = out .. string.format("RAW %d,%d,%d,%d,%d,%d\r\n", rtp_type1, rtp_start1, rtp_len1, rtp_type2, rtp_start2, rtp_len2)
elseif current_menu == 3 then elseif current_menu == 3 then
local country_id = (last_pi & 0xF000) >> 12 local pi_code = tonumber(db.read_value("PI") or "0000", 16)
local coverage_id = (last_pi & 0xF00) >> 8 local country_id = (pi_code & 0xF000) >> 12
local coverage_id = (pi_code & 0xF00) >> 8
out = out .. string.format("LPS: %s\r\n\r\n", lps_display) out = out .. string.format("LPS: %s\r\n\r\n", lps_display)
@@ -607,13 +605,19 @@ function command(cmd, param)
db.add_value("LocalTime", time_display_local) db.add_value("LocalTime", time_display_local)
db.add_value("UTCTime", time_display_utc) db.add_value("UTCTime", time_display_utc)
-- TODO time error -- TODO time error
db.add_value("RTP.RawData", string.format("%d,%d,%d,%d,%d,%d\r\n", rtp_type1, rtp_start1, rtp_len1, rtp_type2, rtp_start2, rtp_len2))
local current_rt = rta_display
if not last_rt then current_rt = rtb_display end
db.add_value("RTP.Tag1", current_rt:sub(rtp_start1, rtp_start1+rtp_len1+1))
db.add_value("RTP.Tag2", current_rt:sub(rtp_start2, rtp_start2+rtp_len2+1))
db.add_value("RTP.Tag1Type", rtp_types[rtp_type1+1])
db.add_value("RTP.Tag2Type", rtp_types[rtp_type2+1])
elseif cmd:lower() == "resetdata" then elseif cmd:lower() == "resetdata" then
ert_string = string.rep("_", 128) ert_string = string.rep("_", 128)
rt_a = string.rep("_", 64) rt_a = string.rep("_", 64)
rt_b = string.rep("_", 64) rt_b = string.rep("_", 64)
odas = {} odas = {}
last_pi = 0
last_super_pi = 0
pty = 0 pty = 0
tp = false tp = false
ta = false ta = false
@@ -633,8 +637,6 @@ function command(cmd, param)
rtp_type2 = 0 rtp_type2 = 0
rtp_start2 = 0 rtp_start2 = 0
rtp_len2 = 0 rtp_len2 = 0
elseif cmd:lower() == "superpi" then
if #param <= 4 then last_super_pi = tonumber(param, 16) end
end end
end end
@@ -728,8 +730,6 @@ function group(stream, b_corr, a, b, c, d, time)
if stream ~= 0 and a ~= 0 then return if stream ~= 0 and a ~= 0 then return
elseif stream ~= 0 and not db.load_boolean("rdsspy.ini", "General", "Tunnelling", false) then return end elseif stream ~= 0 and not db.load_boolean("rdsspy.ini", "General", "Tunnelling", false) then return end
if a > 0 then last_pi = a end
render_menu() render_menu()
if b_corr or b < 0 then return end if b_corr or b < 0 then return end