Exemple #1
0
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;
	extern gconstpointer *global_data;

	filenames = get_files(g_build_filename(INTERROGATOR_DATA_DIR,"Profiles",DATA_GET(global_data,"ecu_family"),NULL),g_strdup("prof"),&classes);
	if (!filenames)
	{
		dbg_func_f(INTERROGATOR|CRITICAL,g_strdup(__FILE__": determine_ecu()\n\t NO Interrogation profiles found,  was MegaTunix installed properly?\n\n"));
		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_DATA)
		{
			dbg_func_f(INTERROGATOR,g_strdup_printf("\tCommand (%s), returned %i byts\n",test->test_desc,test->num_bytes));
			thread_update_logbar_f("interr_view","info",g_strdup_printf("\tCommand (%s), returned %i bytes)\n",test->test_desc,test->num_bytes),FALSE,FALSE);
		}
		if (test->result_type == RESULT_TEXT)
		{
			dbg_func_f(INTERROGATOR,g_strdup_printf("\tCommand (%s), returned (%s)\n",test->test_desc,test->result_str));
			thread_update_logbar_f("interr_view","info",g_strdup_printf("\tCommand (%s), returned (%s)\n",test->test_desc,test->result_str),FALSE,FALSE);
		}
		else if (test->result_type == RESULT_LIST)
		{
			dbg_func_f(INTERROGATOR,g_strdup_printf("\tCommand (%s), returned %i elements\n",test->test_desc,g_list_length((GList *)test->result)));
			thread_update_logbar_f("interr_view","info",g_strdup_printf("\tCommand (%s), returned %i elements\n",test->test_desc,g_list_length((GList *)test->result)),FALSE,FALSE);
		}
	}
	if (match == FALSE) /* (we DID NOT find one) */
	{
		dbg_func_f(INTERROGATOR|CRITICAL,g_strdup(__FILE__":\n\tdetermine_ecu()\n\tFirmware NOT DETECTED, Enable Interrogation debugging, retry interrogation,\nclose megatunix, and send ~/MTXlog.txt to the author for analysis with a note\ndescribing which firmware you are attempting to talk to.\n"));
		update_logbar_f("interr_view","warning",g_strdup("Firmware NOT DETECTED, Enable Interrogation debugging, retry interrogation,\nclose megatunix, and send ~/MTXlog.txt to the author for analysis with a note\ndescribing which firmware you are attempting to talk to.\n"),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);
	return(retval);
}
Exemple #2
0
/*!
  \brief set_offline_mode() is called when the "Offline Mode" button is clicked
  in the general tab and is used to present the user with list of firmware 
  choices to select one for loading to work in offline mode (no connection to
  an ECU)
  */
