/src/plugins/mscommon/interrogate.c
C | 1717 lines | 1466 code | 94 blank | 157 comment | 333 complexity | 5578e4c3df61416046e513eeb598e3c6 MD5 | raw file
Possible License(s): GPL-2.0
Large files files are truncated, but you can click here to view the full file
- /*
- * Copyright (C) 2002-2012 by Dave J. Andruczyk <djandruczyk at yahoo dot com>
- *
- * Linux Megasquirt tuning software
- *
- * Most of this file contributed by Perry Harrington
- * slight changes applied (naming, addition ofbspot 1-3 vars)
- *
- * This software comes under the GPL (GNU Public License)
- * You may freely copy,distribute etc. this as long as the source code
- * is made available for FREE.
- *
- * No warranty is made or implied. You use this program at your own risk.
- */
- /*!
- \file src/plugins/mscommon/interrogate.c
- \ingroup MSCommonPlugin,Plugins
- \brief MS Specific device interrogation/detection routines
- \author David Andruczyk
- */
- #include <api-versions.h>
- #include <dep_loader.h>
- #include <getfiles.h>
- #include <interrogate.h>
- #include <libgen.h>
- #include <mscommon_comms.h>
- #include <mscommon_plugin.h>
- #include <multi_expr_loader.h>
- #include <serialio.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- extern GtkWidget *interr_view;
- extern gconstpointer *global_data;
- #define BUFSIZE 4096
- /*!
- \brief Iinterrogates the target ECU to determine what
- firmware it is running. It does this by reading a list of tests, sending
- those tests in turn, reading the responses and them comparing the group of
- responses against a list of interrogation profiles until it finds a match.
- \returns TRUE on a success, FALSE otherwise
- */
- G_MODULE_EXPORT gboolean interrogate_ecu(void)
- {
- static GMutex mutex;
- gboolean interrogated = FALSE;
- GArray *tests = NULL;
- GHashTable *tests_hash = NULL;
- Detection_Test *test = NULL;
- guchar uint8 = 0;
- gchar sint8 = 0;
- guint16 uint16 = 0;
- gint16 sint16 = 0;
- gboolean res = 0;
- gint count = 0;
- gint i = 0;
- gint j = 0;
- gint len = 0;
- gint tests_to_run = 0;
- gint total_read = 0;
- gint total_wanted = 0;
- gint zerocount = 0;
- gint adder = 0;
- gint base_offset = 0;
- unsigned long crc32 = 0;
- gint crc_pass = 0;
- gint crc_fail = 0;
- gchar *string = NULL;
- guchar buf[BUFSIZE];
- guchar *ptr = NULL;
- gchar * message = NULL;
- Serial_Params *serial_params = NULL;
- ENTER();
- serial_params = (Serial_Params *)DATA_GET(global_data,"serial_params");
- if (DATA_GET(global_data,"offline"))
- {
- EXIT();
- return FALSE;
- }
- /* prevent multiple runs of interrogator simultaneously */
- g_mutex_lock(&mutex);
- MTXDBG(INTERROGATOR,_("Entered\n"));
- if (!DATA_GET(global_data,"connected"))
- {
- MTXDBG(INTERROGATOR,_("NOT connected to ECU!!!!\n"));
- g_mutex_unlock(&mutex);
- EXIT();
- return FALSE;
- }
- thread_update_widget_f("titlebar",MTX_TITLE,g_strdup(_("Interrogating ECU...")));
- /* Load tests from config files */
- tests = validate_and_load_tests(&tests_hash);
- if ((!tests) || (tests->len < 1))
- {
- MTXDBG(INTERROGATOR|CRITICAL,_("validate_and_load_tests() didn't return a valid list of commands\n\t MegaTunix was NOT installed correctly, Aborting Interrogation\n"));
- update_logbar_f("interr_view",NULL,g_strdup(__FILE__": interrogate_ecu()\n\t validate_and_load_tests() didn't return a valid list of commands\n\t MegaTunix was NOT installed correctly, Aborting Interrogation\n"),FALSE,FALSE,TRUE);
- g_mutex_unlock(&mutex);
- EXIT();
- return FALSE;
- }
- thread_widget_set_sensitive_f("offline_button",FALSE);
- thread_widget_set_sensitive_f("interrogate_button",FALSE);
- /* how many tests.... */
- tests_to_run = tests->len;
- for (i=0;i<tests_to_run;i++)
- {
- flush_serial_f(serial_params->fd,BOTH);
- count = 0;
- test = g_array_index(tests,Detection_Test *, i);
- /* flush buffer to known state.. */
- memset (buf,0,BUFSIZE);
- ptr = buf;
- string = g_strdup(test->actual_test);
- res = write_wrapper_f(serial_params->fd,test->send_buf,test->send_len,&len);
- if (!res)
- MTXDBG(INTERROGATOR|CRITICAL,_("Interrogation error: Unable to send data: \"%s\"n"),(gchar *)g_strndup((const gchar *)test->send_buf,test->send_len));
- MTXDBG(INTERROGATOR,_("Sent command \"%s\"\n"),string);
- g_free(string);
- total_read = 0;
- total_wanted = BUFSIZE;
- zerocount = 0;
- while ((total_read < total_wanted ) && (total_wanted-total_read) > 0 )
- {
- MTXDBG(INTERROGATOR,_("Interrogation for command %s requesting %i bytes\n"),test->test_name,total_wanted-total_read);
- res = read_wrapper_f(serial_params->fd,
- ptr+total_read,
- total_wanted-total_read,&len);
- total_read += len;
- MTXDBG(INTERROGATOR,_("Interrogation for command %s read %i bytes, running total %i\n"),test->test_name,len,total_read);
- /* If we get nothing back (i.e. timeout, inc counter)*/
- if ((!res) || (len == 0))
- zerocount++;
- if (zerocount > 1)
- break;
- }
- MTXDBG(INTERROGATOR,_("Received %i bytes\n"),total_read);
- ptr = buf;
- test->recv_len = total_read;
- /* copy data from tmp buffer to struct pointer */
- if (test->ms3_crc32)
- {
- adder = 7;
- base_offset = 3;
- len = buf[0]*256 + buf[1];
- if ((len == 0 ) || (len > 2054))
- printf("packet length INVALID\n");
- if ((len + 6) != test->recv_len)
- printf("data length received DOES NOT MATCH packet length header\n");
- crc32 = crc32_computebuf(0,&buf[2],len);
- if ( (((crc32 >> 24) & 0xff) != buf[2 + len])
- || (((crc32 >> 16) & 0xff) != buf[3 + len])
- || (((crc32 >> 8) & 0xff) != buf[4 + len])
- || ((crc32 & 0xff) != buf[5 + len])) {
- printf("CRC32 validation FAILED\n");
- crc_fail++;
- }
- else
- {
- printf("CRC32 validation SUCCEEDED\n");
- crc_pass++;
- }
- if (buf[2] & 0x80)
- printf("Packet contains error code 0x%x\n",buf[2] & 0xff);
- else
- printf("Packet contains status code 0x%x\n",buf[2] & 0xff);
- }
- if (total_read <= (0 + adder))
- test->result_str = g_strdup("");
- else
- test->result_str = g_strndup((gchar *)ptr+base_offset, total_read-adder);
- if (total_read > (0 + adder))
- {
- if (test->result_type == RESULT_TEXT)
- update_logbar_f("interr_view",NULL,g_strdup_printf(_("Command \"%s\" (%s), returned %i bytes \"%s\"\n"),test->actual_test, test->test_desc,total_read,test->result_str),FALSE,FALSE,TRUE);
- else if (test->result_type == RESULT_DATA)
- update_logbar_f("interr_view",NULL,g_strdup_printf(_("Command \"%s\" (%s), returned %i bytes\n"),test->actual_test, test->test_desc,total_read),FALSE,FALSE,TRUE);
- ptr = buf;
- MTXDBG(SERIAL_RD|INTERROGATOR,_("Read the following from the %s command\n"),test->test_name);
- message = g_strndup(((gchar *)buf),total_read);
- MTXDBG(SERIAL_RD|INTERROGATOR,_("Dumping Output string: \"%s\"\n"),message);
- g_free(message);
- QUIET_MTXDBG(SERIAL_RD|INTERROGATOR,_("Data is in HEX!!\n"));
- for (j=0;j<total_read;j++)
- {
- QUIET_MTXDBG(SERIAL_RD|INTERROGATOR,"%.2x ", ptr[j]);
- if (!((j+1)%8)) /* every 8 bytes give a CR */
- QUIET_MTXDBG(SERIAL_RD|INTERROGATOR,"\n");
- }
- QUIET_MTXDBG(SERIAL_RD|INTERROGATOR,"\n\n");
- }
- }
- interrogated = determine_ecu(tests,tests_hash);
- DATA_SET(global_data,"interrogated",GINT_TO_POINTER(interrogated));
- if (interrogated)
- {
- thread_widget_set_sensitive_f("interrogate_button",FALSE);
- thread_widget_set_sensitive_f("offline_button",FALSE);
- }
- free_tests_array(tests);
- g_hash_table_destroy(tests_hash);
- if (!interrogated)
- {
- thread_widget_set_sensitive_f("interrogate_button",TRUE);
- thread_widget_set_sensitive_f("offline_button",TRUE);
- }
- g_mutex_unlock(&mutex);
- MTXDBG(INTERROGATOR,_("Leaving\n"));
- thread_update_widget_f("titlebar",MTX_TITLE,g_strdup("Interrogation Complete..."));
- EXIT();
- return interrogated;
- }
- /*!
- \brief Tries to match to determine the target firmware by
- loading the interrogation profiles in turn and comparing the data from our
- test ECU and a profile until a match is found,
- \param tests is a pointer to the Array of tests
- \param tests_hash is a pointer to the hashtable of tests
- \returns TRUE on successfull match, FALSE on no match
- */
- G_MODULE_EXPORT gboolean determine_ecu(GArray *tests,GHashTable *tests_hash)
- {
- gboolean retval = TRUE;
- gint i = 0;
- Detection_Test *test = NULL;
- gint num_tests = tests->len;
- gboolean match = FALSE;
- gchar * filename = NULL;
- gchar ** filenames = NULL;
- GArray *classes = NULL;
- Firmware_Details *firmware = NULL;
- gchar *pathstub = NULL;
- ENTER();
- pathstub = g_build_filename(INTERROGATOR_DATA_DIR,"Profiles",DATA_GET(global_data,"ecu_family"),NULL);
- filenames = get_files((const gchar *)DATA_GET(global_data,"project_name"),pathstub,"prof",&classes);
- g_free(pathstub);
- if (!filenames)
- {
- MTXDBG(INTERROGATOR|CRITICAL,_("NO Interrogation profiles found, was MegaTunix installed properly?\n"));
- EXIT();
- return FALSE;
- }
- i = 0;
- while (filenames[i])
- {
- if (check_for_match(tests_hash,filenames[i]))
- {
- match = TRUE;
- filename = g_strdup(filenames[i]);
- break;
- }
- i++;
- }
- g_strfreev(filenames);
- g_array_free(classes,TRUE);
- /* Update the screen with the data... */
- for (i=0;i<num_tests;i++)
- {
- test = g_array_index(tests,Detection_Test *,i);
- if (test->result_type == RESULT_TEXT)
- MTXDBG(INTERROGATOR,_("Command \"%s\" (%s), returned %i bytes \"%s\"\n"),
- test->actual_test,
- test->test_desc,
- test->recv_len,
- test->result_str);
- else if (test->result_type == RESULT_DATA)
- MTXDBG(INTERROGATOR,_("Command \"%s\" (%s), returned %i bytes\n"),
- test->actual_test,
- test->test_desc,
- test->recv_len);
- }
- if (match == FALSE) /* (we DID NOT find one) */
- {
- MTXDBG(INTERROGATOR,_("Firmware NOT DETECTED, Enable Interrogation debugging, retry interrogation,\nclose megatunix, and send ~/mtx/%s/debug.log to the author for analysis with a note\ndescribing which firmware you are attempting to talk to.\n"),(gchar *)DATA_GET(global_data,"project_name"));
- update_logbar_f("interr_view","warning",g_strdup_printf("Firmware NOT DETECTED, Enable Interrogation debugging, retry interrogation,\nclose megatunix, and send ~/mtx/%s/debug.log to the author for analysis with a note\ndescribing which firmware you are attempting to talk to.\n",(gchar *)DATA_GET(global_data,"project_name")),FALSE,FALSE,TRUE);
- retval = FALSE;
- }
- else
- {
- if (!firmware)
- {
- firmware = g_new0(Firmware_Details,1);
- DATA_SET(global_data,"firmware",firmware);
- }
- if (!load_firmware_details(firmware,filename))
- retval = FALSE;
- }
- g_free(filename);
- EXIT();
- return(retval);
- }
- /*!
- \brief loads up all firmware details allocating the required resrouces
- \param firmware is the pointer to the firmware datastructure
- \param filename is the pointer to the filename to parse
- \returns TRUE on success, FALSE otherwise
- */
- G_MODULE_EXPORT gboolean load_firmware_details(Firmware_Details *firmware, const gchar * filename)
- {
- ConfigFile *cfgfile;
- gchar * tmpbuf = NULL;
- gchar * section = NULL;
- gchar ** list = NULL;
- gint i = 0;
- MultiSource * multi = NULL;
- gchar **sources = NULL;
- gchar **suffixes = NULL;
- gchar **fromecu_mults = NULL;
- gchar **fromecu_adds = NULL;
- gchar **precisions = NULL;
- gchar **expr_keys = NULL;
- gchar **tables = NULL;
- gfloat tmpf = 0.0;
- gint major = 0;
- gint minor = 0;
- gint len1 = 0;
- gint len2 = 0;
- gint len3 = 0;
- gint len4 = 0;
- gint len5 = 0;
- gint len6 = 0;
- gint j = 0;
- ENTER();
- g_return_val_if_fail(firmware,FALSE);
- g_return_val_if_fail(filename,FALSE);
- cfgfile = cfg_open_file((gchar *)filename);
- if (!cfgfile)
- {
- MTXDBG(INTERROGATOR|CRITICAL,_("File \"%s\" NOT OPENED successfully\n"),filename);
- EXIT();
- return FALSE;
- }
- get_file_api_f(cfgfile,&major,&minor);
- if ((major != INTERROGATE_MAJOR_API) || (minor != INTERROGATE_MINOR_API))
- {
- thread_update_logbar_f("interr_view","warning",g_strdup_printf(_("Interrogation profile API mismatch (%i.%i != %i.%i):\n\tFile %s will be skipped\n"),major,minor,INTERROGATE_MAJOR_API,INTERROGATE_MINOR_API,filename),FALSE,FALSE);
- cfg_free(cfgfile);
- EXIT();
- return FALSE;
- }
- firmware->profile_filename = g_strdup(filename);
- cfg_read_string(cfgfile,"interrogation_profile","name",&firmware->name);
- cfg_read_string(cfgfile,"parameters","TextVerVia",&firmware->TextVerVia);
- cfg_read_string(cfgfile,"parameters","NumVerVia",&firmware->NumVerVia);
- cfg_read_string(cfgfile,"parameters","SignatureVia",&firmware->SignatureVia);
- if(cfg_read_string(cfgfile,"parameters","EcuTempUnits",&tmpbuf))
- {
- firmware->ecu_temp_units = (TempUnits)translate_string_f(tmpbuf);
- g_free(tmpbuf);
- }
- else
- MTXDBG(INTERROGATOR,_("Failed to find EcuTempUnits key in interrogation profile\n"));
- MTXDBG(INTERROGATOR,_("File:%s opened successfully\n"),filename);
- if(!cfg_read_boolean(cfgfile,"parameters","BigEndian",&firmware->bigendian))
- {
- MTXDBG(INTERROGATOR|CRITICAL,_("\"BigEndian\" key not found in interrogation profile, assuming ECU firmware byte order is big endian, ERROR in interrogation profile\n"));
- firmware->bigendian = TRUE;
- }
- if(!cfg_read_string(cfgfile,"parameters","Capabilities",
- &tmpbuf))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"Capabilities\" enumeration list not found in interrogation profile, ERROR\n"));
- else
- {
- /*printf("Capabilities %s\n",tmpbuf);*/
- firmware->capabilities = translate_capabilities(tmpbuf);
- g_free(tmpbuf);
- /*
- printf("CAP #'s MS1 %i MS1_STD %i MS1_E %i MS1_DT %i MS2 %i MS2_STD %i, MS2_E %i, MS2_E_COMPMON %i, PIS %i, JIMSTIM %i\n",MS1,MS1_STD,MS1_E,MS1_DT,MS2,MS2_STD,MS2_E,MS2_E_COMPMON,PIS,JIMSTIM);
- if (firmware->capabilities & MS1)
- printf("MS1\n");
- if (firmware->capabilities & MS1_STD)
- printf("MS1_STD\n");
- if (firmware->capabilities & MS1_E)
- printf("MS1_E\n");
- if (firmware->capabilities & MS1_DT)
- printf("MS1_DT\n");
- if (firmware->capabilities & MS2)
- printf("MS2\n");
- if (firmware->capabilities & MS2_STD)
- printf("MS2_STD\n");
- if (firmware->capabilities & MS2_E)
- printf("MS2_E\n");
- if (firmware->capabilities & MS2_E_COMPMON)
- printf("MS2_E_COMPMON\n");
- if (firmware->capabilities & PIS)
- printf("PIS\n");
- if (firmware->capabilities & JIMSTIM)
- printf("JIMSTIM\n");
- */
- }
- if(!cfg_read_string(cfgfile,"parameters","RT_Command",
- &firmware->rt_command))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"RT_Command\" variable not found in interrogation profile, ERROR\n"));
- if (firmware->capabilities & PIS)
- {
- if(!cfg_read_int(cfgfile,"parameters","CLT_Table_Page",
- &firmware->clt_table_page))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"CLT_Table_Page\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_int(cfgfile,"parameters","MAT_Table_Page",
- &firmware->mat_table_page))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"MAT_Table_Page\" variable not found in interrogation profile, ERROR\n"));
- }
- if (firmware->capabilities & MS2)
- {
- if(!cfg_read_int(cfgfile,"parameters","MS2_RT_Page",
- &firmware->ms2_rt_page))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"MS2_RT_Page\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_int(cfgfile,"parameters","InterCharDelay",
- &firmware->interchardelay))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"InterCharDelay\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_int(cfgfile,"parameters","CLT_Table_Page",
- &firmware->clt_table_page))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"CLT_Table_Page\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_int(cfgfile,"parameters","MAT_Table_Page",
- &firmware->mat_table_page))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"MAT_Table_Page\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_int(cfgfile,"parameters","EGO_Table_Page",
- &firmware->ego_table_page))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"EGO_Table_Page\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_int(cfgfile,"parameters","MAF_Table_Page",
- &firmware->maf_table_page))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"MAF_Table_Page\" variable not found in interrogation profile, ERROR\n"));
- }
- if(!cfg_read_int(cfgfile,"parameters","RT_total_bytes",
- &firmware->rtvars_size))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"RT_total_bytes\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_string(cfgfile,"parameters","Get_All_Command",
- &firmware->get_all_command))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"Get_All_Command\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_string(cfgfile,"parameters","Read_Command",
- &firmware->read_command))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"Read_Command\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_string(cfgfile,"parameters","Write_Command",
- &firmware->write_command))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"Write_Command\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_string(cfgfile,"parameters","Burn_Command",
- &firmware->burn_command))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"Burn_Command\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_string(cfgfile,"parameters","Burn_All_Command",
- &firmware->burn_all_command))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"Burn_All_Command\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_boolean(cfgfile,"parameters","MultiPage",
- &firmware->multi_page))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"MultiPage\" flag not found in parameters section in interrogation profile, ERROR\n"));
- if ((firmware->multi_page) && (!(firmware->capabilities & MS2)))
- {
- if(!cfg_read_string(cfgfile,"parameters","Page_Command",
- &firmware->page_command))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"Page_Command\" flag not found in parameters section in interrogation profile, ERROR\n"));
- }
- if(!cfg_read_boolean(cfgfile,"parameters","ChunkWriteSupport",
- &firmware->chunk_support))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"ChunkWriteSupport\" flag not found in parameters section in interrogation profile, ERROR\n"));
- if (firmware->chunk_support)
- {
- if(!cfg_read_string(cfgfile,"parameters","Chunk_Write_Command",
- &firmware->chunk_write_command))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"Chunk_Write_Command\" flag not found in parameters section in interrogation profile, ERROR\n"));
- }
- if (firmware->capabilities & MS2)
- {
- if(!cfg_read_string(cfgfile,"parameters","Table_Write_Command",
- &firmware->table_write_command))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"Table_Write_Command\" flag not found in parameters section in interrogation profile, ERROR\n"));
- }
- if(!cfg_read_int(cfgfile,"parameters","TotalPages",
- &firmware->total_pages))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"TotalPages\" value not found in interrogation profile, ERROR\n"));
- cfg_read_int(cfgfile,"parameters","ReadOnlyAbove",&firmware->ro_above);
- if(!cfg_read_int(cfgfile,"parameters","TotalTables",
- &firmware->total_tables))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"TotalTables\" value not found in interrogation profile, ERROR\n"));
- cfg_read_int(cfgfile,"parameters","TotalTETables",
- &firmware->total_te_tables);
- if ((firmware->capabilities & MS2_E) || (firmware->capabilities & MS1_E))
- {
- if(!cfg_read_int(cfgfile,"parameters","TrigmonPage",&firmware->trigmon_page))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"TrigmonPage\" value not found in interrogation profile, ERROR\n"));
- if(!cfg_read_int(cfgfile,"parameters","ToothmonPage",&firmware->toothmon_page))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"ToothmonPage\" value not found in interrogation profile, ERROR\n"));
- if (firmware->capabilities & MS2_E_COMPMON)
- {
- if(!cfg_read_int(cfgfile,"parameters","CompositemonPage",&firmware->compositemon_page))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"CompositemonPage\" value not found in interrogation profile, ERROR\n"));
- }
- }
- if(!cfg_read_string(cfgfile,"gui","LoadTabs",
- &tmpbuf))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"LoadTabs\" list not found in interrogation profile, ERROR\n"));
- else
- {
- firmware->tab_list = g_strsplit(tmpbuf,",",0);
- g_free(tmpbuf);
- }
- if(!cfg_read_string(cfgfile,"gui","TabConfs",
- &tmpbuf))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"TabConfs\" list not found in interrogation profile, ERROR\n"));
- else
- {
- firmware->tab_confs = g_strsplit(tmpbuf,",",0);
- g_free(tmpbuf);
- }
- if(!cfg_read_string(cfgfile,"gui","RealtimeMapFile",
- &firmware->rtv_map_file))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"RealtimeMapFile\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_string(cfgfile,"gui","SliderMapFile",
- &firmware->sliders_map_file))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"SliderMapFile\" variable not found in interrogation profile, ERROR\n"));
- cfg_read_string(cfgfile,"gui","RuntimeTextMapFile",
- &firmware->rtt_map_file);
- /* MTXDBG(INTERROGATOR|CRITICAL,_("\"RuntimeTextMapFile\" variable not found in interrogation profile, ERROR\n"));*/
- cfg_read_string(cfgfile,"gui","StatusMapFile",
- &firmware->status_map_file);
- /* MTXDBG(INTERROGATOR|CRITICAL,_("\"StatusMapFile\" variable not found in interrogation profile, ERROR\n"));*/
- if (!cfg_read_string(cfgfile,"lookuptables","tables",
- &tmpbuf))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"tables\" lookuptable name not found in interrogation profile, ERROR\n"));
- else
- {
- list = g_strsplit(tmpbuf,",",0);
- g_free(tmpbuf);
- i = 0;
- while (list[i] != NULL)
- {
- if (!cfg_read_string(cfgfile,"lookuptables",list[i],&tmpbuf))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"%s\" key name not found in \"[lookuptables]\"\n\t section of interrogation profile, ERROR\n"),list[i]);
- else
- {
- MTXDBG(INTERROGATOR,_("\"[lookuptables]\"\n\t section loading table %s, file %s\n"),list[i],tmpbuf);
- get_table_f(list[i],tmpbuf,NULL);
- g_free(tmpbuf);
- }
- i++;
- }
- g_strfreev(list);
- }
- /* Allocate space for Page Params structures.... */
- firmware->page_params = g_new0(Page_Params *,firmware->total_pages);
- for (i=0;i<firmware->total_pages;i++)
- {
- firmware->page_params[i] = initialize_page_params();
- section = g_strdup_printf("page_%i",i);
- if (firmware->multi_page)
- if(!cfg_read_int(cfgfile,section,"phys_ecu_page",&firmware->page_params[i]->phys_ecu_page))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"phys_ecu_page\" flag not found in \"%s\" section in interrogation profile, ERROR\n"),section);
- if(!cfg_read_boolean(cfgfile,section,"dl_by_default",&firmware->page_params[i]->dl_by_default))
- {
- MTXDBG(INTERROGATOR|CRITICAL,_("\"dl_by_default\" flag not found in \"%s\" section in interrogation profile, assuming TRUE\n"),section);
- firmware->page_params[i]->dl_by_default = TRUE;
- }
- if(!cfg_read_int(cfgfile,section,"length",&firmware->page_params[i]->length))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"length\" flag not found in \"%s\" section in interrogation profile, ERROR\n"),section);
- g_free(section);
- }
- /* Allocate space for Table Offsets structures.... */
- firmware->table_params = g_new0(Table_Params *,firmware->total_tables);
- for (i=0;i<firmware->total_tables;i++)
- {
- firmware->table_params[i] = initialize_table_params();
- section = g_strdup_printf("table_%i",i);
- cfg_read_string(cfgfile,section,"bind_to_list",&firmware->table_params[i]->bind_to_list);
- if(cfg_read_string(cfgfile,section,"match_type",&tmpbuf))
- {
- firmware->table_params[i]->match_type = (MatchType)translate_string_f(tmpbuf);
- g_free(tmpbuf);
- }
- cfg_read_boolean(cfgfile,section,"is_spark",&firmware->table_params[i]->is_spark);
- cfg_read_boolean(cfgfile,section,"is_fuel",&firmware->table_params[i]->is_fuel);
- if ((firmware->table_params[i]->is_fuel) && !(firmware->capabilities & PIS))
- {
- if(!cfg_read_int(cfgfile,section,"divider_page",&firmware->table_params[i]->divider_page))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"divider_page\" flag not found in \"%s\" section in interrogation profile, ERROR\n"),section);
- if(!cfg_read_int(cfgfile,section,"divider_offset",&firmware->table_params[i]->divider_offset))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"divider_offset\" flag not found in \"%s\" section in interrogation profile, ERROR\n"),section);
- if(!cfg_read_int(cfgfile,section,"reqfuel_page",&firmware->table_params[i]->reqfuel_page))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"reqfuel_page\" flag not found in \"%s\" section in interrogation profile, ERROR\n"),section);
- if(!cfg_read_int(cfgfile,section,"reqfuel_offset",&firmware->table_params[i]->reqfuel_offset))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"reqfuel_offset\" flag not found in \"%s\" section in interrogation profile, ERROR\n"),section);
- if(!cfg_read_string(cfgfile,section,"reqfuel_size",&tmpbuf))
- firmware->table_params[i]->reqfuel_size = MTX_U08;
- else
- {
- firmware->table_params[i]->reqfuel_size = (DataSize)translate_string_f(tmpbuf);
- g_free(tmpbuf);
- }
- if(!cfg_read_int(cfgfile,section,"stroke_page",&firmware->table_params[i]->stroke_page))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"stroke_page\" flag not found in \"%s\" section in interrogation profile, ERROR\n"),section);
- if(!cfg_read_int(cfgfile,section,"stroke_offset",&firmware->table_params[i]->stroke_offset))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"stroke_offset\" flag not found in \"%s\" section in interrogation profile, ERROR\n"),section);
- if(!cfg_read_int(cfgfile,section,"stroke_mask",&firmware->table_params[i]->stroke_mask))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"stroke_mask\" flag not found in \"%s\" section in interrogation profile, ERROR\n"),section);
- if(!cfg_read_int(cfgfile,section,"num_cyl_page",&firmware->table_params[i]->num_cyl_page))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"num_cyl_page\" flag not found in \"%s\" section in interrogation profile, ERROR\n"),section);
- if(!cfg_read_int(cfgfile,section,"num_cyl_offset",&firmware->table_params[i]->num_cyl_offset))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"num_cyl_offset\" flag not found in \"%s\" section in interrogation profile, ERROR\n"),section);
- if(!cfg_read_int(cfgfile,section,"num_cyl_mask",&firmware->table_params[i]->num_cyl_mask))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"num_cyl_mask\" flag not found in \"%s\" section in interrogation profile, ERROR\n"),section);
- if(!cfg_read_int(cfgfile,section,"num_inj_page",&firmware->table_params[i]->num_inj_page))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"num_inj_page\" flag not found in \"%s\" section in interrogation profile, ERROR\n"),section);
- if(!cfg_read_int(cfgfile,section,"num_inj_offset",&firmware->table_params[i]->num_inj_offset))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"num_inj_offset\" flag not found in \"%s\" section in interrogation profile, ERROR\n"),section);
- if(!cfg_read_int(cfgfile,section,"num_inj_mask",&firmware->table_params[i]->num_inj_mask))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"num_inj_mask\" flag not found in \"%s\" section in interrogation profile, ERROR\n"),section);
- if (!(firmware->capabilities & MS2))
- {
- if(!cfg_read_int(cfgfile,section,"rpmk_page",&firmware->table_params[i]->rpmk_page))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"rpmk_page\" flag not found in \"%s\" section in interrogation profile, ERROR\n"),section);
- if(!cfg_read_int(cfgfile,section,"rpmk_offset",&firmware->table_params[i]->rpmk_offset))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"rpmk_offset\" flag not found in \"%s\" section in interrogation profile, ERROR\n"),section);
- }
- if (!(firmware->capabilities & MS1_DT))
- {
- if(!cfg_read_int(cfgfile,section,"alternate_page",&firmware->table_params[i]->alternate_page))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"alternate_page\" flag not found in \"%s\" section in interrogation profile, ERROR\n"),section);
- if(!cfg_read_int(cfgfile,section,"alternate_offset",&firmware->table_params[i]->alternate_offset))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"alternate_offset\" flag not found in \"%s\" section in interrogation profile, ERROR\n"),section);
- }
- if (firmware->capabilities & MS1_E)
- {
- if(!cfg_read_int(cfgfile,section,"dtmode_offset",&firmware->table_params[i]->dtmode_offset))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"dtmode_offset\" flag not found in \"%s\" section in interrogation profile, ERROR\n"),section);
- if(!cfg_read_int(cfgfile,section,"dtmode_page",&firmware->table_params[i]->dtmode_page))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"dtmode_page\" flag not found in \"%s\" section in interrogation profile, ERROR\n"),section);
- if(!cfg_read_int(cfgfile,section,"dtmode_mask",&firmware->table_params[i]->dtmode_mask))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"dtmode_mask\" flag not found in \"%s\" section in interrogation profile, ERROR\n"),section);
- }
- }
- if(!cfg_read_int(cfgfile,section,"x_page",&firmware->table_params[i]->x_page))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"x_page\" flag not found in \"%s\" section in interrogation profile, ERROR\n"),section);
- if(!cfg_read_int(cfgfile,section,"y_page",&firmware->table_params[i]->y_page))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"y_page\" flag not found in \"%s\" section in interrogation profile, ERROR\n"),section);
- if(!cfg_read_int(cfgfile,section,"z_page",&firmware->table_params[i]->z_page))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"z_page\" flag not found in \"%s\" section in interrogation profile, ERROR\n"),section);
- if(!cfg_read_int(cfgfile,section,"x_base_offset",&firmware->table_params[i]->x_base))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"x_base_offset\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_int(cfgfile,section,"y_base_offset",&firmware->table_params[i]->y_base))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"y_base_offset\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_int(cfgfile,section,"z_base_offset",&firmware->table_params[i]->z_base))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"z_base_offset\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_int(cfgfile,section,"x_bincount",&firmware->table_params[i]->x_bincount))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"x_bincount\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_int(cfgfile,section,"y_bincount",&firmware->table_params[i]->y_bincount))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"y_bincount\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_string(cfgfile,section,"x_size",&tmpbuf))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"x_size\" enumeration not found in interrogation profile, ERROR\n"));
- else
- {
- firmware->table_params[i]->x_size = (DataSize)translate_string_f(tmpbuf);
- g_free(tmpbuf);
- }
- if(!cfg_read_string(cfgfile,section,"y_size",&tmpbuf))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"y_size\" enumeration not found in interrogation profile, ERROR\n"));
- else
- {
- firmware->table_params[i]->y_size = (DataSize)translate_string_f(tmpbuf);
- g_free(tmpbuf);
- }
- if(!cfg_read_string(cfgfile,section,"z_size",&tmpbuf))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"z_size\" enumeration not found in interrogation profile, ERROR\n"));
- else
- {
- firmware->table_params[i]->z_size = (DataSize)translate_string_f(tmpbuf);
- g_free(tmpbuf);
- }
- if(!cfg_read_int(cfgfile,section,"z_raw_lower",&firmware->table_params[i]->z_raw_lower))
- {
- firmware->table_params[i]->z_raw_lower = get_extreme_from_size_f(firmware->table_params[i]->z_size,LOWER);
- }
- if(!cfg_read_int(cfgfile,section,"z_raw_upper",&firmware->table_params[i]->z_raw_upper))
- {
- firmware->table_params[i]->z_raw_upper = get_extreme_from_size_f(firmware->table_params[i]->z_size,UPPER);
- }
- if(cfg_read_boolean(cfgfile,section,"x_multi_source",&firmware->table_params[i]->x_multi_source))
- {
- /* READ multi-source stuff, but do NOT create
- * evaluators, we do that in the final copy
- * over to the firmware struct
- */
- if(!cfg_read_string(cfgfile,section,"x_multi_expr_keys",&firmware->table_params[i]->x_multi_expr_keys))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"x_multi_expr_keys\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_string(cfgfile,section,"x_source_key",&firmware->table_params[i]->x_source_key))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"x_source_key\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_string(cfgfile,section,"x_sources",&firmware->table_params[i]->x_sources))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"x_sources\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_string(cfgfile,section,"x_suffixes",&firmware->table_params[i]->x_suffixes))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"x_suffixes\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_string(cfgfile,section,"x_fromecu_mults",&firmware->table_params[i]->x_fromecu_mults))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"x_fromecu_mults\" variable not found in interrogation profile, table %i, ERROR\n"),i);
- if(!cfg_read_string(cfgfile,section,"x_fromecu_adds",&firmware->table_params[i]->x_fromecu_adds))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"x_fromecu_adds\" variable not found in interrogation profile, table %i, ERROR\n"),i);
- if(!cfg_read_string(cfgfile,section,"x_precisions",&firmware->table_params[i]->x_precisions))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"x_precisions\" variable not found in interrogation profile, ERROR\n"));
- cfg_read_string(cfgfile,section,"x_lookuptables",&firmware->table_params[i]->x_lookuptables);
- cfg_read_boolean(cfgfile,section,"x_ignore_algorithm",&firmware->table_params[i]->x_ignore_algorithm);
- }
- else
- {
- if(!cfg_read_string(cfgfile,section,"x_source",&firmware->table_params[i]->x_source))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"x_source\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_string(cfgfile,section,"x_suffix",&firmware->table_params[i]->x_suffix))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"x_suffix\" variable not found in interrogation profile, ERROR\n"));
- if(cfg_read_boolean(cfgfile,section,"x_complex",&firmware->table_params[i]->x_complex))
- {
- cfg_read_string(cfgfile,section,"x_fromecu_conv_expr",&firmware->table_params[i]->x_fromecu_conv_expr);
- cfg_read_string(cfgfile,section,"x_toecu_conv_expr",&firmware->table_params[i]->x_toecu_conv_expr);
- }
- else
- {
- if(cfg_read_float(cfgfile,section,"x_fromecu_mult",&tmpf))
- {
- firmware->table_params[i]->x_fromecu_mult = g_new0(gfloat, 1);
- *(firmware->table_params[i]->x_fromecu_mult) = tmpf;
- }
- if(cfg_read_float(cfgfile,section,"x_fromecu_add",&tmpf))
- {
- firmware->table_params[i]->x_fromecu_add = g_new0(gfloat, 1);
- *(firmware->table_params[i]->x_fromecu_add) = tmpf;
- }
- }
- if(!cfg_read_int(cfgfile,section,"x_precision",&firmware->table_params[i]->x_precision))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"x_precision\" variable not found in interrogation profile for table %i, ERROR\n"),i);
- }
- if(cfg_read_boolean(cfgfile,section,"y_multi_source",&firmware->table_params[i]->y_multi_source))
- {
- /* READ multi-source stuff, but do NOT create
- * evaluators, we do that in the final copy
- * over to the firmware struct
- */
- if(!cfg_read_string(cfgfile,section,"y_multi_expr_keys",&firmware->table_params[i]->y_multi_expr_keys))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"y_multi_expr_keys\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_string(cfgfile,section,"y_source_key",&firmware->table_params[i]->y_source_key))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"y_source_key\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_string(cfgfile,section,"y_sources",&firmware->table_params[i]->y_sources))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"y_sources\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_string(cfgfile,section,"y_suffixes",&firmware->table_params[i]->y_suffixes))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"y_suffixes\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_string(cfgfile,section,"y_fromecu_mults",&firmware->table_params[i]->y_fromecu_mults))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"y_fromecu_mults\" variable not found in interrogation profile, table %i, ERROR\n"),i);
- if(!cfg_read_string(cfgfile,section,"y_fromecu_adds",&firmware->table_params[i]->y_fromecu_adds))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"y_fromecu_adds\" variable not found in interrogation profile, table %i, ERROR\n"),i);
- if(!cfg_read_string(cfgfile,section,"y_precisions",&firmware->table_params[i]->y_precisions))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"y_precisions\" variable not found in interrogation profile, ERROR\n"));
- cfg_read_string(cfgfile,section,"y_lookuptables",&firmware->table_params[i]->y_lookuptables);
- cfg_read_boolean(cfgfile,section,"y_ignore_algorithm",&firmware->table_params[i]->y_ignore_algorithm);
- }
- else
- {
- if(!cfg_read_string(cfgfile,section,"y_source",&firmware->table_params[i]->y_source))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"y_source\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_string(cfgfile,section,"y_suffix",&firmware->table_params[i]->y_suffix))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"y_suffix\" variable not found in interrogation profile, ERROR\n"));
- if(cfg_read_boolean(cfgfile,section,"y_complex",&firmware->table_params[i]->y_complex))
- {
- cfg_read_string(cfgfile,section,"y_fromecu_conv_expr",&firmware->table_params[i]->y_fromecu_conv_expr);
- cfg_read_string(cfgfile,section,"y_toecu_conv_expr",&firmware->table_params[i]->y_toecu_conv_expr);
- }
- else
- {
- if(cfg_read_float(cfgfile,section,"y_fromecu_mult",&tmpf))
- {
- firmware->table_params[i]->y_fromecu_mult = g_new0(gfloat, 1);
- *(firmware->table_params[i]->y_fromecu_mult) = tmpf;
- }
- if(cfg_read_float(cfgfile,section,"y_fromecu_add",&tmpf))
- {
- firmware->table_params[i]->y_fromecu_add = g_new0(gfloat, 1);
- *(firmware->table_params[i]->y_fromecu_add) = tmpf;
- }
- }
- if(!cfg_read_int(cfgfile,section,"y_precision",&firmware->table_params[i]->y_precision))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"y_precision\" variable not found in interrogation profile for table %i, ERROR\n"),i);
- }
- if(cfg_read_boolean(cfgfile,section,"z_multi_source",&firmware->table_params[i]->z_multi_source))
- {
- /* READ multi-source stuff, but do NOT create
- * evaluators, we do that in the final copy
- * over to the firmware struct
- */
- if(!cfg_read_string(cfgfile,section,"z_multi_expr_keys",&firmware->table_params[i]->z_multi_expr_keys))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"z_multi_expr_keys\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_string(cfgfile,section,"z_source_key",&firmware->table_params[i]->z_source_key))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"z_source_key\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_string(cfgfile,section,"z_sources",&firmware->table_params[i]->z_sources))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"z_sources\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_string(cfgfile,section,"z_suffixes",&firmware->table_params[i]->z_suffixes))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"z_suffixes\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_string(cfgfile,section,"z_fromecu_mults",&firmware->table_params[i]->z_fromecu_mults))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"z_fromecu_mults\" variable not found in interrogation profile, table %i, ERROR\n"),i);
- if(!cfg_read_string(cfgfile,section,"z_fromecu_adds",&firmware->table_params[i]->z_fromecu_adds))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"z_fromecu_adds\" variable not found in interrogation profile, table %i, ERROR\n"),i);
- if(!cfg_read_string(cfgfile,section,"z_precisions",&firmware->table_params[i]->z_precisions))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"z_precisions\" variable not found in interrogation profile, ERROR\n"));
- cfg_read_string(cfgfile,section,"z_lookuptables",&firmware->table_params[i]->z_lookuptables);
- cfg_read_boolean(cfgfile,section,"z_ignore_algorithm",&firmware->table_params[i]->z_ignore_algorithm);
- }
- else
- {
- if(!cfg_read_string(cfgfile,section,"z_source",&firmware->table_params[i]->z_source))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"z_source\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_string(cfgfile,section,"z_suffix",&firmware->table_params[i]->z_suffix))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"z_suffix\" variable not found in interrogation profile, ERROR\n"));
- if(cfg_read_boolean(cfgfile,section,"z_complex",&firmware->table_params[i]->z_complex))
- {
- cfg_read_string(cfgfile,section,"z_fromecu_conv_expr",&firmware->table_params[i]->z_fromecu_conv_expr);
- cfg_read_string(cfgfile,section,"z_toecu_conv_expr",&firmware->table_params[i]->z_toecu_conv_expr);
- }
- else
- {
- if(cfg_read_float(cfgfile,section,"z_fromecu_mult",&tmpf))
- {
- firmware->table_params[i]->z_fromecu_mult = g_new0(gfloat, 1);
- *(firmware->table_params[i]->z_fromecu_mult) = tmpf;
- }
- if(cfg_read_float(cfgfile,section,"z_fromecu_add",&tmpf))
- {
- firmware->table_params[i]->z_fromecu_add = g_new0(gfloat, 1);
- *(firmware->table_params[i]->z_fromecu_add) = tmpf;
- }
- }
- if(!cfg_read_int(cfgfile,section,"z_precision",&firmware->table_params[i]->z_precision))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"z_precision\" variable not found in interrogation profile for table %i, ERROR\n"),i);
- if(cfg_read_string(cfgfile,section,"z_depend_on",&firmware->table_params[i]->z_depend_on))
- {
- firmware->table_params[i]->z_object = (GObject *)g_object_new(GTK_TYPE_INVISIBLE,NULL);
- g_object_ref_sink(GTK_OBJECT(firmware->table_params[i]->z_object));
- load_dependencies_obj(firmware->table_params[i]->z_object,cfgfile,section,"z_depend_on");
- if(!cfg_read_string(cfgfile,section,"z_alt_lookuptable",&tmpbuf))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"z_alt_lookuptable\" variable not found in interrogation profile, NOT NECESSARILY AN ERROR\n"));
- else
- {
- OBJ_SET_FULL(firmware->table_params[i]->z_object,"alt_lookuptable",g_strdup(tmpbuf),g_free);
- g_free(tmpbuf);
- }
- if(!cfg_read_string(cfgfile,section,"z_lookuptable",&tmpbuf))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"z_lookuptable\" variable not found in interrogation profile, NOT NECESSARILY AN ERROR\n"));
- else
- {
- OBJ_SET_FULL(firmware->table_params[i]->z_object,"lookuptable",g_strdup(tmpbuf),g_free);
- g_free(tmpbuf);
- }
- }
- }
- cfg_read_boolean(cfgfile,section,"x_use_color",&firmware->table_params[i]->x_use_color);
- cfg_read_boolean(cfgfile,section,"y_use_color",&firmware->table_params[i]->y_use_color);
- cfg_read_boolean(cfgfile,section,"z_use_color",&firmware->table_params[i]->z_use_color);
- if(!cfg_read_string(cfgfile,section,"table_name",&firmware->table_params[i]->table_name))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"table_name\" variable not found in interrogation profile, ERROR\n"));
- g_free(section);
- }
- /* Allocate space for Table Editor structures.... */
- firmware->te_params = g_new0(TE_Params *,firmware->total_te_tables);
- for (i=0;i<firmware->total_te_tables;i++)
- {
- firmware->te_params[i] = initialize_te_params();
- section = g_strdup_printf("te_table_%i",i);
- cfg_read_boolean(cfgfile,section,"x_lock",&firmware->te_params[i]->x_lock);
- cfg_read_boolean(cfgfile,section,"y_lock",&firmware->te_params[i]->y_lock);
- cfg_read_boolean(cfgfile,section,"reversed",&firmware->te_params[i]->reversed);
- cfg_read_string(cfgfile,section,"bind_to_list",&firmware->te_params[i]->bind_to_list);
- if(cfg_read_string(cfgfile,section,"match_type",&tmpbuf))
- {
- firmware->te_params[i]->match_type = (MatchType)translate_string_f(tmpbuf);
- g_free(tmpbuf);
- }
- cfg_read_boolean(cfgfile,section,"gauge_temp_dep",&firmware->te_params[i]->gauge_temp_dep);
- cfg_read_string(cfgfile,section,"gauge",&firmware->te_params[i]->gauge);
- cfg_read_string(cfgfile,section,"c_gauge",&firmware->te_params[i]->c_gauge);
- cfg_read_string(cfgfile,section,"f_gauge",&firmware->te_params[i]->f_gauge);
- if (firmware->te_params[i]->f_gauge || firmware->te_params[i]->c_gauge || firmware->te_params[i]->gauge)
- cfg_read_string(cfgfile,section,"gauge_datasource",&firmware->te_params[i]->gauge_datasource);
- cfg_read_boolean(cfgfile,section,"x_use_color",&firmware->te_params[i]->x_use_color);
- cfg_read_boolean(cfgfile,section,"y_use_color",&firmware->te_params[i]->y_use_color);
- cfg_read_boolean(cfgfile,section,"x_temp_dep",&firmware->te_params[i]->x_temp_dep);
- cfg_read_boolean(cfgfile,section,"y_temp_dep",&firmware->te_params[i]->y_temp_dep);
- if(!cfg_read_string(cfgfile,section,"x_axis_label",&firmware->te_params[i]->x_axis_label))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"x_axis_label\" flag not found in \"%s\" section in interrogation profile, ERROR\n"),section);
- if(!cfg_read_string(cfgfile,section,"y_axis_label",&firmware->te_params[i]->y_axis_label))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"y_axis_label\" flag not found in \"%s\" section in interrogation profile, ERROR\n"),section);
- if(!cfg_read_int(cfgfile,section,"x_page",&firmware->te_params[i]->x_page))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"x_page\" flag not found in \"%s\" section in interrogation profile, ERROR\n"),section);
- if(!cfg_read_int(cfgfile,section,"y_page",&firmware->te_params[i]->y_page))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"y_page\" flag not found in \"%s\" section in interrogation profile, ERROR\n"),section);
- if(!cfg_read_int(cfgfile,section,"x_base_offset",&firmware->te_params[i]->x_base))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"x_base_offset\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_int(cfgfile,section,"y_base_offset",&firmware->te_params[i]->y_base))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"y_base_offset\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_int(cfgfile,section,"bincount",&firmware->te_params[i]->bincount))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"x_bincount\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_string(cfgfile,section,"x_size",&tmpbuf))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"x_size\" enumeration not found in interrogation profile, ERROR\n"));
- else
- {
- firmware->te_params[i]->x_size = (DataSize)translate_string_f(tmpbuf);
- g_free(tmpbuf);
- }
- if(!cfg_read_string(cfgfile,section,"y_size",&tmpbuf))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"y_size\" enumeration not found in interrogation profile, ERROR\n"));
- else
- {
- firmware->te_params[i]->y_size = (DataSize)translate_string_f(tmpbuf);
- g_free(tmpbuf);
- }
- if(!cfg_read_string(cfgfile,section,"x_source",&firmware->te_params[i]->x_source))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"x_source\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_string(cfgfile,section,"x_units",&firmware->te_params[i]->x_units))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"x_units\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_string(cfgfile,section,"x_name",&firmware->te_params[i]->x_name))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"x_name\" variable not found in interrogation profile, ERROR\n"));
- if(cfg_read_float(cfgfile,section,"x_fromecu_mult",&tmpf))
- {
- firmware->te_params[i]->x_fromecu_mult = g_new0(gfloat,1 );
- *(firmware->te_params[i]->x_fromecu_mult) = tmpf;
- }
- if(cfg_read_float(cfgfile,section,"x_fromecu_add",&tmpf))
- {
- firmware->te_params[i]->x_fromecu_add = g_new0(gfloat,1 );
- *(firmware->te_params[i]->x_fromecu_add) = tmpf;
- }
- if(!cfg_read_int(cfgfile,section,"x_raw_lower",&firmware->te_params[i]->x_raw_lower))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"x_raw_lower\" variable not found in interrogation profile for table %i, ERROR\n"),i);
- if(!cfg_read_int(cfgfile,section,"x_raw_upper",&firmware->te_params[i]->x_raw_upper))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"x_raw_upper\" variable not found in interrogation profile for table %i, ERROR\n"),i);
- if(!cfg_read_int(cfgfile,section,"x_precision",&firmware->te_params[i]->x_precision))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"x_precision\" variable not found in interrogation profile for table %i, ERROR\n"),i);
- if(!cfg_read_string(cfgfile,section,"y_units",&firmware->te_params[i]->y_units))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"y_units\" variable not found in interrogation profile, ERROR\n"));
- if(!cfg_read_string(cfgfile,section,"y_name",&firmware->te_params[i]->y_name))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"y_name\" variable not found in interrogation profile, ERROR\n"));
- if(cfg_read_float(cfgfile,section,"y_fromecu_mult",&tmpf))
- {
- firmware->te_params[i]->y_fromecu_mult = g_new0(gfloat,1 );
- *(firmware->te_params[i]->y_fromecu_mult) = tmpf;
- }
- if(cfg_read_float(cfgfile,section,"y_fromecu_add",&tmpf))
- {
- firmware->te_params[i]->y_fromecu_add = g_new0(gfloat,1 );
- *(firmware->te_params[i]->y_fromecu_add) = tmpf;
- }
- if(!cfg_read_int(cfgfile,section,"y_raw_lower",&firmware->te_params[i]->y_raw_lower))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"y_raw_lower\" variable not found in interrogation profile for table %i, ERROR\n"),i);
- if(!cfg_read_int(cfgfile,section,"y_raw_upper",&firmware->te_params[i]->y_raw_upper))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"y_raw_upper\" variable not found in interrogation profile for table %i, ERROR\n"),i);
- if(!cfg_read_int(cfgfile,section,"y_precision",&firmware->te_params[i]->y_precision))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"y_precision\" variable not found in interrogation profile for table %i, ERROR\n"),i);
- if(!cfg_read_string(cfgfile,section,"title",&firmware->te_params[i]->title))
- MTXDBG(INTERROGATOR|CRITICAL,_("\"title\" variable not found in interrogation profile, ERROR\n"));
- g_free(section);
- }
- cfg_free(cfgfile);
- /* Allocate RAM for the Req_Fuel_Params structures.*/
- firmware->rf_params = g_new0(Req_Fuel_Params *,firmware->total_tables);
- /* Allocate RAM for the Table_Params structures and copy data in..*/
- for (i=0;i<firmware->total_tables;i++)
- {
- firmware->rf_params[i] = g_new0(Req_Fuel_Params ,1);
- /* Check for multi source table handling */
- if (firmware->table_params[i]->x_multi_source)
- {
- firmware->table_params[i]->x_multi_hash = g_hash_table_new_full(g_str_hash,g_str_equal,NULL,NULL);
- expr_keys = g_strsplit(firmware->table_params[i]->x_multi_expr_keys,",",-1);
- sources = g_strsplit(firmware->table_params[i]->x_sources,",",-1);
- suffixes = g_strsplit(firmware->table_params[i]->x_suffixes,",",-1);
- fromecu_mults = g_strsplit(firmware->table_params[i]->x_fromecu_mults,",",-1);
- fromecu_a…
Large files files are truncated, but you can click here to view the full file