function eps_tc_wr_stored_param_dissector(buffer, pinfo, tree, eps_proto, offset) local f_option = ProtoField.uint8("eps.option", "Option", base.DEC) local f_mppt_cnt = ProtoField.uint8("eps.mppt_cnt", "MPPT Count", base.DEC) local f_op_conv_cnt = ProtoField.uint8("eps.op_conv_cnt", "OP Converter Count", base.DEC) local f_btry_temp_sns_cnt = ProtoField.uint8("eps.btry_temp_sns_cnt", "Battery Temp Sensor Count", base.DEC) local f_heat_elmnt_cnt = ProtoField.uint8("eps.heat_elmnt_cnt", "Heater Element Count", base.DEC) local f_volt_rail_cnt = ProtoField.uint8("eps.volt_rail_cnt", "Voltage Rail Count", base.DEC) local f_mppt_enb = ProtoField.bytes("eps.mppt_enb", "MPPT Enable") local f_op_conv_ena_sts = ProtoField.bytes("eps.op_conv_ena_sts", "OP Convertor Enable Status") local f_op_conv_volt = ProtoField.float("eps.op_conv_volt", "OP Convertor Volt", base.DEC) local f_btry_chrg_cur_lmt = ProtoField.float("eps.btry_chrg_cur_lmt", "Battery Charge Current Limit", base.DEC) local f_btry_dischrg_cur_lmt = ProtoField.float("eps.btry_dischrg_cur_lmt", "Battery Discharge Current Limit", base.DEC) local f_btry_temp_sens_read = ProtoField.bytes("eps.btry_temp_sens_read", "Battery Tempatarure Sensor Read") local f_heat_mode = ProtoField.uint8("eps.heat_mode", "Heat Mode", base.DEC) local f_heat_mode_flags = ProtoField.float("eps.heat_mode_flags", "Heat Mode Flags", base.DEC) local f_volt_rail_cur_val = ProtoField.bytes("eps.volt_rail_cur_val", "Volt Rail Current Value") local f_nrml_mode_thrld_volt = ProtoField.float("eps.nrml_mode_thrld_volt", "Normal Mode Threshold Voltage", base.DEC) local f_safe_mode_thrld_volt = ProtoField.float("eps.safe_mode_thrld_volt", "Safe Mode Threshold Voltage", base.DEC) local f_crtl_mode_thrld_volt = ProtoField.float("eps.crtl_mode_thrld_volt", "Control Mode Threshold Voltage", base.DEC) local f_obc_com_timeout = ProtoField.uint16("eps.obc_com_timeout", "OBC Communication Timeout (Sec Byte1 and Byte2)", base.DEC) 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) local f_mcu_count = ProtoField.uint8("eps.mcu_count", "MCU Count", base.DEC) -- Define ProtoFields for RTC TIME in the structure local f_hour = ProtoField.uint8("eps.hour", "Hour", base.DEC) local f_min = ProtoField.uint8("eps.min", "Minute", base.DEC) local f_sec = ProtoField.uint8("eps.sec", "Second", base.DEC) local f_date = ProtoField.uint8("eps.date", "Date", base.DEC) local f_month = ProtoField.uint8("eps.month", "Month", base.DEC) local f_year = ProtoField.uint8("eps.year", "Year", base.DEC) local f_weekday = ProtoField.uint8("eps.weekday", "Weekday", base.DEC) -- Define ProtoFields for Change Channel state in the structure local f_chnl_cnt = ProtoField.uint8("eps.chnl_cnt", "Channel Count", base.DEC) local f_chnl_state = ProtoField.bytes("eps.chnl_state", "Channel States") -- Define fields for eps_get_fw_vers_s local f_mjr_fw_vers = ProtoField.uint8("eps.mjr_fw_vers", "Major Firmware Version", base.DEC) local f_mnr_fw_vers = ProtoField.uint8("eps.mnr_fw_vers", "Minor Firmware Version", base.DEC) local f_patch_fw_vers = ProtoField.uint8("eps.patch_fw_vers", "Patch Firmware Version", base.DEC) local f_com_mjr_vers = ProtoField.uint8("eps.com_mjr_vers", "Communication Major Version", base.DEC) local f_com_mnr_vers = ProtoField.uint8("eps.com_mnr_vers", "Communication Minor Version", base.DEC) -- Register fields to the protocol eps_proto.fields = { f_option, f_mppt_cnt, f_op_conv_cnt, f_btry_temp_sns_cnt, f_heat_elmnt_cnt, f_volt_rail_cnt, 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, f_heat_mode_flags, f_volt_rail_cur_val, f_nrml_mode_thrld_volt, f_safe_mode_thrld_volt, f_crtl_mode_thrld_volt, 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, 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 } local subtree = tree:add(eps_proto, buffer(), "EPS WR STORED PARAM") local option = buffer(offset, 1):le_uint() subtree:add(f_option, option) offset = offset + 1 if option == 0 then subtree:add("___Set All The Common Parameters___") offset = offset + 4 local mppt_cnt = buffer(offset, 1):le_uint() subtree:add(f_mppt_cnt, buffer(offset, 1):le_uint()) offset = offset + 1 local op_conv_cnt = buffer(offset, 1):le_uint() subtree:add(f_op_conv_cnt, buffer(offset, 1):le_uint()) offset = offset + 1 local btry_temp_sns_cnt = buffer(offset, 1):le_uint() subtree:add(f_btry_temp_sns_cnt, buffer(offset, 1):le_uint()) offset = offset + 1 local heat_elmnt_cnt = buffer(offset, 1):le_uint() subtree:add(f_heat_elmnt_cnt, buffer(offset, 1):le_uint()) offset = offset + 1 local volt_rail_cnt = buffer(offset, 1):le_uint() subtree:add(f_volt_rail_cnt, buffer(offset, 1):le_uint()) offset = offset + 1 --local mcu_cnt = buffer(offset, 1):le_uint() --subtree:add(f_mcu_count, buffer(offset, 1):le_uint()) --offset = offset + 1 local count = math.ceil(mppt_cnt / 8) local value local mppt_enable = buffer(offset, count):le_uint() for i = 0,mppt_cnt - 1 do value = (mppt_enable >> i)&1 if value == 0 then subtree:add(f_mppt_enb, mppt_enable):set_text(string.format("MPPT Enable Status %d ----> 0", i)) elseif value == 1 then subtree:add(f_mppt_enb, mppt_enable):set_text(string.format("MPPT Enable Status %d ----> 1", i)) end end offset = offset + 1 local count = math.ceil(op_conv_cnt / 8) local value local data = buffer(offset, count):le_uint() for i = 0,op_conv_cnt - 1 do value = (data >> i)&1 if value == 0 then subtree:add(f_op_conv_ena_sts, data):set_text(string.format("O/P Convertor Enable Status %d ----> 0", i)) elseif value == 1 then subtree:add(f_op_conv_ena_sts, data):set_text(string.format("O/P Convertor Enable Status %d ----> 1", i)) end end offset = offset + 1 --local data = buffer(offset, count):le_uint() for i = 0,op_conv_cnt - 1 do data = buffer(offset, 2):le_uint() data = data / 10 subtree:add(f_op_conv_volt, data):set_text(string.format("O/P Convertor Volt %d -----> %0.1f V", i, data)) offset = offset + 2 end local btry_chrg = buffer(offset, 2):le_uint() btry_chrg = btry_chrg/100 subtree:add(f_btry_chrg_cur_lmt, btry_chrg):set_text(string.format("Battery Charge Current Limit ----> %0.2f", btry_chrg)) offset = offset + 2 local btry_dischrg = buffer(offset, 2):le_uint() btry_dischrg = btry_dischrg/100 subtree:add(f_btry_dischrg_cur_lmt, btry_chrg):set_text(string.format("Battery Discharge Current Limit ----> %0.2f", btry_dischrg)) offset = offset + 2 subtree:add("Battery Temparature Sensor Threshold ---->") for i = 0, btry_temp_sns_cnt - 1 do local data = buffer(offset, 2):le_uint() 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)) offset = offset + 2 end subtree:add(f_heat_mode, buffer(offset, 1)) offset = offset + 1 local count = math.ceil(heat_elmnt_cnt/8) local data = buffer(offset, count):le_uint() local value for i = 0,heat_elmnt_cnt - 1 do value = (data >> i) & 1 subtree:add(f_heat_mode_flags, value):set_text(string.format("Heat Mode Flag Status %d -----> %d", i, value)) end offset = offset + count for i = 0,volt_rail_cnt - 1 do data = buffer(offset, 2):le_uint() data = data / 100 subtree:add(f_volt_rail_cur_val, data):set_text(string.format("Volt Rail Current Value %d -----> %0.2f V", i, data)) offset = offset + 2 end local mode = buffer(offset, 2):le_uint() mode = mode / 10 subtree:add(f_nrml_mode_thrld_volt, mode):set_text(string.format("Normal Mode Threshold Voltage -----> %0.1f V", mode)) offset = offset + 2 local mode = buffer(offset, 2):le_uint() mode = mode / 10 subtree:add(f_safe_mode_thrld_volt, mode):set_text(string.format("Safe Mode Threshold Voltage -----> %0.1f V", mode)) offset = offset + 2 local mode = buffer(offset, 2):le_uint() mode = mode / 10 subtree:add(f_crtl_mode_thrld_volt, mode):set_text(string.format("Critical Mode Threshold Voltage -----> %0.1f V", mode)) offset = offset + 2 subtree:add(f_obc_com_timeout, buffer(offset, 2):le_uint()) offset = offset + 2 subtree:add(f_num_of_obc_rst_for_eps_rst, buffer(offset, 1):le_uint()) offset = offset + 1 elseif option == 1 then subtree:add("___RTC Time Parameters___") subtree:add(f_hour, buffer(offset, 1)) offset = offset + 1 subtree:add(f_min, buffer(offset, 1)) offset = offset + 1 subtree:add(f_sec, buffer(offset, 1)) offset = offset + 1 subtree:add(f_date, buffer(offset, 1)) offset = offset + 1 subtree:add(f_month, buffer(offset, 1)) offset = offset + 1 subtree:add(f_year, buffer(offset, 1)) offset = offset + 1 subtree:add(f_weekday, buffer(offset, 1)) offset = offset + 1 elseif option == 2 then offset = offset + 1 subtree:add("___Channel State Parameters___") local chnl_cnt = buffer(offset, 1):le_uint() subtree:add(f_chnl_cnt, buffer(offset, 1)):append_text(" (Number of Channels)") offset = offset + 1 for i = 0, chnl_cnt - 1 do local state = buffer(offset, 1):le_uint() subtree:add("Channel " .. i .. " State: " .. state) offset = offset + 1 end end end