function UHF_DISSECTOR(buffer, pinfo, tree, HM_TM_dissector, offset, tm_len,data3)
        -- UHF_DISSECTOR(buffer, pinfo, tree, TC_TM_PROTOCOL, offset, tm_len,data3)

-- Define ProtoFields for each element of the structure (like in your original example)
local f_cnt_hk_str = ProtoField.uint8("TC_TM_PROTOCOL.cnt_hk_str", "cnt_hk_str", base.DEC)
local f_timestamp = ProtoField.uint32("TC_TM_PROTOCOL.timestamp1", "timestamp", base.DEC)
local f_uptime = ProtoField.uint32("TC_TM_PROTOCOL.uptime", "Uptime", base.DEC)
local f_uarto_rx_count = ProtoField.uint32("TC_TM_PROTOCOL.uarto_rx_count", "UART0 RX Count", base.DEC)
local f_uart1_rx_count = ProtoField.uint32("TC_TM_PROTOCOL.uart1_rx_count", "UART1 RX Count", base.DEC)
local f_rx_mode = ProtoField.uint8("TC_TM_PROTOCOL.rx_mode", "RX Mode", base.DEC)
local f_tx_mode = ProtoField.uint8("TC_TM_PROTOCOL.tx_mode", "TX Mode", base.DEC)
local f_adc = ProtoField.uint16("TC_TM_PROTOCOL.adc", "ADC", base.DEC) -- array of int16_t[10]
local f_last_rssi = ProtoField.uint8("TC_TM_PROTOCOL.last_rssi", "Last RSSI", base.DEC)
local f_last_lqi = ProtoField.uint8("TC_TM_PROTOCOL.last_lqi", "Last LQI", base.DEC)
local f_last_freqest = ProtoField.uint8("TC_TM_PROTOCOL.last_freqest", "Last Frequency Estimate", base.DEC)
local f_pkt_sent = ProtoField.uint32("TC_TM_PROTOCOL.Pkt_sent", "Packets Sent", base.DEC)
local f_cs_count = ProtoField.uint32("TC_TM_PROTOCOL.cs_count", "CS Count", base.DEC)
local f_pkt_good = ProtoField.uint32("TC_TM_PROTOCOL.Pkt_good", "Packets Good", base.DEC)
local f_pkt_rejected_checksum = ProtoField.uint32("TC_TM_PROTOCOL.Pkt_rejected_checksum", "Packets Rejected (Checksum)", base.DEC)
local f_pkt_rejected_reserved = ProtoField.uint32("TC_TM_PROTOCOL.Pkt_rejected_reserved", "Packets Rejected (Reserved)", base.DEC)
local f_pkt_rejected_other = ProtoField.uint32("TC_TM_PROTOCOL.Pkt_rejected_other", "Packets Rejected (Other)", base.DEC)
local f_reserved0 = ProtoField.uint32("TC_TM_PROTOCOL.reserved0", "Reserved0", base.DEC)
-- local f_reserved1 = ProtoField.uint32("TC_TM_PROTOCOL.reserved1", "Reserved1", base.DEC) -- Uncomment if needed
local f_customo = ProtoField.uint32("TC_TM_PROTOCOL.customo", "Custom 0", base.DEC)
local f_custom1 = ProtoField.uint32("TC_TM_PROTOCOL.custom1", "Custom 1", base.DEC)

-- Add the fields to the protocol
HM_TM_dissector.fields = {
    f_timestamp,
    f_cnt_hk_str,
    f_uptime,
    f_uarto_rx_count,
    f_uart1_rx_count,
    f_rx_mode,
    f_tx_mode,
    f_adc,
    f_last_rssi,
    f_last_lqi,
    f_last_freqest,
    f_pkt_sent,
    f_cs_count,
    f_pkt_good,
    f_pkt_rejected_checksum,
    f_pkt_rejected_reserved,
    f_pkt_rejected_other,
    f_reserved0,
    -- f_reserved1, -- Uncomment if you want to include reserved1
    f_customo,
    f_custom1
}

local subtree = tree:add(TC_TM_PROTOCOL, buffer(), "UHF")

