eps_rd_stored_param.lua 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. function eps_rd_stored_param_dissector(buffer, pinfo, tree, eps_proto, offset)
  2. local f_mppt_cnt = ProtoField.uint8("eps.mppt_cnt", "MPPT Count", base.DEC)
  3. local f_op_conv_cnt = ProtoField.uint8("eps.op_conv_cnt", "OP Converter Count", base.DEC)
  4. local f_btry_temp_sns_cnt = ProtoField.uint8("eps.btry_temp_sns_cnt", "Battery Temp Sensor Count", base.DEC)
  5. local f_heat_elmnt_cnt = ProtoField.uint8("eps.heat_elmnt_cnt", "Heater Element Count", base.DEC)
  6. local f_volt_rail_cnt = ProtoField.uint8("eps.volt_rail_cnt", "Voltage Rail Count", base.DEC)
  7. local f_mppt_enb = ProtoField.bytes("eps.mppt_enb", "MPPT Enable")
  8. local f_op_conv_ena_sts = ProtoField.bytes("eps.op_conv_ena_sts", "OP Convertor Enable Status")
  9. local f_op_conv_volt = ProtoField.float("eps.op_conv_volt", "OP Convertor Volt", base.DEC)
  10. local f_btry_chrg_cur_lmt = ProtoField.float("eps.btry_chrg_cur_lmt", "Battery Charge Current Limit", base.DEC)
  11. local f_btry_dischrg_cur_lmt = ProtoField.float("eps.btry_dischrg_cur_lmt", "Battery Discharge Current Limit", base.DEC)
  12. local f_btry_temp_sens_read = ProtoField.bytes("eps.btry_temp_sens_read", "Battery Tempatarure Sensor Read")
  13. local f_heat_mode = ProtoField.uint8("eps.heat_mode", "Heat Mode", base.DEC)
  14. local f_heat_mode_flags = ProtoField.float("eps.heat_mode_flags", "Heat Mode Flags", base.DEC)
  15. local f_volt_rail_cur_val = ProtoField.bytes("eps.volt_rail_cur_val", "Volt Rail Current Value")
  16. local f_nrml_mode_thrld_volt = ProtoField.float("eps.nrml_mode_thrld_volt", "Normal Mode Threshold Voltage", base.DEC)
  17. local f_safe_mode_thrld_volt = ProtoField.float("eps.safe_mode_thrld_volt", "Safe Mode Threshold Voltage", base.DEC)
  18. local f_crtl_mode_thrld_volt = ProtoField.float("eps.crtl_mode_thrld_volt", "Control Mode Threshold Voltage", base.DEC)
  19. local f_obc_com_timeout = ProtoField.uint16("eps.obc_com_timeout", "OBC Communication Timeout (Sec Byte1 and Byte2)", base.DEC)
  20. 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)
  21. local f_mcu_count = ProtoField.uint8("eps.mcu_count", "MCU Count", base.DEC)
  22. -- Define fields for eps_get_fw_vers_s
  23. local f_mjr_fw_vers = ProtoField.uint8("eps.mjr_fw_vers", "Major Firmware Version", base.DEC)
  24. local f_mnr_fw_vers = ProtoField.uint8("eps.mnr_fw_vers", "Minor Firmware Version", base.DEC)
  25. local f_patch_fw_vers = ProtoField.uint8("eps.patch_fw_vers", "Patch Firmware Version", base.DEC)
  26. local f_com_mjr_vers = ProtoField.uint8("eps.com_mjr_vers", "Communication Major Version", base.DEC)
  27. local f_com_mnr_vers = ProtoField.uint8("eps.com_mnr_vers", "Communication Minor Version", base.DEC)
  28. -- Register fields to the protocol
  29. eps_proto.fields = {
  30. f_mppt_cnt, f_op_conv_cnt, f_btry_temp_sns_cnt, f_heat_elmnt_cnt, f_volt_rail_cnt,
  31. 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,
  32. f_heat_mode_flags, f_volt_rail_cur_val, f_nrml_mode_thrld_volt, f_safe_mode_thrld_volt, f_crtl_mode_thrld_volt,
  33. f_obc_com_timeout, f_num_of_obc_rst_for_eps_rst, f_mcu_count,
  34. f_mjr_fw_vers, f_mnr_fw_vers, f_patch_fw_vers, f_com_mjr_vers, f_com_mnr_vers
  35. }
  36. local subtree = tree:add(eps_proto, buffer(), "EPS RD STORED PARAM")
  37. local mppt_cnt = buffer(offset, 1):le_uint()
  38. subtree:add(f_mppt_cnt, buffer(offset, 1):le_uint())
  39. offset = offset + 1
  40. local op_conv_cnt = buffer(offset, 1):le_uint()
  41. subtree:add(f_op_conv_cnt, buffer(offset, 1):le_uint())
  42. offset = offset + 1
  43. local btry_temp_sns_cnt = buffer(offset, 1):le_uint()
  44. subtree:add(f_btry_temp_sns_cnt, buffer(offset, 1):le_uint())
  45. offset = offset + 1
  46. local heat_elmnt_cnt = buffer(offset, 1):le_uint()
  47. subtree:add(f_heat_elmnt_cnt, buffer(offset, 1):le_uint())
  48. offset = offset + 1
  49. local volt_rail_cnt = buffer(offset, 1):le_uint()
  50. subtree:add(f_volt_rail_cnt, buffer(offset, 1):le_uint())
  51. offset = offset + 1
  52. local mcu_cnt = buffer(offset, 1):le_uint()
  53. subtree:add(f_mcu_count, buffer(offset, 1):le_uint())
  54. offset = offset + 1
  55. local count = math.ceil(mppt_cnt / 8)
  56. local value
  57. local mppt_enable = buffer(offset, count):le_uint()
  58. for i = 0,mppt_cnt - 1 do
  59. value = (mppt_enable >> i)&1
  60. if value == 0 then
  61. subtree:add(f_mppt_enb, mppt_enable):set_text(string.format("MPPT Enable Status %d ----> 0", i))
  62. elseif value == 1 then
  63. subtree:add(f_mppt_enb, mppt_enable):set_text(string.format("MPPT Enable Status %d ----> 1", i))
  64. end
  65. end
  66. offset = offset + 1
  67. local count = math.ceil(op_conv_cnt / 8)
  68. local value
  69. local data = buffer(offset, count):le_uint()
  70. for i = 0,op_conv_cnt - 1 do
  71. value = (data >> i)&1
  72. if value == 0 then
  73. subtree:add(f_op_conv_ena_sts, data):set_text(string.format("O/P Convertor Enable Status %d ----> 0", i))
  74. elseif value == 1 then
  75. subtree:add(f_op_conv_ena_sts, data):set_text(string.format("O/P Convertor Enable Status %d ----> 1", i))
  76. end
  77. end
  78. offset = offset + 1
  79. --local data = buffer(offset, count):le_uint()
  80. for i = 0,op_conv_cnt - 1 do
  81. data = buffer(offset, 2):le_uint()
  82. data = data / 10
  83. subtree:add(f_op_conv_volt, data):set_text(string.format("O/P Convertor Volt %d -----> %0.1f V", i, data))
  84. offset = offset + 2
  85. end
  86. local btry_chrg = buffer(offset, 2):le_uint()
  87. btry_chrg = btry_chrg/100
  88. subtree:add(f_btry_chrg_cur_lmt, btry_chrg):set_text(string.format("Battery Charge Current Limit ----> %0.2f", btry_chrg))
  89. offset = offset + 2
  90. local btry_dischrg = buffer(offset, 2):le_uint()
  91. btry_dischrg = btry_dischrg/100
  92. subtree:add(f_btry_dischrg_cur_lmt, btry_chrg):set_text(string.format("Battery Discharge Current Limit ----> %0.2f", btry_dischrg))
  93. offset = offset + 2
  94. subtree:add("Battery Temparature Sensor Threshold ---->")
  95. for i = 0, btry_temp_sns_cnt - 1 do
  96. local data = buffer(offset, 2):le_uint()
  97. 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))
  98. offset = offset + 2
  99. end
  100. subtree:add(f_heat_mode, buffer(offset, 1))
  101. offset = offset + 1
  102. local count = math.ceil(heat_elmnt_cnt/8)
  103. local data = buffer(offset, count):le_uint()
  104. local value
  105. for i = 0,heat_elmnt_cnt - 1 do
  106. value = (data >> i) & 1
  107. subtree:add(f_heat_mode_flags, value):set_text(string.format("Heat Mode Flag Status %d -----> %d", i, value))
  108. end
  109. offset = offset + count
  110. for i = 0,volt_rail_cnt - 1 do
  111. data = buffer(offset, 2):le_uint()
  112. data = data / 100
  113. subtree:add(f_volt_rail_cur_val, data):set_text(string.format("Volt Rail Current Value %d -----> %0.2f V", i, data))
  114. offset = offset + 2
  115. end
  116. local mode = buffer(offset, 2):le_uint()
  117. mode = mode / 10
  118. subtree:add(f_nrml_mode_thrld_volt, mode):set_text(string.format("Normal Mode Threshold Voltage -----> %0.1f V", mode))
  119. offset = offset + 2
  120. local mode = buffer(offset, 2):le_uint()
  121. mode = mode / 10
  122. subtree:add(f_safe_mode_thrld_volt, mode):set_text(string.format("Safe Mode Threshold Voltage -----> %0.1f V", mode))
  123. offset = offset + 2
  124. local mode = buffer(offset, 2):le_uint()
  125. mode = mode / 10
  126. subtree:add(f_crtl_mode_thrld_volt, mode):set_text(string.format("Critical Mode Threshold Voltage -----> %0.1f V", mode))
  127. offset = offset + 2
  128. subtree:add(f_obc_com_timeout, buffer(offset, 2):le_uint())
  129. offset = offset + 2
  130. subtree:add(f_num_of_obc_rst_for_eps_rst, buffer(offset, 1):le_uint())
  131. offset = offset + 1
  132. -- Parse eps_get_fw_vers_s
  133. local fw_vers_tree = subtree:add(eps_proto, buffer(offset, 5), "Firmware Version")
  134. for i = 1 ,mcu_cnt do
  135. fw_vers_tree:add("EPS MCU ",i)
  136. fw_vers_tree:add(f_mjr_fw_vers, buffer(offset, 1):le_uint())
  137. offset = offset + 1
  138. fw_vers_tree:add(f_mnr_fw_vers, buffer(offset, 1):le_uint())
  139. offset = offset + 1
  140. fw_vers_tree:add(f_patch_fw_vers, buffer(offset, 1):le_uint())
  141. offset = offset + 1
  142. fw_vers_tree:add(f_com_mjr_vers, buffer(offset, 1):le_uint())
  143. offset = offset + 1
  144. fw_vers_tree:add(f_com_mnr_vers, buffer(offset, 1):le_uint())
  145. offset = offset + 1
  146. end
  147. end