eps_wr_stored_param.lua 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. function eps_tc_wr_stored_param_dissector(buffer, pinfo, tree, eps_proto, offset)
  2. local f_option = ProtoField.uint8("eps.option", "Option", base.DEC)
  3. local f_mppt_cnt = ProtoField.uint8("eps.mppt_cnt", "MPPT Count", base.DEC)
  4. local f_op_conv_cnt = ProtoField.uint8("eps.op_conv_cnt", "OP Converter Count", base.DEC)
  5. local f_btry_temp_sns_cnt = ProtoField.uint8("eps.btry_temp_sns_cnt", "Battery Temp Sensor Count", base.DEC)
  6. local f_heat_elmnt_cnt = ProtoField.uint8("eps.heat_elmnt_cnt", "Heater Element Count", base.DEC)
  7. local f_volt_rail_cnt = ProtoField.uint8("eps.volt_rail_cnt", "Voltage Rail Count", base.DEC)
  8. local f_mppt_enb = ProtoField.bytes("eps.mppt_enb", "MPPT Enable")
  9. local f_op_conv_ena_sts = ProtoField.bytes("eps.op_conv_ena_sts", "OP Convertor Enable Status")
  10. local f_op_conv_volt = ProtoField.float("eps.op_conv_volt", "OP Convertor Volt", base.DEC)
  11. local f_btry_chrg_cur_lmt = ProtoField.float("eps.btry_chrg_cur_lmt", "Battery Charge Current Limit", base.DEC)
  12. local f_btry_dischrg_cur_lmt = ProtoField.float("eps.btry_dischrg_cur_lmt", "Battery Discharge Current Limit", base.DEC)
  13. local f_btry_temp_sens_read = ProtoField.bytes("eps.btry_temp_sens_read", "Battery Tempatarure Sensor Read")
  14. local f_heat_mode = ProtoField.uint8("eps.heat_mode", "Heat Mode", base.DEC)
  15. local f_heat_mode_flags = ProtoField.float("eps.heat_mode_flags", "Heat Mode Flags", base.DEC)
  16. local f_volt_rail_cur_val = ProtoField.bytes("eps.volt_rail_cur_val", "Volt Rail Current Value")
  17. local f_nrml_mode_thrld_volt = ProtoField.float("eps.nrml_mode_thrld_volt", "Normal Mode Threshold Voltage", base.DEC)
  18. local f_safe_mode_thrld_volt = ProtoField.float("eps.safe_mode_thrld_volt", "Safe Mode Threshold Voltage", base.DEC)
  19. local f_crtl_mode_thrld_volt = ProtoField.float("eps.crtl_mode_thrld_volt", "Control Mode Threshold Voltage", base.DEC)
  20. local f_obc_com_timeout = ProtoField.uint16("eps.obc_com_timeout", "OBC Communication Timeout (Sec Byte1 and Byte2)", base.DEC)
  21. local f_num_of_obc_rst_for_eps_rst = ProtoField.uint8("eps.num_of_obc_rst", "Number of OBC Resets for EPS Reset", base.DEC)
  22. local f_mcu_count = ProtoField.uint8("eps.mcu_count", "MCU Count", base.DEC)
  23. -- Define ProtoFields for RTC TIME in the structure
  24. local f_hour = ProtoField.uint8("eps.hour", "Hour", base.DEC)
  25. local f_min = ProtoField.uint8("eps.min", "Minute", base.DEC)
  26. local f_sec = ProtoField.uint8("eps.sec", "Second", base.DEC)
  27. local f_date = ProtoField.uint8("eps.date", "Date", base.DEC)
  28. local f_month = ProtoField.uint8("eps.month", "Month", base.DEC)
  29. local f_year = ProtoField.uint8("eps.year", "Year", base.DEC)
  30. local f_weekday = ProtoField.uint8("eps.weekday", "Weekday", base.DEC)
  31. -- Define ProtoFields for Change Channel state in the structure
  32. local f_chnl_cnt = ProtoField.uint8("eps.chnl_cnt", "Channel Count", base.DEC)
  33. local f_chnl_state = ProtoField.bytes("eps.chnl_state", "Channel States")
  34. -- Define fields for eps_get_fw_vers_s
  35. local f_mjr_fw_vers = ProtoField.uint8("eps.mjr_fw_vers", "Major Firmware Version", base.DEC)
  36. local f_mnr_fw_vers = ProtoField.uint8("eps.mnr_fw_vers", "Minor Firmware Version", base.DEC)
  37. local f_patch_fw_vers = ProtoField.uint8("eps.patch_fw_vers", "Patch Firmware Version", base.DEC)
  38. local f_com_mjr_vers = ProtoField.uint8("eps.com_mjr_vers", "Communication Major Version", base.DEC)
  39. local f_com_mnr_vers = ProtoField.uint8("eps.com_mnr_vers", "Communication Minor Version", base.DEC)
  40. -- Register fields to the protocol
  41. eps_proto.fields = {
  42. f_option, f_mppt_cnt, f_op_conv_cnt, f_btry_temp_sns_cnt, f_heat_elmnt_cnt, f_volt_rail_cnt,
  43. f_mppt_enb, f_op_conv_ena_sts,f_op_conv_volt, f_btry_chrg_cur_lmt, f_btry_dischrg_cur_lmt, f_btry_temp_sens_read, f_heat_mode,
  44. f_heat_mode_flags, f_volt_rail_cur_val, f_nrml_mode_thrld_volt, f_safe_mode_thrld_volt, f_crtl_mode_thrld_volt,
  45. f_obc_com_timeout, f_num_of_obc_rst_for_eps_rst, f_mcu_count, f_hour, f_min, f_sec, f_date, f_month, f_year, f_weekday,
  46. f_chnl_cnt, f_chnl_state, f_mjr_fw_vers, f_mnr_fw_vers, f_patch_fw_vers, f_com_mjr_vers, f_com_mnr_vers
  47. }
  48. local subtree = tree:add(eps_proto, buffer(), "EPS WR STORED PARAM")
  49. local option = buffer(offset, 1):le_uint()
  50. subtree:add(f_option, option)
  51. offset = offset + 1
  52. if option == 0 then
  53. subtree:add("___Set All The Common Parameters___")
  54. offset = offset + 4
  55. local mppt_cnt = buffer(offset, 1):le_uint()
  56. subtree:add(f_mppt_cnt, buffer(offset, 1):le_uint())
  57. offset = offset + 1
  58. local op_conv_cnt = buffer(offset, 1):le_uint()
  59. subtree:add(f_op_conv_cnt, buffer(offset, 1):le_uint())
  60. offset = offset + 1
  61. local btry_temp_sns_cnt = buffer(offset, 1):le_uint()
  62. subtree:add(f_btry_temp_sns_cnt, buffer(offset, 1):le_uint())
  63. offset = offset + 1
  64. local heat_elmnt_cnt = buffer(offset, 1):le_uint()
  65. subtree:add(f_heat_elmnt_cnt, buffer(offset, 1):le_uint())
  66. offset = offset + 1
  67. local volt_rail_cnt = buffer(offset, 1):le_uint()
  68. subtree:add(f_volt_rail_cnt, buffer(offset, 1):le_uint())
  69. offset = offset + 1
  70. --local mcu_cnt = buffer(offset, 1):le_uint()
  71. --subtree:add(f_mcu_count, buffer(offset, 1):le_uint())
  72. --offset = offset + 1
  73. local count = math.ceil(mppt_cnt / 8)
  74. local value
  75. local mppt_enable = buffer(offset, count):le_uint()
  76. for i = 0,mppt_cnt - 1 do
  77. value = (mppt_enable >> i)&1
  78. if value == 0 then
  79. subtree:add(f_mppt_enb, mppt_enable):set_text(string.format("MPPT Enable Status %d ----> 0", i))
  80. elseif value == 1 then
  81. subtree:add(f_mppt_enb, mppt_enable):set_text(string.format("MPPT Enable Status %d ----> 1", i))
  82. end
  83. end
  84. offset = offset + 1
  85. local count = math.ceil(op_conv_cnt / 8)
  86. local value
  87. local data = buffer(offset, count):le_uint()
  88. for i = 0,op_conv_cnt - 1 do
  89. value = (data >> i)&1
  90. if value == 0 then
  91. subtree:add(f_op_conv_ena_sts, data):set_text(string.format("O/P Convertor Enable Status %d ----> 0", i))
  92. elseif value == 1 then
  93. subtree:add(f_op_conv_ena_sts, data):set_text(string.format("O/P Convertor Enable Status %d ----> 1", i))
  94. end
  95. end
  96. offset = offset + 1
  97. --local data = buffer(offset, count):le_uint()
  98. for i = 0,op_conv_cnt - 1 do
  99. data = buffer(offset, 2):le_uint()
  100. data = data / 10
  101. subtree:add(f_op_conv_volt, data):set_text(string.format("O/P Convertor Volt %d -----> %0.1f V", i, data))
  102. offset = offset + 2
  103. end
  104. local btry_chrg = buffer(offset, 2):le_uint()
  105. btry_chrg = btry_chrg/100
  106. subtree:add(f_btry_chrg_cur_lmt, btry_chrg):set_text(string.format("Battery Charge Current Limit ----> %0.2f", btry_chrg))
  107. offset = offset + 2
  108. local btry_dischrg = buffer(offset, 2):le_uint()
  109. btry_dischrg = btry_dischrg/100
  110. subtree:add(f_btry_dischrg_cur_lmt, btry_chrg):set_text(string.format("Battery Discharge Current Limit ----> %0.2f", btry_dischrg))
  111. offset = offset + 2
  112. subtree:add("Battery Temparature Sensor Threshold ---->")
  113. for i = 0, btry_temp_sns_cnt - 1 do
  114. local data = buffer(offset, 2):le_uint()
  115. subtree:add(f_btry_temp_sens_read, data):set_text(string.format(" %d LOW = %d degC , HIGH = %d degC", i, (data&0x00ff), (data>>8)&0x00ff))
  116. offset = offset + 2
  117. end
  118. subtree:add(f_heat_mode, buffer(offset, 1))
  119. offset = offset + 1
  120. local count = math.ceil(heat_elmnt_cnt/8)
  121. local data = buffer(offset, count):le_uint()
  122. local value
  123. for i = 0,heat_elmnt_cnt - 1 do
  124. value = (data >> i) & 1
  125. subtree:add(f_heat_mode_flags, value):set_text(string.format("Heat Mode Flag Status %d -----> %d", i, value))
  126. end
  127. offset = offset + count
  128. for i = 0,volt_rail_cnt - 1 do
  129. data = buffer(offset, 2):le_uint()
  130. data = data / 100
  131. subtree:add(f_volt_rail_cur_val, data):set_text(string.format("Volt Rail Current Value %d -----> %0.2f V", i, data))
  132. offset = offset + 2
  133. end
  134. local mode = buffer(offset, 2):le_uint()
  135. mode = mode / 10
  136. subtree:add(f_nrml_mode_thrld_volt, mode):set_text(string.format("Normal Mode Threshold Voltage -----> %0.1f V", mode))
  137. offset = offset + 2
  138. local mode = buffer(offset, 2):le_uint()
  139. mode = mode / 10
  140. subtree:add(f_safe_mode_thrld_volt, mode):set_text(string.format("Safe Mode Threshold Voltage -----> %0.1f V", mode))
  141. offset = offset + 2
  142. local mode = buffer(offset, 2):le_uint()
  143. mode = mode / 10
  144. subtree:add(f_crtl_mode_thrld_volt, mode):set_text(string.format("Critical Mode Threshold Voltage -----> %0.1f V", mode))
  145. offset = offset + 2
  146. subtree:add(f_obc_com_timeout, buffer(offset, 2):le_uint())
  147. offset = offset + 2
  148. subtree:add(f_num_of_obc_rst_for_eps_rst, buffer(offset, 1):le_uint())
  149. offset = offset + 1
  150. elseif option == 1 then
  151. subtree:add("___RTC Time Parameters___")
  152. subtree:add(f_hour, buffer(offset, 1))
  153. offset = offset + 1
  154. subtree:add(f_min, buffer(offset, 1))
  155. offset = offset + 1
  156. subtree:add(f_sec, buffer(offset, 1))
  157. offset = offset + 1
  158. subtree:add(f_date, buffer(offset, 1))
  159. offset = offset + 1
  160. subtree:add(f_month, buffer(offset, 1))
  161. offset = offset + 1
  162. subtree:add(f_year, buffer(offset, 1))
  163. offset = offset + 1
  164. subtree:add(f_weekday, buffer(offset, 1))
  165. offset = offset + 1
  166. elseif option == 2 then
  167. offset = offset + 1
  168. subtree:add("___Channel State Parameters___")
  169. local chnl_cnt = buffer(offset, 1):le_uint()
  170. subtree:add(f_chnl_cnt, buffer(offset, 1)):append_text(" (Number of Channels)")
  171. offset = offset + 1
  172. for i = 0, chnl_cnt - 1 do
  173. local state = buffer(offset, 1):le_uint()
  174. subtree:add("Channel " .. i .. " State: " .. state)
  175. offset = offset + 1
  176. end
  177. end
  178. end