-- For your dissection function (within a loop structure)
for i = 0, data3 - 1 do
    --offset = offset + 8
    local subtree1 = subtree:add(TC_TM_PROTOCOL, buffer(), "Instance "..i)
	
    --local a = buffer(offset, 1):le_uint()
    --subtree1:add(f_cnt_hk_str, a)
    --offset = offset + 1
    
    local b = buffer(offset, 4):le_uint()
    subtree1:add(f_timestamp, b)
    offset = offset + 8
    --b = buffer(offset, 4):le_uint()
    --subtree1:add(f_timestamp, b)
    --offset = offset + 4

    -- dissect uptime
    local uptime = buffer(offset, 4):le_uint()
    subtree1:add(f_uptime, uptime)
    offset = offset + 4

    -- dissect uarto_rx_count
    local uarto_rx_count = buffer(offset, 4):le_uint()
    subtree1:add(f_uarto_rx_count, uarto_rx_count)
    offset = offset + 4

    -- dissect uart1_rx_count
    local uart1_rx_count = buffer(offset, 4):le_uint()
    subtree1:add(f_uart1_rx_count, uart1_rx_count)
    offset = offset + 4

    -- dissect rx_mode
    local rx_mode = buffer(offset, 1):le_uint()
    subtree1:add(f_rx_mode, rx_mode)
    offset = offset + 1

    -- dissect tx_mode
    local tx_mode = buffer(offset, 1):le_uint()
    subtree1:add(f_tx_mode, tx_mode)
    offset = offset + 1

    -- dissect adc (array of int16, loop through based on 10 elements)
    for j = 1, 10 do
        local adc_value = buffer(offset, 2):le_int()
        subtree1:add(f_adc, adc_value)
        offset = offset + 2
    end

    -- dissect last_rssi
    local last_rssi = buffer(offset, 1):le_int()
    subtree1:add(f_last_rssi, last_rssi)
    offset = offset + 1

    -- dissect last_lqi
    local last_lqi = buffer(offset, 1):le_uint()
    subtree1:add(f_last_lqi, last_lqi)
    offset = offset + 1

    -- dissect last_freqest
    local last_freqest = buffer(offset, 1):le_int()
    subtree1:add(f_last_freqest, last_freqest)
    offset = offset + 1

    -- dissect Pkt_sent
    local pkt_sent = buffer(offset, 4):le_uint()
    subtree1:add(f_pkt_sent, pkt_sent)
    offset = offset + 4

    -- dissect cs_count
    local cs_count = buffer(offset, 4):le_uint()
    subtree1:add(f_cs_count, cs_count)
    offset = offset + 4

    -- dissect Pkt_good
    local pkt_good = buffer(offset, 4):le_uint()
    subtree1:add(f_pkt_good, pkt_good)
    offset = offset + 4

    -- dissect Pkt_rejected_checksum
    local pkt_rejected_checksum = buffer(offset, 4):le_uint()
    subtree1:add(f_pkt_rejected_checksum, pkt_rejected_checksum)
    offset = offset + 4

    -- dissect Pkt_rejected_reserved
    local pkt_rejected_reserved = buffer(offset, 4):le_uint()
    subtree1:add(f_pkt_rejected_reserved, pkt_rejected_reserved)
    offset = offset + 4

    -- dissect Pkt_rejected_other
    local pkt_rejected_other = buffer(offset, 4):le_uint()
    subtree1:add(f_pkt_rejected_other, pkt_rejected_other)
    offset = offset + 4

    -- dissect reserved0
    local reserved0 = buffer(offset, 4):le_uint()
    subtree1:add(f_reserved0, reserved0)
    offset = offset + 9

    -- dissect customo
    --local customo = buffer(offset, 4):le_uint()
    --subtree1:add(f_customo, customo)
    --offset = offset + 4

    -- dissect custom1
    --local custom1 = buffer(offset, 4):le_uint()
    --subtree1:add(f_custom1, custom1)
    --offset = offset + 4

    -- (continue for any other fields you want to dissect, e.g., reserved1 if needed)
end


end