Browse Source

add sband dissector

priyadharsan 4 months ago
parent
commit
c54aeebaf6
2 changed files with 205 additions and 25 deletions
  1. 36 25
      Dissector/hm_dissector.lua
  2. 169 0
      Dissector/sband_dissector.lua

+ 36 - 25
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,38 +48,49 @@ 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_dissector")
-      dissect_power_system_data(buffer, pinfo, tree, TC_TM_PROTOCOL, offset, tm_len,data3)
-     end
-
-     if data1 == 3  then
-        require("uhf_dissector")
-      UHF_DISSECTOR(buffer, pinfo, tree, TC_TM_PROTOCOL, offset, tm_len,data3)
-     end
+     len =len - 3
+     if data1 == 5 then
+       require("obc_dissector")
+       
+        
+         obc_dissector(buffer, pinfo, subtree1, TC_TM_PROTOCOL, offset, data3)
 
-     local array = {data1, data2, data3,array1}
+     
+     elseif data1 == 2 then 
+       require("sband_dissector")
+       
+       sband_dissectors(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}
      
      return array
 

+ 169 - 0
Dissector/sband_dissector.lua

@@ -0,0 +1,169 @@
+-- Your function definition begins here
+function sband_dissectors(buffer, pinfo, tree, TC_TM_PROTOCOL, offset, instance)
+    -- Define ProtoFields for s_sband_cmn_tm
+    local f_timestamp2 = ProtoField.uint64("TC_TM_PROTOCOL.timestamp2", "Timestamp", base.DEC) 
+    local f_temp_mcu = ProtoField.uint32("TC_TM_PROTOCOL.temp_mcu", "Temp MCU", base.DEC)
+    local f_temp_fpga = ProtoField.uint32("TC_TM_PROTOCOL.temp_fpga", "Temp FPGA", base.DEC)
+    local f_temp_xcvr = ProtoField.uint32("TC_TM_PROTOCOL.temp_xcvr", "Temp XCVR", base.DEC)
+    local f_volt_vint = ProtoField.double("TC_TM_PROTOCOL.volt_vint", "Volt Vint", base.DEC)
+    local f_volt_vaux = ProtoField.double("TC_TM_PROTOCOL.volt_vaux", "Volt Vaux", base.DEC)
+    local f_volt_vbram = ProtoField.double("TC_TM_PROTOCOL.volt_vbram", "Volt Vbram", base.DEC)
+    local f_volt_vpint = ProtoField.double("TC_TM_PROTOCOL.volt_vpint", "Volt Vpint", base.DEC)
+    local f_volt_vpaux = ProtoField.double("TC_TM_PROTOCOL.volt_vpaux", "Volt Vpaux", base.DEC)
+    local f_volt_vpdro = ProtoField.double("TC_TM_PROTOCOL.volt_vpdro", "Volt Vpdro", base.DEC)
+    --local f_resv_chnl = ProtoField.uint8("TC_TM_PROTOCOL.resv_cgnl", "resvchnl", base.DEC)
+
+    -- Define ProtoFields for s_sband_rx_tm
+    local f_rx_cfg_frames = ProtoField.uint32("TC_TM_PROTOCOL.rx_cfg_frames", "RX Config Frames", base.DEC)
+    local f_rx_cfg_detected = ProtoField.uint32("TC_TM_PROTOCOL.rx_cfg_detected", "RX Config Detected", base.DEC)
+    local f_rx_cfg_rssi = ProtoField.float("TC_TM_PROTOCOL.rx_cfg_rssi", "RX Config RSSI", base.DEC)
+    local f_rx_avg_rssi = ProtoField.float("TC_TM_PROTOCOL.rx_avg_rssi", "RX Average RSSI", base.DEC)
+    local f_rx_cfg_freqerr = ProtoField.int32("TC_TM_PROTOCOL.rx_cfg_freqerr", "RX Config Frequency Error", base.DEC)
+    local f_rx_cfg_carrier_lock = ProtoField.uint32("TC_TM_PROTOCOL.rx_cfg_carrier_lock", "RX Carrier Lock", base.DEC)
+    local f_rx_frame_lock = ProtoField.uint32("TC_TM_PROTOCOL.rx_frame_lock", "RX Frame Lock", base.DEC)
+    local f_rx_sir_min = ProtoField.uint32("TC_TM_PROTOCOL.rx_sir_min", "RX SIR Min", base.DEC)
+    local f_rx_sir_max = ProtoField.uint32("TC_TM_PROTOCOL.rx_sir_max", "RX SIR Max", base.DEC)
+    local f_rx_bch_block_cnt = ProtoField.uint32("TC_TM_PROTOCOL.rx_bch_block_cnt", "RX BCH Block Count", base.DEC)
+    local f_rx_bch_err_cnt = ProtoField.uint32("TC_TM_PROTOCOL.rx_bch_err_cnt", "RX BCH Error Count", base.DEC)
+
+    -- Define ProtoFields for s_sband_tx_tm
+    local f_tx_cfg_frames = ProtoField.uint32("TC_TM_PROTOCOL.tx_cfg_frames", "TX Config Frames", base.DEC)
+    local f_tx_cfg_pwr_rfl = ProtoField.float("TC_TM_PROTOCOL.tx_cfg_pwr_rfl", "TX Power RFL", base.DEC)
+
+    -- For the main s_sband_periodic_tm structure
+    --local f_cmn_tm = ProtoField.bytes("TC_TM_PROTOCOL.cmn_tm", "Common Time", base.HEX)
+    --local f_rx_tm = ProtoField.bytes("TC_TM_PROTOCOL.rx_tm", "RX Time", base.HEX)
+    --local f_tx_tm = ProtoField.bytes("TC_TM_PROTOCOL.tx_tm", "TX Time", base.HEX) 
+
+    -- Add all fields to the protocol
+    TC_TM_PROTOCOL.fields = {
+        f_timestamp2, f_temp_mcu, f_temp_fpga, f_temp_xcvr, f_volt_vint, f_volt_vaux, f_volt_vbram, f_volt_vpint,
+        f_volt_vpaux, f_volt_vpdro,
+        f_rx_cfg_frames, f_rx_cfg_detected, f_rx_cfg_rssi, f_rx_avg_rssi, f_rx_cfg_freqerr, 
+        f_rx_cfg_carrier_lock, f_rx_frame_lock, f_rx_sir_min, f_rx_sir_max, f_rx_bch_block_cnt, f_rx_bch_err_cnt,
+        f_tx_cfg_frames, f_tx_cfg_pwr_rfl
+    }
+
+
+
+
+    -- Now the loop for iterating over instances
+    for i = 0, instance - 1 do
+        local subtree = tree:add(TC_TM_PROTOCOL, buffer(), "HEALTH METRIC DATA SBAND")
+
+        -- Offset for the different structs in s_sband_periodic_tm
+        
+        -- Dissect the s_sband_cmn_tm structure
+        subtree:add(f_timestamp2, buffer(offset, 8):le_uint64())
+        offset = offset + 8 
+        subtree:add(f_temp_mcu, buffer(offset, 4):le_uint())  -- 4 bytes for int32
+        offset = offset + 4
+        subtree:add(f_temp_fpga, buffer(offset, 4):le_uint()) -- 4 bytes for int32
+        offset = offset + 4
+        subtree:add(f_temp_xcvr, buffer(offset, 4):le_uint()) -- 4 bytes for int32
+        offset = offset + 4
+        
+        local data = buffer(offset, 4):le_uint()  -- First 4 bytes for z_vel
+        local data1 = buffer(offset + 4, 4):le_uint() -- Next 4 bytes for z_vel
+        local data3 = string.unpack("d", string.pack("<II", data1, data))
+        subtree:add(f_volt_vint, data3 )
+        offset = offset + 8
+       
+        data = buffer(offset, 4):le_uint()  -- First 4 bytes for z_vel
+        data1 = buffer(offset + 4, 4):le_uint() -- Next 4 bytes for z_vel
+        data3 = string.unpack("d", string.pack("<II", data1, data))
+        subtree:add(f_volt_vaux, data3 )
+        offset = offset + 8
+        
+        
+        data = buffer(offset, 4):le_uint()  -- First 4 bytes for z_vel
+        data1 = buffer(offset + 4, 4):le_uint() -- Next 4 bytes for z_vel
+        data3 = string.unpack("d", string.pack("<II", data1, data))
+        subtree:add(f_volt_vbram, data3 )
+        offset = offset + 8
+        
+        
+        data = buffer(offset, 4):le_uint()  -- First 4 bytes for z_vel
+        data1 = buffer(offset + 4, 4):le_uint() -- Next 4 bytes for z_vel
+        data3 = string.unpack("d", string.pack("<II", data1, data))
+        subtree:add(f_volt_vpint, data3 )
+        offset = offset + 8
+        
+        data = buffer(offset, 4):le_uint()  -- First 4 bytes for z_vel
+        data1 = buffer(offset + 4, 4):le_uint() -- Next 4 bytes for z_vel
+        data3 = string.unpack("d", string.pack("<II", data1, data))
+        subtree:add(f_volt_vpaux, data3 )
+        offset = offset + 8
+        
+        
+        data = buffer(offset, 4):le_uint()  -- First 4 bytes for z_vel
+        data1 = buffer(offset + 4, 4):le_uint() -- Next 4 bytes for z_vel
+        data3 = string.unpack("d", string.pack("<II", data1, data))
+        subtree:add(f_volt_vpdro, data3 )
+        offset = offset + 8
+       
+
+        -- Dissect the s_sband_rx_tm structure 
+        -- Handle the RX structure
+        print("Recv chnl : 1")
+
+        subtree:add(f_rx_cfg_frames, buffer(offset, 4):le_uint())  -- 4 bytes for uint32
+        offset = offset + 4
+        subtree:add(f_rx_cfg_detected, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
+        offset = offset + 4
+        subtree:add(f_rx_cfg_rssi, buffer(offset, 4):le_float())  -- 4 bytes for float (f32)
+        offset = offset + 4
+        subtree:add(f_rx_avg_rssi, buffer(offset, 4):le_float())  -- 4 bytes for float (f32)
+        offset = offset + 4
+        subtree:add(f_rx_cfg_freqerr, buffer(offset, 4):le_uint()) -- 4 bytes for int32
+        offset = offset + 4
+        subtree:add(f_rx_cfg_carrier_lock, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
+        offset = offset + 4
+        subtree:add(f_rx_frame_lock, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
+        offset = offset + 4
+        subtree:add(f_rx_sir_min, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
+        offset = offset + 4
+        subtree:add(f_rx_sir_max, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
+        offset = offset + 4
+        subtree:add(f_rx_bch_block_cnt, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
+        offset = offset + 4
+        subtree:add(f_rx_bch_err_cnt, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
+        offset = offset + 4
+        
+        --subtree:add(f_recv_chnl,2)  -- 4 bytes for uint32
+        
+        print("Recv chnl - 2")
+        subtree:add(f_rx_cfg_frames, buffer(offset, 4):le_uint())  -- 4 bytes for uint32
+        offset = offset + 4
+        subtree:add(f_rx_cfg_detected, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
+        offset = offset + 4
+        subtree:add(f_rx_cfg_rssi, buffer(offset, 4):le_float())  -- 4 bytes for float (f32)
+        offset = offset + 4
+        subtree:add(f_rx_avg_rssi, buffer(offset, 4):le_float())  -- 4 bytes for float (f32)
+        offset = offset + 4
+        subtree:add(f_rx_cfg_freqerr, buffer(offset, 4):le_uint()) -- 4 bytes for int32
+        offset = offset + 4
+        subtree:add(f_rx_cfg_carrier_lock, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
+        offset = offset + 4
+        subtree:add(f_rx_frame_lock, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
+        offset = offset + 4
+        subtree:add(f_rx_sir_min, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
+        offset = offset + 4
+        subtree:add(f_rx_sir_max, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
+        offset = offset + 4
+        subtree:add(f_rx_bch_block_cnt, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
+        offset = offset + 4
+        subtree:add(f_rx_bch_err_cnt, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
+        offset = offset + 4
+
+        -- Dissect the s_sband_tx_tm structure
+        --subtree:add(f_tx_cfg_frames, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
+        --offset = offset + 4
+        --subtree:add(f_tx_cfg_pwr_rfl, buffer(offset, 4):le_float()) -- 4 bytes for float (f32)
+        --offset = offset + 4
+        
+        
+        
+    end  -- This closes the `for` loop
+
+end  -- This closes the function `sband_dissectors`