示例#1
0
/*!
 \brief Updates General tab ECU info box
 */
G_MODULE_EXPORT void ecu_info_update(Firmware_Details *firmware)
{
	gchar *tmpbuf = NULL;
	ENTER();
	g_return_if_fail(firmware);
	tmpbuf = g_strdup_printf("<b>Firmware Version:</b> %s\n<b>Firmware Signature:</b> %s\n<b>Numeric Version:</b> %.1f",firmware->text_revision,firmware->actual_signature,firmware->ecu_revision/10.0);
	thread_update_widget_f("ecu_info_label",MTX_LABEL,g_strdup(tmpbuf));
	g_free(tmpbuf);

}
示例#2
0
G_MODULE_EXPORT void update_interrogation_gui_pf(void)
{
	gchar *version = NULL;
	gchar *fw_version = NULL;
	guint8 major = 0;
	guint8 minor = 0;
	guint8 micro = 0;

	if (!DATA_GET(global_data,"interrogated"))
		return;
	/* Request firmware version */
	fw_version = request_firmware_version(NULL);
	thread_update_widget_f("ecu_signature_entry",MTX_ENTRY,g_strdup(fw_version));
	g_free(fw_version);

	/* Request interface version */
	version = request_detailed_interface_version(&major, &minor, &micro);
	thread_update_widget_f("text_version_entry",MTX_ENTRY,g_strdup(version));
	thread_update_widget_f("ecu_revision_entry",MTX_ENTRY,g_strdup_printf("%i.%i.%i",major,minor,micro));
	g_free(version);

}
示例#3
0
/*!
  \brief updates the interrogation Gui (General Tab) with the Firmware and 
  Interface Versions
  */
