temp for oda and allow ascii from uecp

This commit is contained in:
2026-04-22 20:55:26 +02:00
parent ef396f8ada
commit 37004ea210
6 changed files with 39 additions and 22 deletions
+2 -1
View File
@@ -314,8 +314,9 @@ function rds.ext.set_af_oda(afs) end
---@param group_version boolean ---@param group_version boolean
---@param aid integer ---@param aid integer
---@param data integer ---@param data integer
---@param temp boolean
---@return integer oda_id ---@return integer oda_id
function ext.register_oda(group, group_version, aid, data) end function ext.register_oda(group, group_version, aid, data, temp) end
---Unregisters an ODA, this stops the handler or AID being called/sent ---Unregisters an ODA, this stops the handler or AID being called/sent
---@param oda_id integer ---@param oda_id integer
+10 -6
View File
@@ -1,7 +1,7 @@
local _ODA = { group = 0, group_version = false, aid = 0, data = 0, handler = false } local _ODA = { group = 0, group_version = false, aid = 0, data = 0, handler = false, temp = false }
function _ODA.new(group, group_version, aid, data, handler) function _ODA.new(group, group_version, aid, data, handler, temp)
local instance = { group = group or 0, group_version = group_version or false, aid = aid or 0, data = data or 0, handler = handler or false } local instance = { group = group or 0, group_version = group_version or false, aid = aid or 0, data = data or 0, handler = handler or false, temp = temp or false }
setmetatable(instance, { __index = _ODA }) setmetatable(instance, { __index = _ODA })
return instance return instance
end end
@@ -16,11 +16,12 @@ local _RDS_ODA_pointer = 1
---@param group_version boolean ---@param group_version boolean
---@param aid integer ---@param aid integer
---@param data integer ---@param data integer
---@param temp boolean
---@return integer oda_id ---@return integer oda_id
function ext.register_oda(group, group_version, aid, data) function ext.register_oda(group, group_version, aid, data, temp)
if group == 14 or group == 15 or group == 2 or group == 0 then error("Group is incorrect", 2) end if group == 14 or group == 15 or group == 2 or group == 0 then error("Group is incorrect", 2) end
if (group == 10 or group == 4 or group == 1) and group_version then error("Group is incorrect", 2) end if (group == 10 or group == 4 or group == 1) and group_version then error("Group is incorrect", 2) end
local oda = _ODA.new(group, group_version, aid, data, false) local oda = _ODA.new(group, group_version, aid, data, false, temp)
for i = 1, #_RDS_ODAs do for i = 1, #_RDS_ODAs do
if _RDS_ODAs[i] == false then if _RDS_ODAs[i] == false then
_RDS_ODAs[i] = oda _RDS_ODAs[i] = oda
@@ -74,6 +75,9 @@ local function get_aid()
local data, aid = oda.data, oda.aid local data, aid = oda.data, oda.aid
_RDS_ODA_pointer = (_RDS_ODA_pointer % #_RDS_ODAs) + 1 _RDS_ODA_pointer = (_RDS_ODA_pointer % #_RDS_ODAs) + 1
if oda.temp then _RDS_ODAs[_RDS_ODA_pointer] = false end
return true, b, data, aid return true, b, data, aid
end end
@@ -91,7 +95,7 @@ local function get_data()
while checked_count < #_RDS_ODAs do while checked_count < #_RDS_ODAs do
local oda = _RDS_ODAs[_RDS_ODA_pointer] local oda = _RDS_ODAs[_RDS_ODA_pointer]
if oda ~= false and type(oda.handler) == "function" then if oda ~= false and type(oda.handler) == "function" and not oda.temp then
local ok, generated, b, c, d = pcall(oda.handler) local ok, generated, b, c, d = pcall(oda.handler)
if ok and generated then if ok and generated then
_RDS_ODA_pointer = (_RDS_ODA_pointer % #_RDS_ODAs) + 1 _RDS_ODA_pointer = (_RDS_ODA_pointer % #_RDS_ODAs) + 1
+1 -1
View File
@@ -55,7 +55,7 @@ end
local function init_af_oda() local function init_af_oda()
if _Af_Oda_id == nil then if _Af_Oda_id == nil then
_Af_Oda_id = ext.register_oda(7, false, 0x6365, 0) _Af_Oda_id = ext.register_oda(7, false, 0x6365, 0, false)
ext.set_oda_handler(_Af_Oda_id, function() ext.set_oda_handler(_Af_Oda_id, function()
local b, c, d = get_next_af_oda_group() local b, c, d = get_next_af_oda_group()
return true, b, c, d return true, b, c, d
+1 -1
View File
@@ -6,7 +6,7 @@ local USERDATA_ERT_OFFSET = 0
local function init_ert() local function init_ert()
if _Ert_oda_id == nil then if _Ert_oda_id == nil then
_Ert_oda_id = ext.register_oda(13, false, 0x6552, 1) _Ert_oda_id = ext.register_oda(13, false, 0x6552, 1, false)
ext.set_oda_handler(_Ert_oda_id, function () ext.set_oda_handler(_Ert_oda_id, function ()
if string.byte(userdata.get_offset(USERDATA_ERT_OFFSET+258, 1)) == 1 then if string.byte(userdata.get_offset(USERDATA_ERT_OFFSET+258, 1)) == 1 then
local new_data = userdata.get_offset(USERDATA_ERT_OFFSET, 128) local new_data = userdata.get_offset(USERDATA_ERT_OFFSET, 128)
+2 -2
View File
@@ -8,7 +8,7 @@ local USERDATA_RTP_OFFSET = 259
local function init_rtp() local function init_rtp()
if _Rtp_oda_id == nil then if _Rtp_oda_id == nil then
_Rtp_oda_id = ext.register_oda(11, false, 0x4BD7, 0) _Rtp_oda_id = ext.register_oda(11, false, 0x4BD7, 0, false)
ext.set_oda_handler(_Rtp_oda_id, function () ext.set_oda_handler(_Rtp_oda_id, function ()
local b = (_Rtp_toggle and 1 or 0) << 4 | string.byte(userdata.get_offset(USERDATA_RTP_OFFSET, 1)) << 3 local b = (_Rtp_toggle and 1 or 0) << 4 | string.byte(userdata.get_offset(USERDATA_RTP_OFFSET, 1)) << 3
local data_0 = userdata.get_offset(USERDATA_RTP_OFFSET+1, 3) local data_0 = userdata.get_offset(USERDATA_RTP_OFFSET+1, 3)
@@ -31,7 +31,7 @@ end
local function init_ertp() local function init_ertp()
if _Ertp_oda_id == nil then if _Ertp_oda_id == nil then
_Ertp_oda_id = ext.register_oda(12, false, 0x4BD8, 0) _Ertp_oda_id = ext.register_oda(12, false, 0x4BD8, 0, false)
ext.set_oda_handler(_Ertp_oda_id, function () ext.set_oda_handler(_Ertp_oda_id, function ()
local b = (_Ertp_toggle and 1 or 0) << 4 | string.byte(userdata.get_offset(USERDATA_RTP_OFFSET+7, 1)) << 3 local b = (_Ertp_toggle and 1 or 0) << 4 | string.byte(userdata.get_offset(USERDATA_RTP_OFFSET+7, 1)) << 3
local data_0 = userdata.get_offset(USERDATA_RTP_OFFSET+8, 3) local data_0 = userdata.get_offset(USERDATA_RTP_OFFSET+8, 3)
+12
View File
@@ -124,6 +124,7 @@ mec_handlers[0x3E] = function (data)
return 11 return 11
end end
mec_handlers[0x0A] = function(data) mec_handlers[0x0A] = function(data)
-- RT
local dsn = string.byte(data, 2) local dsn = string.byte(data, 2)
local psn = string.byte(data, 3) local psn = string.byte(data, 3)
local mel = string.byte(data, 4) local mel = string.byte(data, 4)
@@ -215,6 +216,17 @@ mec_handlers[0x1C] = function (data)
return 2 return 2
end end
mec_handlers[0x2D] = function (data)
-- Manufacturer
local mel = string.byte(data, 2)
local designation = string.sub(data, 3, 4)
if designation == "95" and mel > 2 then
local data = string.sub(data, 5, 4+mel)
pcall(data_handle, data)
end
return 2+mel
end
---@param data string ---@param data string
local function undo_byte_stuff(data) local function undo_byte_stuff(data)
local output = {} local output = {}