G_MODULE_EXPORT gboolean set_offline_mode(void)
{
	GtkWidget * widget = NULL;
	gchar * filename = NULL;
	gboolean tmp = TRUE;
	GArray *pfuncs = NULL;
	PostFunction *pf = NULL;
	GAsyncQueue *io_repair_queue = NULL;
	Firmware_Details *firmware = NULL;
	void (*load_firmware_details)(void *,const gchar *) = NULL;

	ENTER();
	firmware = (Firmware_Details *)DATA_GET(global_data,"firmware");
	io_repair_queue = (GAsyncQueue *)DATA_GET(global_data,"io_repair_queue");

	/* Cause Serial Searcher thread to abort.... */
	if (io_repair_queue)
		g_async_queue_push(io_repair_queue,&tmp);

	filename = present_firmware_choices();
	if (!filename)
	{
		DATA_SET(global_data,"offline",GINT_TO_POINTER(FALSE));
		DATA_SET(global_data,"interrogated",GINT_TO_POINTER(FALSE));
		widget = lookup_widget("interrogate_button");
		if (GTK_IS_WIDGET(widget))
			gtk_widget_set_sensitive(GTK_WIDGET(widget),TRUE);
		widget = lookup_widget("offline_button");
		if (GTK_IS_WIDGET(widget))
			gtk_widget_set_sensitive(GTK_WIDGET(widget),TRUE);
		plugins_shutdown();
		/* Does this need a delay? */
		personality_choice();

		EXIT();
		return FALSE;
	}

	DATA_SET_FULL(global_data,"last_offline_profile",g_strdup(filename),g_free);
	DATA_SET(global_data,"offline",GINT_TO_POINTER(TRUE));
	DATA_SET(global_data,"interrogated",GINT_TO_POINTER(TRUE));

	/* Disable interrogation button */
	widget = lookup_widget("interrogate_button");
	if (GTK_IS_WIDGET(widget))
		gtk_widget_set_sensitive(GTK_WIDGET(widget),FALSE);

	widget = lookup_widget("netaccess_table");
	if (GTK_IS_WIDGET(widget))
		gtk_widget_set_sensitive(GTK_WIDGET(widget),FALSE);

	queue_function("kill_conn_warning");

	if (!firmware)
	{
		firmware = g_new0(Firmware_Details,1);
		DATA_SET(global_data,"firmware",firmware);
	}
	if (get_symbol("load_firmware_details",(void **)&load_firmware_details))
	{
		load_firmware_details(firmware,filename);
	}
	else
		printf("Unable to load firmware details!\n");

	pfuncs = g_array_new(FALSE,TRUE,sizeof(PostFunction *));

	pf = g_new0(PostFunction,1);
	pf->name = g_strdup("update_interrogation_gui_pf");
	get_symbol(pf->name,(void **)&pf->function);
	pf->w_arg = FALSE;
	pfuncs = g_array_append_val(pfuncs,pf);

	pf = g_new0(PostFunction,1);
	pf->name = g_strdup("load_realtime_map_pf");
	get_symbol(pf->name,(void **)&pf->function);
	pf->w_arg = FALSE;
	pfuncs = g_array_append_val(pfuncs,pf);

	pf = g_new0(PostFunction,1);
	pf->name = g_strdup("initialize_dashboards_pf");
	get_symbol(pf->name,(void **)&pf->function);
	pf->w_arg = FALSE;
	pfuncs = g_array_append_val(pfuncs,pf);

	pf = g_new0(PostFunction,1);
	pf->name = g_strdup("load_status_pf");
	get_symbol(pf->name,(void **)&pf->function);
	pf->w_arg = FALSE;
	pfuncs = g_array_append_val(pfuncs,pf);

	pf = g_new0(PostFunction,1);
	pf->name = g_strdup("load_rt_text_pf");
	get_symbol(pf->name,(void **)&pf->function);
	pf->w_arg = FALSE;
	pfuncs = g_array_append_val(pfuncs,pf);

	pf = g_new0(PostFunction,1);
	pf->name = g_strdup("load_gui_tabs_pf");
	get_symbol(pf->name,(void **)&pf->function);
	pf->w_arg = FALSE;
	pfuncs = g_array_append_val(pfuncs,pf);

	pf = g_new0(PostFunction,1);
	pf->name = g_strdup("start_statuscounts_pf");
	get_symbol(pf->name,(void **)&pf->function);
	pf->w_arg = FALSE;
	pfuncs = g_array_append_val(pfuncs,pf);

	pf = g_new0(PostFunction,1);
	pf->name = g_strdup("disable_burner_buttons_pf");
	get_symbol(pf->name,(void **)&pf->function);
	pf->w_arg = FALSE;
	pfuncs = g_array_append_val(pfuncs,pf);

	/* BUG, causes deadlock
	pf = g_new0(PostFunction,1);
	pf->name = g_strdup("offline_ecu_restore_pf");
	get_symbol(pf->name,(void **)&pf->function);
	pf->w_arg = FALSE;
	pfuncs = g_array_append_val(pfuncs,pf);
	*/

	pf = g_new0(PostFunction,1);
	pf->name = g_strdup("setup_menu_handlers_pf");
	get_symbol(pf->name,(void **)&pf->function);
	pf->w_arg = FALSE;
	pfuncs = g_array_append_val(pfuncs,pf);

	pf = g_new0(PostFunction,1);
	pf->name = g_strdup("enable_3d_buttons_pf");
	get_symbol(pf->name,(void **)&pf->function);
	pf->w_arg = FALSE;
	pfuncs = g_array_append_val(pfuncs,pf);

	pf = g_new0(PostFunction,1);
	pf->name = g_strdup("ready_msg_pf");
	get_symbol(pf->name,(void **)&pf->function);
	pf->w_arg = FALSE;
	pfuncs = g_array_append_val(pfuncs,pf);

	pf = g_new0(PostFunction,1);
	pf->name = g_strdup("cleanup_pf");
	get_symbol(pf->name,(void **)&pf->function_w_arg);
	pf->w_arg = TRUE;
	pfuncs = g_array_append_val(pfuncs,pf);

	io_cmd(NULL,pfuncs);

	/*
	   io_cmd(firmware->get_all_command,NULL);
	 */

	widget = lookup_widget("binary_logging_frame");
	if (GTK_IS_WIDGET(widget))
		gtk_widget_set_sensitive(GTK_WIDGET(widget),FALSE);
	widget = lookup_widget("interrogate_button");
	if (GTK_IS_WIDGET(widget))
		gtk_widget_set_sensitive(GTK_WIDGET(widget),FALSE);
	widget = lookup_widget("offline_button");
	if (GTK_IS_WIDGET(widget))
		gtk_widget_set_sensitive(GTK_WIDGET(widget),FALSE);
	g_list_foreach(get_list("get_data_buttons"),set_widget_sensitive,GINT_TO_POINTER(FALSE));

	pfuncs = g_array_new(FALSE,TRUE,sizeof(PostFunction *));

	pf = g_new0(PostFunction,1);
	pf->name = g_strdup("reset_temps_pf");
	get_symbol(pf->name,(void **)&pf->function);
	pf->w_arg = FALSE;
	pfuncs = g_array_append_val(pfuncs,pf);

	pf = g_new0(PostFunction,1);
	pf->name = g_strdup("cleanup_pf");
	get_symbol(pf->name,(void **)&pf->function_w_arg);
	pf->w_arg = TRUE;
	pfuncs = g_array_append_val(pfuncs,pf);
	io_cmd(NULL,pfuncs);
	EXIT();
	return FALSE;
}