Exemplo n.º 1
0
/*!
  \brief returns the ECU data corresponding to the fields attached to the 
  data object, data can be either a GtkWidget pointer or a gconstpointer
  \param data pointer to container, should contain the following fields
  offset, size, and location_id or page
  \returns the value at that ECU memory location
  */
G_MODULE_EXPORT gint get_ecu_data(gpointer data)
{
	gint locID = 0;
	gint page = 0;
	gint offset = 0;
	DataSize size = MTX_U08;
	gint value = 0 ;
	GtkWidget *widget = NULL;
	gconstpointer *container = NULL;
	Firmware_Details *firmware = NULL;
	static gint (*_get_sized_data)(guint8 *, gint, DataSize, gboolean) = NULL;
	ENTER();
	if (!_get_sized_data)
		get_symbol_f("_get_sized_data",(void **)&_get_sized_data);

	firmware = (Firmware_Details *)DATA_GET(global_data,"firmware");
	widget = (GtkWidget *)data;
	container = (gconstpointer *)data;
	if (GTK_IS_WIDGET(widget))
	{
		offset = (GINT)OBJ_GET(widget,"offset");
		size = (DataSize)(GINT)OBJ_GET(widget,"size");
		if (OBJ_GET(widget,"location_id"))
		{
			locID = (GINT)OBJ_GET(widget,"location_id");
			g_return_val_if_fail(libreems_find_mtx_page(locID, &page),0);;
		}
		else if (OBJ_GET(widget,"page"))
			page = (GINT)OBJ_GET(widget,"page");
	}
	else
	{
		offset = (GINT)DATA_GET(container,"offset");
		size = (DataSize)(GINT)DATA_GET(container,"size");
		if (DATA_GET(container,"location_id"))
		{
			locID = (GINT)DATA_GET(container,"location_id");
			g_return_val_if_fail(libreems_find_mtx_page(locID, &page),0);;
		}
		else if (DATA_GET(container,"page"))
			page = (GINT)DATA_GET(container,"page");
	}

	/* Sanity checking */
	g_return_val_if_fail(firmware,0);
	g_return_val_if_fail(firmware->page_params,0);
	g_return_val_if_fail(firmware->page_params[page],0);
	g_return_val_if_fail((offset >= 0) && (offset < firmware->page_params[page]->length),0);

	EXIT();
	return _get_sized_data(firmware->ecu_data[page],offset,size,firmware->bigendian);
}
Exemplo n.º 2
0
/*!
 \brief freeems_get_ecu_data_backup() is a func to return the data requested.
 \param canID, CANbus ID (unused currently)
 \param locID, Location ID (internal to ECU)
 \param offset (RAW BYTE offset)
 \param size (size to be returned...
 */
G_MODULE_EXPORT gint freeems_get_ecu_data_backup(gint canID, gint locID, gint offset, DataSize size) 
{
	gint page = 0;
	Firmware_Details *firmware = NULL;
	static gint (*_get_sized_data)(guint8 *, gint, DataSize, gboolean) = NULL;
	if (!_get_sized_data)
		get_symbol_f("_get_sized_data",(void*)&_get_sized_data);
 

	firmware = DATA_GET(global_data,"firmware");
	g_return_val_if_fail(freeems_find_mtx_page(locID, &page),0);
	g_return_val_if_fail(firmware,0);
	g_return_val_if_fail(firmware->page_params,0);
	g_return_val_if_fail(firmware->page_params[page],0);
	g_return_val_if_fail((offset >= 0) && (offset < firmware->page_params[page]->length),0);
	return _get_sized_data(firmware->ecu_data_backup[page],offset,size,firmware->bigendian);
}
Exemplo n.º 3
0
/*!
 \brief Megasquirrt specific function to return the data from the "last" buffer
 \param canID is the CAN Identifier (currently unused)
 \param page is the ecu firmware page
 \param offset is the RAW BYTE offset
 \param size is the size to be returned
 \returns the value requested or 0 on error
 */
