Browse Source

add obc dissector

priyadharsan 4 months ago
parent
commit
8e49b525fb
3 changed files with 150 additions and 42 deletions
  1. 32 19
      Dissector/hm_dissector.lua
  2. 100 0
      Dissector/obc_dissector.lua
  3. 18 23
      Dissector/tc_tm_protocols.lua

+ 32 - 19
Dissector/hm_dissector.lua

@@ -1,6 +1,6 @@
 
 
-function HM_dissector(buffer, pinfo, tree, TC_TM_PROTOCOL, offset)
+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)
@@ -11,34 +11,34 @@ local f_opt_sel_sin_mul_que = ProtoField.uint8("TC_TM_PROTOCOL.opt_sel_sin_mul_q
 TC_TM_PROTOCOL.fields = { f_sub_mod_id, f_Queue_id, f_priority, f_opt_sel_sin_mul_que }
 
     --local info_display
-  local subtree = tree:add(TC_TM_PROTOCOL, buffer(), "HEALTH_METRIC_DATA")
+    subtree1 = subtree:add(TC_TM_PROTOCOL, buffer(), "HEALTH_METRIC_DATA")
   
      --dissect submodule_id
      local data1 = buffer(offset,1):le_uint()
-     subtree:add(f_sub_mod_id , data1)
+     subtree1:add(f_sub_mod_id , data1)
      offset = offset + 1
      
      --dissect queue_id
      local data2 = buffer(offset,1):le_uint()
-     subtree:add(f_Queue_id, data2)
+     subtree1:add(f_Queue_id, data2)
      offset = offset + 1
      
      --dissect f_priority
      local data3 = buffer(offset,1):le_uint()
-     subtree:add(f_priority, data3)
+     subtree1:add(f_priority, data3)
       offset = offset + 1     
      --dissect option to select_single or multiple queue
      local data4 = buffer(offset,1):le_uint()
-     subtree:add(f_opt_sel_sin_mul_que, data4)
+     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, tree, TC_TM_PROTOCOL, offset, len)
+
+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)
@@ -48,32 +48,45 @@ local f_Health_Data = ProtoField.uint8("TC_TM_PROTOCOL.Health_Data", "Health Dat
 -- 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 len1 = 0
    --local info_display
-  local subtree = tree:add(TC_TM_PROTOCOL, buffer(), "HEALTH_METRIC_DATA")
+   local subtree1 = subtree:add(TC_TM_PROTOCOL, buffer(), "HEALTH_METRIC_DATA")
   
      --dissect submodule_id
      local data1 = buffer(offset,1):le_uint()
-     subtree:add(f_sub_mod_id , data1)
+     subtree1:add(f_sub_mod_id , data1)
      offset = offset + 1
      
      --dissect queue_id
      local data2 = buffer(offset,1):le_uint()
-     subtree:add(f_Queue_id, data2)
+     subtree1:add(f_Queue_id, data2)
      offset = offset + 1
      
      --dissect f_num_of_instance
      local data3 = buffer(offset,2):le_uint()
-     subtree:add(f_num_of_instance, data3)
-      offset = offset + 2    
+     subtree1:add(f_num_of_instance, data3)
+      offset = offset + 2  
       
-	local array1
      --dissect Health_Data
-    if data1 == 0  then
-        require("EPS")
-      dissect_power_system_data(buffer, pinfo, tree, TC_TM_PROTOCOL, offset, tm_len,data3)
+     len =len - 3
+     if data1 == 5 then
+       require("obc_dissector")
+       
+        --for i=0, data3-1 do
+        
+         obc_dissector(buffer, pinfo, subtree1, TC_TM_PROTOCOL, offset, data3)
+     
+     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 = {data1, data2, data3,array1}
+       
+     
+     local array = {data1, data2, data3}
      
      return array
 

+ 100 - 0
Dissector/obc_dissector.lua

@@ -0,0 +1,100 @@
+function obc_dissector(buffer, pinfo, subtree, TC_TM_PROTOCOL, offset, instance)
+  
+  local f_timestamp1 = ProtoField.uint64("TC_TM_PROTOCOL.timestamp1", "Timestamp", base.DEC)
+  local f_fsm_state = ProtoField.uint8("TC_TM_PROTOCOL.fsm_state", "Fsm State", base.DEC)
+  local f_num_resets = ProtoField.uint8("TC_TM_PROTOCOL.num_resets", "Num of resets", base.DEC)
+  local f_io_error = ProtoField.uint16("TC_TM_PROTOCOL.io_error", "IO error", base.DEC)
+  local f_sys_error = ProtoField.uint8("TC_TM_PROTOCOL.sys_error", "Sys error", base.DEC)
+  local f_cpu_until = ProtoField.float("TC_TM_PROTOCOL.cpu_until", "Cpu Until", base.DEC)
+  local f_iram_rem_heap = ProtoField.uint32("TC_TM_PROTOCOL.iram_rem_heap", "Iram rem heap", base.DEC)
+  local f_eram_rem_heap = ProtoField.uint32("TC_TM_PROTOCOL.eram_rem_heap", "Eram rem heap", base.DEC)
+  local f_uptime = ProtoField.uint32("TC_TM_PROTOCOL.uptime", "Uptime", base.DEC)
+  local f_reset_cause = ProtoField.uint8("TC_TM_PROTOCOL.reset_cause", "Reset cause", base.DEC)
+  local f_task_count = ProtoField.uint8("TC_TM_PROTOCOL.task_count", "Task Count", base.DEC)
+  local ipc_fail_cntr = ProtoField.uint16("TC_TM_PROTOCOL.ipc_fail_cntr", "Ipc Fail Cntr", base.DEC)
+
+  -- Add the fields to the protocol
+TC_TM_PROTOCOL.fields = {
+    f_timestamp1, f_fsm_state, f_num_resets,f_io_error, f_sys_error, f_cpu_until, f_iram_rem_heap,
+    f_eram_rem_heap, f_uptime, f_reset_cause, f_task_count, f_ipc_fail_cntr
+}
+for i=0, instance-1 do
+  local subtree1 = subtree:add(TC_TM_PROTOCOL, buffer(), "HEALTH METRIC DATA OBC")
+   -- dissect timestamp 
+   local data1
+     --for i=0, 8 do
+     --data1 = buffer(offset, 8):le_uint()
+     subtree1:add(f_timestamp1, buffer(offset, 8):le_uint64())
+     offset = offset + 8
+     
+     --dissect fsm_state
+     --local data2 = buffer(offset,1):le_uint()
+     subtree1:add(f_fsm_state, buffer(offset,1):le_uint())
+     offset = offset + 1
+     
+     --dissect f_num_resets
+     local data3 = buffer(offset,1):le_uint()
+     subtree1:add(f_num_resets, data3)
+      offset = offset + 1  
+      
+      --dissect io_error
+     subtree1:add(f_io_error , buffer(offset, 2):le_uint())
+     offset = offset + 2
+     
+     --dissect sys_error
+     --local data2 = buffer(offset,1):le_uint()
+     subtree1:add(f_sys_error, buffer(offset, 1):le_uint())
+     offset = offset + 1
+     
+     
+     --dissect f_cpu_until
+     local cpu_value = buffer(offset, 4):le_float()
+     
+     local formatted_value = string.format("%.6f", cpu_value)
+      subtree1:add(f_cpu_until, formatted_value)
+     offset = offset + 4
+   
+     --dissect f_iram_rem_heap
+      subtree1:add(f_iram_rem_heap, buffer(offset, 4):le_uint())
+     offset = offset + 4
+     
+      --dissect f_eram_rem_heap
+      subtree1:add(f_eram_rem_heap, buffer(offset, 4):le_uint())
+     offset = offset + 4
+     
+     --dissect f_uptime
+      subtree1:add(f_uptime, buffer(offset, 4):le_uint())
+     offset = offset + 4
+     
+       --dissect f_reset_cause
+      subtree1:add(f_reset_cause, buffer(offset, 1):le_uint())
+     offset = offset + 1
+     
+     --dissect f_task_count
+     local task_count = buffer(offset, 1):le_uint()
+      subtree1:add(f_task_count, buffer(offset, 1):le_uint())
+     offset = offset + 1
+     
+     
+     for i=0, task_count - 1 do
+       local fail = buffer(offset, 2):le_uint()
+       if fail == 0 then
+         i = i + 2
+         offset = offset + 2
+         
+       else
+         subtree1:add(f_ipc_fail_cntr, buffer(offset, 2):le_uint())
+         offset = offset + 2
+         i = i + 2
+       end
+     end
+     
+   end
+     
+     
+end
+      
+      
+      
+         
+      

+ 18 - 23
Dissector/tc_tm_protocols.lua

@@ -14,7 +14,7 @@ local f_da_id = ProtoField.uint16("TC_TM_PROTOCOL.da_id", "DA Id", base.DEC)
 local f_rm_id = ProtoField.uint8("TC_TM_PROTOCOL.rm_id", "RM Id", base.DEC)
 local f_tm_id = ProtoField.uint16("TC_TM_PROTOCOL.tm_id", "TM Id", base.DEC)
 local f_co_id = ProtoField.uint16("TC_TM_PROTOCOL.co_id", "Co Id", base.DEC)
-local f_tm_len = ProtoField.uint16("TC_TM_PROTOCOL.tm_len", "TM Len", base.HEX)
+local f_tm_len = ProtoField.uint16("TC_TM_PROTOCOL.tm_len", "TM Len", base.DEC)
 local f_tm_data = ProtoField.uint8("TC_TM_PROTOCOL.tm_data", "TM Data", base.DEC)
 local f_ext_header_len = ProtoField.uint8("TC_TM_PROTOCOL.ext_header_len", "Ext Header Len", base.DEC)
 local f_ext_header_data = ProtoField.uint8("TC_TM_PROTOCOL.ext_header_data", "Ext Header Data", base.DEC)
@@ -234,7 +234,7 @@ end
               
                  require("hm_dissector")
 
-                data = HM_dissector(buffer, pinfo, tree, TC_TM_PROTOCOL, offset)
+                data = HM_TC_dissector(buffer, pinfo, subtree, TC_TM_PROTOCOL, offset)
                 offset = offset + tc_len   
               else
 	              for i=0,tc_len - 1 do
@@ -300,7 +300,7 @@ end
     info_display= {buffer(11, 2):le_uint(),buffer(7, 4):le_uint() ,tc_id, string} --- for info display in wireshark
 
     
-    pinfo.cols.info ="seq_no = " ..info_display[1] .." TS = " ..info_display[2].." TC_ID = "..info_display[3].." Module = " ..info_display[4] -- for info display in wireshark
+    pinfo.cols.info ="seq_no = " ..info_display[1] ..", TS = " ..info_display[2]..", TC_ID = "..info_display[3]..", Module = " ..info_display[4] -- for info display in wireshark
 
 end
 
@@ -431,7 +431,7 @@ function TM_dissector(buffer, pinfo, tree)  -- OBC to GS
       if tm_id == 621  then
       
         require("hm_dissector")
-        array = HM_TM_dissector(buffer, pinfo, tree, TC_TM_PROTOCOL, add, tm_len)
+        array = HM_TM_dissector(buffer, pinfo, subtree, TC_TM_PROTOCOL, add, tm_len)
         add = add + tm_len
       
       else
@@ -473,29 +473,24 @@ function TM_dissector(buffer, pinfo, tree)  -- OBC to GS
     local string
     if tm_id == 621 then
     
-    	local switch = {
-    	[0] = function() return "EPS" end, 
-    	[1] = function() return "ADCS" end,
-    	[2] = function() return "COMMS SBAND CNTRL" end,
-    	[3] = function() return "COMMS_UHF_CNTRL" end,
-    	[4] = function() return "SENSOR" end,
-    	[5] = function() return "OBC" end,
-    	[6] = function() return "ERROR HANDLER" end
-    	}
-    	string = (switch[array[1]] or function() return "All Module" end)()
-    
+    local switch = {
+    [0] = function() return "EPS" end, 
+    [1] = function() return "ADCS" end,
+    [2] = function() return "COMMS SBAND CNTRL" end,
+    [3] = function() return "COMMS_UHF_CNTRL" end,
+    [4] = function() return "SENSOR" end,
+    [5] = function() return "OBC" end,
+    [6] = function() return "ERROR HANDLER" end
+    }
+    string = (switch[array[1]] or function() return "All Module" end)()
     
+    end
     
-    	info_display= {buffer(11, 2):le_uint(),buffer(7, 4):le_uint() ,tm_id, string, array[2], array[3]} --- for info display in wireshark
+    info_display= {buffer(11, 2):le_uint(),buffer(7, 4):le_uint() ,tm_id, string, array[2], array[3]} --- for info display in wireshark
 
 	 
-	pinfo.cols.info ="Seq_no = " ..info_display[1] .." TS = " ..info_display[2].." TM ID = "..info_display[3].." Module = "..info_display[4].." Queue id = "..info_display[5].." Number of instance = "..info_display[6] -- for info display in wireshark
-    else
-        info_display= {buffer(11, 2):le_uint(),buffer(7, 4):le_uint() ,tm_id} --- for info display in wireshark
+	pinfo.cols.info ="Seq_no = " ..info_display[1] ..", TS = " ..info_display[2]..", TM ID = "..info_display[3]..", Module = "..info_display[4]..", Queue id = "..info_display[5]..", Number of instance = "..info_display[6] -- for info display in wireshark
 
-	 
-	pinfo.cols.info ="Seq_no = " ..info_display[1] .." TS = " ..info_display[2].." TM ID = "..info_display[3] -- for info display in wireshark
-    end
     -- Check if the buffer contains enough data for the expected total length
    --if buffer:len() < 38 + buffer(21, 2):uint() then
      --   subtree:add_expert_info(PI_MALFORMED, PI_WARN, "Incomplete data")
@@ -530,7 +525,7 @@ end
 ------------------------------------------------------------------------------------------------------------------------------------------------
 
 -- Add a preference for the port number
-TC_TM_PROTOCOL.prefs.port = Pref.uint("UDP Port", 6779, "UDP port for TC_TM protocol")
+TC_TM_PROTOCOL.prefs.port = Pref.uint("UDP Port", 6767, "UDP port for TC_TM protocol")
 
 -- Register the dissector based on the preference
 function TC_TM_PROTOCOL.init()