G_MODULE_EXPORT void update_ecu_info(void)
{
	gchar *int_version = NULL;
	gchar *fw_version = NULL;
	gchar *build_date = NULL;
	gchar *build_os = NULL;
	gchar *compiler = NULL;
	gchar *info = NULL;

	fw_version = DATA_GET(global_data,"fw_version");
	int_version = DATA_GET(global_data,"int_version");
	build_date = DATA_GET(global_data,"build_date");
	build_os = DATA_GET(global_data,"build_os");
	compiler = DATA_GET(global_data,"compiler");
	if ((fw_version) && (int_version) && (build_date) && (build_os) && (compiler))
	{
		info = g_strdup_printf("<b>Firmware Version:</b> %s\n<b>Interface version:</b> %s\nThis firmware was built on %s using the %s compiler on %s",fw_version,int_version,build_date,compiler,build_os);
		thread_update_widget_f("ecu_info_label",MTX_LABEL,g_strdup(info));
		g_free(info);
	}
	return;
}
示例#4
0
G_MODULE_EXPORT void *serial_repair_thread(gpointer data)
{
	/* We got sent here because of one of the following occurred:
	 * Serial port isn't opened yet (app just fired up)
	 * Serial I/O errors (missing data, or failures reading/writing)
	 *  - This includes things like pulling the RS232 cable out of the ECU
	 * Serial port disappeared (i.e. device hot unplugged)
	 *  - This includes unplugging the USB side of a USB->Serial adapter
	 *    or going out of bluetooth range, for a BT serial device
	 *
	 * Thus we need to handle all possible conditions if possible
	 */
	static gboolean serial_is_open = FALSE; /* Assume never opened */
	static GAsyncQueue *io_repair_queue = NULL;
	gchar * potential_ports;
	gint len = 0;
	gboolean autodetect = FALSE;
	guchar buf [1024];
	gchar ** vector = NULL;
	guint i = 0;
	Serial_Params *serial_params = NULL;
	void (*unlock_serial_f)(void) = NULL;
	void (*close_serial_f)(void) = NULL;
	gboolean (*open_serial_f)(const gchar *,gboolean) = NULL;
	gboolean (*lock_serial_f)(const gchar *) = NULL;
	void (*setup_serial_params_f)(void) = NULL;

	ENTER();
	serial_params = (Serial_Params *)DATA_GET(global_data,"serial_params");

	get_symbol_f("setup_serial_params",(void **)&setup_serial_params_f);
	get_symbol_f("open_serial",(void **)&open_serial_f);
	get_symbol_f("close_serial",(void **)&close_serial_f);
	get_symbol_f("lock_serial",(void **)&lock_serial_f);
	get_symbol_f("unlock_serial",(void **)&unlock_serial_f);
	MTXDBG(THREADS|CRITICAL,_("LibreEMS serial_repair_thread() created!\n"));

	if (DATA_GET(global_data,"offline"))
	{
		g_timeout_add(100,(GSourceFunc)queue_function_f,(gpointer)"kill_conn_warning");
		MTXDBG(THREADS|CRITICAL,_("LibreEMS serial_repair_thread() exiting, offline mode!\n"));
		g_thread_exit(0);
	}
	if (!io_repair_queue)
		io_repair_queue = (GAsyncQueue *)DATA_GET(global_data,"io_repair_queue");
	/* IF serial_is_open is true, then the port was ALREADY opened 
	 * previously but some error occurred that sent us down here. Thus
	 * first do a simple comms test, if that succeeds, then just cleanup 
	 * and return,  if not, close the port and essentially start over.
	 */
	if (serial_is_open == TRUE)
	{
		MTXDBG(SERIAL_RD|SERIAL_WR,_("Port considered open, but throwing errors\n"));
		libreems_serial_disable();
		close_serial_f();
		unlock_serial_f();
		serial_is_open = FALSE;
		/* Fall through */
	}
	while (!serial_is_open)
	{
		/* If "leaving" flag set, EXIT now */
		if (DATA_GET(global_data,"leaving"))
			g_thread_exit(0);
		MTXDBG(SERIAL_RD|SERIAL_WR,_("Port NOT considered open yet.\n"));
		autodetect = (GBOOLEAN) DATA_GET(global_data,"autodetect_port");
		if (!autodetect) /* User thinks he/she is S M A R T */
		{
			potential_ports = (gchar *)DATA_GET(global_data, "override_port");
			if (potential_ports == NULL)
				potential_ports = (gchar *)DATA_GET(global_data,"potential_ports");
		}
		else    /* Auto mode */
			potential_ports = (gchar *)DATA_GET(global_data,"potential_ports");
		vector = g_strsplit(potential_ports,",",-1);
		for (guint i=0;i<g_strv_length(vector);i++)
		{
			if (DATA_GET(global_data,"leaving"))
			{
				g_strfreev(vector);
				g_thread_exit(0);
			}
			/* Message queue used to exit immediately */
			if (g_async_queue_try_pop(io_repair_queue))
			{
				g_timeout_add(300,(GSourceFunc)queue_function_f,(gpointer)"kill_conn_warning");
				MTXDBG(THREADS|CRITICAL,_("LibreEMS serial_repair_thread() exiting, told to!\n"));
				g_thread_exit(0);
			}
			if (!g_file_test(vector[i],G_FILE_TEST_EXISTS))
			{
				MTXDBG(SERIAL_RD|SERIAL_WR,_("Port %s does NOT exist\n"),vector[i]);

				/* Wait 100 ms to avoid deadlocking */
				g_usleep(100000);
				continue;
			}
			g_usleep(100000);
			MTXDBG(SERIAL_RD|SERIAL_WR,_("Attempting to open port %s\n"),vector[i]);
			thread_update_logbar_f("comms_view",NULL,g_strdup_printf(_("Attempting to open port %s\n"),vector[i]),FALSE,FALSE);
			if (lock_serial_f(vector[i]))
			{
				if (open_serial_f(vector[i],TRUE))
				{
					if (autodetect)
						thread_update_widget_f("active_port_entry",MTX_ENTRY,g_strdup(vector[i]));
					MTXDBG(SERIAL_RD|SERIAL_WR,_("Port %s opened\n"),vector[i]);
					setup_serial_params_f();
					libreems_serial_enable();

					thread_update_logbar_f("comms_view",NULL,g_strdup_printf(_("Searching for ECU\n")),FALSE,FALSE);
					MTXDBG(SERIAL_RD|SERIAL_WR,_("Performing ECU comms test via port %s.\n"),vector[i]);
					if (comms_test())
					{       /* We have a winner !!  Abort loop */
						thread_update_logbar_f("comms_view",NULL,g_strdup_printf(_("Search successfull\n")),FALSE,FALSE);
						serial_is_open = TRUE;
						break;
					}
					else
					{
						MTXDBG(SERIAL_RD|SERIAL_WR,_("COMMS test failed, no ECU found, closing port %s.\n"),vector[i]);
						thread_update_logbar_f("comms_view",NULL,g_strdup_printf(_("No ECU found...\n")),FALSE,FALSE);
						libreems_serial_disable();
						close_serial_f();
						unlock_serial_f();
						/*g_usleep(100000);*/
					}
				}
				g_usleep(100000);
			}
			else
			{
				MTXDBG(SERIAL_RD|SERIAL_WR,_("Port %s is open by another application\n"),vector[i]);
				thread_update_logbar_f("comms_view","warning",g_strdup_printf(_("Port %s is open by another application\n"),vector[i]),FALSE,FALSE);
			}
		}
		queue_function_f("conn_warning");
	}

	if (serial_is_open)
	{
		queue_function_f("kill_conn_warning");
		thread_update_widget_f("active_port_entry",MTX_ENTRY,g_strdup(vector[i]));
	}
	if (vector)
		g_strfreev(vector);
	MTXDBG(THREADS|CRITICAL,_("LibreEMS serial_repair_thread()  exiting, device found!\n"));
	g_thread_exit(0);
	EXIT();
	return NULL;
}