sband_dissector.lua 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. -- Your function definition begins here
  2. function sband_dissectors(buffer, pinfo, tree, TC_TM_PROTOCOL, offset, instance)
  3. -- Define ProtoFields for s_sband_cmn_tm
  4. local f_timestamp2 = ProtoField.uint64("TC_TM_PROTOCOL.timestamp2", "Timestamp", base.DEC)
  5. local f_temp_mcu = ProtoField.uint32("TC_TM_PROTOCOL.temp_mcu", "Temp MCU", base.DEC)
  6. local f_temp_fpga = ProtoField.uint32("TC_TM_PROTOCOL.temp_fpga", "Temp FPGA", base.DEC)
  7. local f_temp_xcvr = ProtoField.uint32("TC_TM_PROTOCOL.temp_xcvr", "Temp XCVR", base.DEC)
  8. local f_volt_vint = ProtoField.double("TC_TM_PROTOCOL.volt_vint", "Volt Vint", base.DEC)
  9. local f_volt_vaux = ProtoField.double("TC_TM_PROTOCOL.volt_vaux", "Volt Vaux", base.DEC)
  10. local f_volt_vbram = ProtoField.double("TC_TM_PROTOCOL.volt_vbram", "Volt Vbram", base.DEC)
  11. local f_volt_vpint = ProtoField.double("TC_TM_PROTOCOL.volt_vpint", "Volt Vpint", base.DEC)
  12. local f_volt_vpaux = ProtoField.double("TC_TM_PROTOCOL.volt_vpaux", "Volt Vpaux", base.DEC)
  13. local f_volt_vpdro = ProtoField.double("TC_TM_PROTOCOL.volt_vpdro", "Volt Vpdro", base.DEC)
  14. --local f_resv_chnl = ProtoField.uint8("TC_TM_PROTOCOL.resv_cgnl", "resvchnl", base.DEC)
  15. -- Define ProtoFields for s_sband_rx_tm
  16. local f_rx_cfg_frames = ProtoField.uint32("TC_TM_PROTOCOL.rx_cfg_frames", "RX Config Frames", base.DEC)
  17. local f_rx_cfg_detected = ProtoField.uint32("TC_TM_PROTOCOL.rx_cfg_detected", "RX Config Detected", base.DEC)
  18. local f_rx_cfg_rssi = ProtoField.float("TC_TM_PROTOCOL.rx_cfg_rssi", "RX Config RSSI", base.DEC)
  19. local f_rx_avg_rssi = ProtoField.float("TC_TM_PROTOCOL.rx_avg_rssi", "RX Average RSSI", base.DEC)
  20. local f_rx_cfg_freqerr = ProtoField.int32("TC_TM_PROTOCOL.rx_cfg_freqerr", "RX Config Frequency Error", base.DEC)
  21. local f_rx_cfg_carrier_lock = ProtoField.uint32("TC_TM_PROTOCOL.rx_cfg_carrier_lock", "RX Carrier Lock", base.DEC)
  22. local f_rx_frame_lock = ProtoField.uint32("TC_TM_PROTOCOL.rx_frame_lock", "RX Frame Lock", base.DEC)
  23. local f_rx_sir_min = ProtoField.uint32("TC_TM_PROTOCOL.rx_sir_min", "RX SIR Min", base.DEC)
  24. local f_rx_sir_max = ProtoField.uint32("TC_TM_PROTOCOL.rx_sir_max", "RX SIR Max", base.DEC)
  25. local f_rx_bch_block_cnt = ProtoField.uint32("TC_TM_PROTOCOL.rx_bch_block_cnt", "RX BCH Block Count", base.DEC)
  26. local f_rx_bch_err_cnt = ProtoField.uint32("TC_TM_PROTOCOL.rx_bch_err_cnt", "RX BCH Error Count", base.DEC)
  27. -- Define ProtoFields for s_sband_tx_tm
  28. local f_tx_cfg_frames = ProtoField.uint32("TC_TM_PROTOCOL.tx_cfg_frames", "TX Config Frames", base.DEC)
  29. local f_tx_cfg_pwr_rfl = ProtoField.float("TC_TM_PROTOCOL.tx_cfg_pwr_rfl", "TX Power RFL", base.DEC)
  30. -- For the main s_sband_periodic_tm structure
  31. --local f_cmn_tm = ProtoField.bytes("TC_TM_PROTOCOL.cmn_tm", "Common Time", base.HEX)
  32. --local f_rx_tm = ProtoField.bytes("TC_TM_PROTOCOL.rx_tm", "RX Time", base.HEX)
  33. --local f_tx_tm = ProtoField.bytes("TC_TM_PROTOCOL.tx_tm", "TX Time", base.HEX)
  34. -- Add all fields to the protocol
  35. TC_TM_PROTOCOL.fields = {
  36. f_timestamp2, f_temp_mcu, f_temp_fpga, f_temp_xcvr, f_volt_vint, f_volt_vaux, f_volt_vbram, f_volt_vpint,
  37. f_volt_vpaux, f_volt_vpdro,
  38. f_rx_cfg_frames, f_rx_cfg_detected, f_rx_cfg_rssi, f_rx_avg_rssi, f_rx_cfg_freqerr,
  39. 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,
  40. f_tx_cfg_frames, f_tx_cfg_pwr_rfl
  41. }
  42. local subtree = tree:add(TC_TM_PROTOCOL, buffer(), "SBAND")
  43. -- Now the loop for iterating over instances
  44. for i = 0, instance - 1 do
  45. local subtree1 = subtree:add(TC_TM_PROTOCOL, buffer(), "Instance " ..i)
  46. -- Offset for the different structs in s_sband_periodic_tm
  47. -- Dissect the s_sband_cmn_tm structure
  48. subtree1:add(f_timestamp2, buffer(offset, 8):le_uint64())
  49. offset = offset + 8
  50. subtree1:add(f_temp_mcu, buffer(offset, 4):le_uint()) -- 4 bytes for int32
  51. offset = offset + 4
  52. subtree1:add(f_temp_fpga, buffer(offset, 4):le_uint()) -- 4 bytes for int32
  53. offset = offset + 4
  54. subtree1:add(f_temp_xcvr, buffer(offset, 4):le_uint()) -- 4 bytes for int32
  55. offset = offset + 4
  56. local data = buffer(offset, 4):le_uint() -- First 4 bytes for z_vel
  57. local data1 = buffer(offset + 4, 4):le_uint() -- Next 4 bytes for z_vel
  58. local data3 = string.unpack("d", string.pack("<II", data1, data))
  59. subtree1:add(f_volt_vint, data3 )
  60. offset = offset + 8
  61. data = buffer(offset, 4):le_uint() -- First 4 bytes for z_vel
  62. data1 = buffer(offset + 4, 4):le_uint() -- Next 4 bytes for z_vel
  63. data3 = string.unpack("d", string.pack("<II", data1, data))
  64. subtree1:add(f_volt_vaux, data3 )
  65. offset = offset + 8
  66. data = buffer(offset, 4):le_uint() -- First 4 bytes for z_vel
  67. data1 = buffer(offset + 4, 4):le_uint() -- Next 4 bytes for z_vel
  68. data3 = string.unpack("d", string.pack("<II", data1, data))
  69. subtree1:add(f_volt_vbram, data3 )
  70. offset = offset + 8
  71. data = buffer(offset, 4):le_uint() -- First 4 bytes for z_vel
  72. data1 = buffer(offset + 4, 4):le_uint() -- Next 4 bytes for z_vel
  73. data3 = string.unpack("d", string.pack("<II", data1, data))
  74. subtree1:add(f_volt_vpint, data3 )
  75. offset = offset + 8
  76. data = buffer(offset, 4):le_uint() -- First 4 bytes for z_vel
  77. data1 = buffer(offset + 4, 4):le_uint() -- Next 4 bytes for z_vel
  78. data3 = string.unpack("d", string.pack("<II", data1, data))
  79. subtree1:add(f_volt_vpaux, data3 )
  80. offset = offset + 8
  81. data = buffer(offset, 4):le_uint() -- First 4 bytes for z_vel
  82. data1 = buffer(offset + 4, 4):le_uint() -- Next 4 bytes for z_vel
  83. data3 = string.unpack("d", string.pack("<II", data1, data))
  84. subtree1:add(f_volt_vpdro, data3 )
  85. offset = offset + 8
  86. -- Dissect the s_sband_rx_tm structure
  87. -- Handle the RX structure
  88. print("Recv chnl : 1")
  89. subtree1:add(f_rx_cfg_frames, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
  90. offset = offset + 4
  91. subtree1:add(f_rx_cfg_detected, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
  92. offset = offset + 4
  93. subtree1:add(f_rx_cfg_rssi, buffer(offset, 4):le_float()) -- 4 bytes for float (f32)
  94. offset = offset + 4
  95. subtree1:add(f_rx_avg_rssi, buffer(offset, 4):le_float()) -- 4 bytes for float (f32)
  96. offset = offset + 4
  97. subtree1:add(f_rx_cfg_freqerr, buffer(offset, 4):le_uint()) -- 4 bytes for int32
  98. offset = offset + 4
  99. subtree1:add(f_rx_cfg_carrier_lock, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
  100. offset = offset + 4
  101. subtree1:add(f_rx_frame_lock, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
  102. offset = offset + 4
  103. subtree1:add(f_rx_sir_min, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
  104. offset = offset + 4
  105. subtree1:add(f_rx_sir_max, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
  106. offset = offset + 4
  107. subtree1:add(f_rx_bch_block_cnt, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
  108. offset = offset + 4
  109. subtree1:add(f_rx_bch_err_cnt, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
  110. offset = offset + 4
  111. --subtree1:add(f_recv_chnl,2) -- 4 bytes for uint32
  112. print("Recv chnl - 2")
  113. subtree1:add(f_rx_cfg_frames, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
  114. offset = offset + 4
  115. subtree1:add(f_rx_cfg_detected, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
  116. offset = offset + 4
  117. subtree1:add(f_rx_cfg_rssi, buffer(offset, 4):le_float()) -- 4 bytes for float (f32)
  118. offset = offset + 4
  119. subtree1:add(f_rx_avg_rssi, buffer(offset, 4):le_float()) -- 4 bytes for float (f32)
  120. offset = offset + 4
  121. subtree1:add(f_rx_cfg_freqerr, buffer(offset, 4):le_uint()) -- 4 bytes for int32
  122. offset = offset + 4
  123. subtree1:add(f_rx_cfg_carrier_lock, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
  124. offset = offset + 4
  125. subtree1:add(f_rx_frame_lock, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
  126. offset = offset + 4
  127. subtree1:add(f_rx_sir_min, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
  128. offset = offset + 4
  129. subtree1:add(f_rx_sir_max, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
  130. offset = offset + 4
  131. subtree1:add(f_rx_bch_block_cnt, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
  132. offset = offset + 4
  133. subtree1:add(f_rx_bch_err_cnt, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
  134. offset = offset + 4
  135. -- Dissect the s_sband_tx_tm structure
  136. --subtree1:add(f_tx_cfg_frames, buffer(offset, 4):le_uint()) -- 4 bytes for uint32
  137. --offset = offset + 4
  138. --subtree1:add(f_tx_cfg_pwr_rfl, buffer(offset, 4):le_float()) -- 4 bytes for float (f32)
  139. --offset = offset + 4
  140. end -- This closes the `for` loop
  141. end -- This closes the function `sband_dissectors`