G_MODULE_EXPORT gint ms_get_ecu_data_last(gint canID, gint page, gint offset, DataSize size) 
{
	Firmware_Details *firmware = NULL;
	static gint (*_get_sized_data)(guint8 *, gint, DataSize, gboolean) = NULL;
	if (!_get_sized_data)
		get_symbol_f("_get_sized_data",(void*)&_get_sized_data);
	g_return_val_if_fail(_get_sized_data,0);
 

	firmware = DATA_GET(global_data,"firmware");
	g_return_val_if_fail(firmware,0);
	g_return_val_if_fail(firmware->page_params,0);
	g_return_val_if_fail(page < firmware->total_pages,0);
	g_return_val_if_fail(page >= 0,0);
	g_return_val_if_fail(firmware->page_params[page],0);
	g_return_val_if_fail(((offset >= 0 ) && (offset < firmware->page_params[page]->length)),0);
	return _get_sized_data(firmware->ecu_data_last[page],offset,size,firmware->bigendian);
}
Exemplo n.º 4
0
/*!
  \brief A generic function to returns the data from the representation of
  ECU memory. This will call an ECU specific function to do the heavy lifting
  \param data is either a GtkWidget pointer or a gconstpointer which contains
  name:value associations describng the location to return
  \returns the value requested or 0 if error
*/
G_MODULE_EXPORT gint get_ecu_data(gpointer data)
{
	gint canID = 0;
	gint page = 0;
	gint offset = 0;
	DataSize size = MTX_U08;
	gint value = 0 ;
	GtkWidget *widget = NULL;
	gconstpointer *container = NULL;
	Firmware_Details *firmware = NULL;
	static gint (*_get_sized_data)(guint8 *, gint, DataSize, gboolean) = NULL;
	if (!_get_sized_data)
		get_symbol_f("_get_sized_data",(void*)&_get_sized_data);
	g_return_val_if_fail(_get_sized_data,0);

	firmware = DATA_GET(global_data,"firmware");
	/* Sanity checking */
	g_return_val_if_fail(data,0);
	g_return_val_if_fail(firmware,0);
	g_return_val_if_fail(firmware->page_params,0);
	g_return_val_if_fail(firmware->page_params[page],0);
	g_return_val_if_fail(((offset >= 0 ) && (offset < firmware->page_params[page]->length)),0);

	widget = (GtkWidget *)data;
	container = (gconstpointer *)data;
	if (GTK_IS_WIDGET(widget))
	{
		canID = (GINT)OBJ_GET(widget,"canID");
		page = (GINT)OBJ_GET(widget,"page");
		offset = (GINT)OBJ_GET(widget,"offset");
		size = (DataSize)OBJ_GET(widget,"size");
	}
	else
	{
		canID = (GINT)DATA_GET(container,"canID");
		page = (GINT)DATA_GET(container,"page");
		offset = (GINT)DATA_GET(container,"offset");
		size = (DataSize)DATA_GET(container,"size");
	}

	return _get_sized_data(firmware->ecu_data[page],offset,size,firmware->bigendian);
}
Exemplo n.º 5
0
/*!
 \brief returns the ECU data at the location coordinates provided
 \param canID is the CANbus ID (unused currently)
 \param locID is the Location ID (internal to ECU)
 \param offset is the (RAW BYTE offset)
 \param size is the (size to be returned)
 \returns the value at those specific memory coordinates
 */
G_MODULE_EXPORT gint libreems_get_ecu_data(gint canID, gint locID, gint offset, DataSize size) 
{
	Firmware_Details *firmware = NULL;
	static gint (*_get_sized_data)(guint8 *, gint, DataSize, gboolean) = NULL;
	gint page = 0;
	ENTER();
	if (!_get_sized_data)
		get_symbol_f("_get_sized_data",(void **)&_get_sized_data);
 

	firmware = (Firmware_Details *)DATA_GET(global_data,"firmware");
	/* Sanity checking */
	g_return_val_if_fail(libreems_find_mtx_page(locID, &page),0);
	g_return_val_if_fail(firmware,0);
	g_return_val_if_fail(firmware->page_params,0);
	g_return_val_if_fail(firmware->page_params[page],0);
	g_return_val_if_fail((offset >= 0) && (offset < firmware->page_params[page]->length),0);

	EXIT();
	return _get_sized_data(firmware->ecu_data[page],offset,size,firmware->bigendian);
}