mirror of
https://github.com/radio95-rnt/rds95.git
synced 2026-02-26 20:33:53 +01:00
better scheduling of oda
This commit is contained in:
@@ -93,10 +93,12 @@ local function get_data()
|
|||||||
|
|
||||||
if oda ~= false and type(oda.handler) == "function" then
|
if oda ~= false and type(oda.handler) == "function" then
|
||||||
local generated, b, c, d = oda.handler()
|
local generated, b, c, d = oda.handler()
|
||||||
_RDS_ODA_pointer = (_RDS_ODA_pointer % #_RDS_ODAs) + 1
|
if generated then
|
||||||
b = b | oda.group << 12
|
_RDS_ODA_pointer = (_RDS_ODA_pointer % #_RDS_ODAs) + 1
|
||||||
b = b | (oda.group_version and 1 or 0) << 11
|
b = b | oda.group << 12
|
||||||
return generated, b, c, d
|
b = b | (oda.group_version and 1 or 0) << 11
|
||||||
|
return generated, b, c, d
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
_RDS_ODA_pointer = (_RDS_ODA_pointer % #_RDS_ODAs) + 1
|
_RDS_ODA_pointer = (_RDS_ODA_pointer % #_RDS_ODAs) + 1
|
||||||
|
|||||||
@@ -102,17 +102,29 @@ function rds2_group(stream)
|
|||||||
_RDS2_ODA_aid = _RDS2_ODA_aid + 1
|
_RDS2_ODA_aid = _RDS2_ODA_aid + 1
|
||||||
if _RDS2_ODA_aid > 8 then _RDS2_ODA_aid = 0 end
|
if _RDS2_ODA_aid > 8 then _RDS2_ODA_aid = 0 end
|
||||||
if oda.handler then
|
if oda.handler then
|
||||||
local generated, a, b, c, d = oda.handler(stream)
|
local generated = false
|
||||||
local channel_bitshift = 8
|
checked = 0
|
||||||
local fid = (a & 0xC000) >> 14
|
while generated == false and checked < #_RDS2_ODAs do
|
||||||
local fn_msb = (a >> 13) & 1
|
local generated, a, b, c, d = oda.handler(stream)
|
||||||
if fid == 0 and fn_msb == 0 then
|
if not generated then
|
||||||
warn("RDS2 ODA is tunneling (A or B) over C")
|
_RDS2_ODA_pointer = _RDS2_ODA_pointer + 1
|
||||||
return true, 0, b, c, d -- Tunnel, not sure why but sure
|
if _RDS2_ODA_pointer > #_RDS2_ODAs then _RDS2_ODA_pointer = 1 end
|
||||||
--FID = 1 means a normal ODA group
|
oda = _RDS2_ODAs[_RDS2_ODA_pointer]
|
||||||
--FID = 2 means a RFT file
|
checked = checked + 1
|
||||||
elseif fid == 2 and fn_msb == 0 then channel_bitshift = 0 end -- This is AID
|
else
|
||||||
return generated, (channel << channel_bitshift) | a, b, c, d
|
local channel_bitshift = 8
|
||||||
|
local fid = (a & 0xC000) >> 14
|
||||||
|
local fn_msb = (a >> 13) & 1
|
||||||
|
if fid == 0 and fn_msb == 0 then
|
||||||
|
warn("RDS2 ODA is tunneling (A or B) over C")
|
||||||
|
return true, 0, b, c, d -- Tunnel, not sure why but sure
|
||||||
|
--FID = 1 means a normal ODA group
|
||||||
|
--FID = 2 means a RFT file
|
||||||
|
elseif fid == 2 and fn_msb == 0 then channel_bitshift = 0 end -- This is AID
|
||||||
|
return generated, (channel << channel_bitshift) | a, b, c, d
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if checked == #_RDS2_ODAs then return false, 0, 0, 0, 0 end
|
||||||
end
|
end
|
||||||
return true, (2 << 14) | channel, oda.aid, (oda.data >> 16) & 0xffff, oda.data & 0xffff
|
return true, (2 << 14) | channel, oda.aid, (oda.data >> 16) & 0xffff, oda.data & 0xffff
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user