

function HM_TC_dissector(buffer, pinfo, subtree, TC_TM_PROTOCOL, offset)

  local f_sub_mod_id = ProtoField.uint8("TC_TM_PROTOCOL.sub_mod_id", "SUB MODULE ID", base.DEC)
local f_Queue_id = ProtoField.uint8("TC_TM_PROTOCOL.Queue_id", "QUEUE ID", base.DEC)
local f_priority = ProtoField.uint8("TC_TM_PROTOCOL.priority", "PRIORITY", base.DEC)
local f_opt_sel_sin_mul_que = ProtoField.uint8("TC_TM_PROTOCOL.opt_sel_sin_mul_que", "Option To Select Single Or Multiple Queue", base.DEC)

-- Add the fields to the protocol
TC_TM_PROTOCOL.fields = { f_sub_mod_id, f_Queue_id, f_priority, f_opt_sel_sin_mul_que }

    --local info_display
    subtree1 = subtree:add(TC_TM_PROTOCOL, buffer(), "HEALTH_METRIC_DATA")
  
     --dissect submodule_id
     local data1 = buffer(offset,1):le_uint()
     subtree1:add(f_sub_mod_id , data1)
     offset = offset + 1
     
     --dissect queue_id
     local data2 = buffer(offset,1):le_uint()
     subtree1:add(f_Queue_id, data2)
     offset = offset + 1
     
     --dissect f_priority
     local data3 = buffer(offset,1):le_uint()
     subtree1:add(f_priority, data3)
      offset = offset + 1     
     --dissect option to select_single or multiple queue
     local data4 = buffer(offset,1):le_uint()
     subtree1:add(f_opt_sel_sin_mul_que, data4)
     
     --info_display= {data1} --- for info display in wireshark
     --pinfo.cols.info ="sub_mod_id" ..info_display[1]
  
    return data1     
end 


function HM_TM_dissector(buffer, pinfo, subtree, TC_TM_PROTOCOL, offset, len)

local f_sub_mod_id = ProtoField.uint8("TC_TM_PROTOCOL.sub_mod_id", "SUB MODULE ID", base.DEC)
local f_Queue_id = ProtoField.uint8("TC_TM_PROTOCOL.Queue_id", "QUEUE ID", base.DEC)
local f_num_of_instance = ProtoField.uint16("TC_TM_PROTOCOL.num_of_instance", "Number of Instance", base.DEC)
local f_Health_Data = ProtoField.uint8("TC_TM_PROTOCOL.Health_Data", "Health Data", base.DEC)

-- Add the fields to the protocol
TC_TM_PROTOCOL.fields = { f_sub_mod_id, f_Queue_id, f_num_of_instance, f_Health_Data }

   --local info_display
   local subtree1 = subtree:add(TC_TM_PROTOCOL, buffer(), "HEALTH_METRIC_DATA")
  
     --dissect submodule_id
     local submodule_id = buffer(offset,1):le_uint()
     subtree1:add(f_sub_mod_id , submodule_id)
     offset = offset + 1
     
     --dissect queue_id
     local queue_id = buffer(offset,1):le_uint()
     subtree1:add(f_Queue_id, queue_id)
     offset = offset + 1
     
     --dissect f_num_of_instance
     local num_of_instance = buffer(offset,2):le_uint()
     subtree1:add(f_num_of_instance, num_of_instance)
      offset = offset + 2  
      
     --dissect Health_Data
     len = len - 4
     if submodule_id == 0  then
     	require("eps_dissector")
      	dissect_power_system_data(buffer, pinfo, subtree, TC_TM_PROTOCOL, offset, tm_len, num_of_instance)
     elseif submodule_id == 1  then
     	require("adcs_dissector")
      	adcs_dissector(buffer, pinfo, subtree, TC_TM_PROTOCOL, offset, num_of_instance, queue_id)
     elseif submodule_id == 3  then
        require("uhf_dissector")
        UHF_DISSECTOR(buffer, pinfo, subtree, TC_TM_PROTOCOL, offset, tm_len, num_of_instance)
     elseif submodule_id == 4 then
         require("sensor_dissector")
         sensor_dissector(buffer, pinfo, subtree, TC_TM_PROTOCOL, offset, num_of_instance, queue_id)
     elseif submodule_id == 5 then
        require("obc_dissector")
        obc_dissector(buffer, pinfo, subtree, TC_TM_PROTOCOL, offset, num_of_instance)     
     elseif submodule_id == 2 then 
       require("sband_dissector")
       sband_dissectors(buffer, pinfo, subtree, TC_TM_PROTOCOL, offset, num_of_instance)
     elseif submodule_id == 6 then 
       require("error_handler_dissector")
       error_handler_dissector(buffer, pinfo, subtree, TC_TM_PROTOCOL, offset, num_of_instance)
     else
       
         for i = 0, len - 1 do
         local data4 = buffer(offset,1):le_uint()
         subtree1:add(f_Health_Data, data4)
         offset = offset + 1
         end
       end  
     
     local array = {submodule_id, queue_id, num_of_instance}
     
     return array

end





