send a complex structure with DBus

"Charles Hervé Tchoutat Tchabo" t_charles at gmx.de
Tue Sep 4 12:21:19 PDT 2007


Hello,
I am writing a program using DBus to receive information and treat these information. I succeed to send and receive unique variable as string, integer, float ... but when I try to send a structure oder an arry of structure I have all problem. Here is my, I will be very pleased if anyone can look at it and help me to correct it
my server:

/**********************************************
 * File server-guimessdata.c 
 * listen the object send by the client
 *
 *
 *
 *---------------------------------------------
 */

#include <dbus/dbus-protocol.h>
#include <dbus/dbus-glib-bindings.h>
#include <dbus/dbus-glib.h>
#include <glib.h>
#include <glib-object.h>
#include <stdio.h>
#include <stdlib.h>

static void lose (const char *fmt, ...) G_GNUC_NORETURN G_GNUC_PRINTF (1, 2);
static void lose_gerror (const char *prefix, GError *error) G_GNUC_NORETURN;

static void
lose (const char *str, ...)
{
  va_list args;

  va_start (args, str);

  vfprintf (stderr, str, args);
  fputc ('\n', stderr);

  va_end (args);

  exit (1);
}

static void
lose_gerror (const char *prefix, GError *error) 
{
  lose ("%s: %s", prefix, error->message);
}


enum vectortype { VT_XYZ, VT_POLAR };
typedef struct _vector {
	enum vectortype type;
	union {
		//double V[3];    /* for using in loops */
		struct {
			double x;   /* kartesian coordinates */
			double y;
			double z;
		};
		struct {
			double r;   /* polar coordinates */
			double a1;
			double a2;
		};
	};
} vector;

enum angleformat { AF_RAD, AF_DEG };
typedef struct _angles {
	enum angleformat fmt;
	double A;        /* rotation    */
	double B;
	double C;
} angles;


typedef struct GuiMessData GuiMessData;
typedef struct GuiMessDataClass GuiMessDataClass;

GType gui_mess_data_get_type (void);

struct GuiMessData
{
  GObject parent;
};

struct GuiMessDataClass
{
  GObjectClass parent;
};

#define GUI_MESS_TYPE_DATA     	      (gui_mess_data_get_type ())
#define GUI_MESS_DATA(object)         (G_TYPE_CHECK_INSTANCE_CAST ((object), GUI_MESS_TYPE_DATA, GuiMessData))
#define GUI_MESS_DATA_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GUI_MESS_TYPE_DATA, GuiMessDataClass))
#define GUI_MESS_IS_DATA(object)      (G_TYPE_CHECK_INSTANCE_TYPE ((object), GUI_MESS_TYPE_DATA))
#define GUI_MESS_IS_DATA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GUI_MESS_TYPE_DATA))
#define GUI_MESS_DATA_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GUI_MESS_TYPE_DATA, GuiMessDataClass))

G_DEFINE_TYPE(GuiMessData, gui_mess_data, G_TYPE_OBJECT);

//gboolean some_object_hello_world (SomeObject *obj, const char *hello_message, char ***ret, GError **error);
//gboolean some_object_get_tuple (SomeObject *obj, GValueArray **ret, GError **error);
//gboolean some_object_get_dict (SomeObject *obj, GHashTable **ret, GError **error);

void dbase_printESDTestData (const GPtrArray* geoData);
void dbase_printPlugData (const GPtrArray* test_cycle);

/*
gboolean gui_data_start_esd_test (GuiMessData *obj, const char * IN_ecuname, const char * IN_info, const char * IN_base, gboolean* OUT_isEsdStart, GError **error);

gboolean gui_data_start_esd_test(GuiMessData *obj, const char * IN_ecuname, const char * IN_info, const char * IN_base, const char * IN_DUTname, const char * IN_DUTno, const char * IN_DUTdescr, const GPtrArray* IN_arg6, const char * IN_Standard, const gdouble IN_HBM_C, const gdouble IN_HBM_R, const gdouble IN_IntervalContact, const gdouble IN_IntervalAir, const gdouble IN_VelocityAir, const gdouble IN_Frequency, const gdouble IN_AC-Offset, const gdouble IN_DC-Offset, const char * IN_EquivCircuit, const GPtrArray* IN_TestLevel, gboolean* OUT_isEsdStart, GError **error);
*/

gboolean gui_data_start_esd_test (GuiMessData *obj, const char * IN_ecuname, const char * IN_info, const char * IN_base, const char * IN_DUTname, const char * IN_DUTno, const char * IN_DUTdescr, const char * IN_Standard, const gdouble IN_HBM_C, const gdouble IN_HBM_R, const gdouble IN_IntervalContact, const gdouble IN_IntervalAir, const gdouble IN_VelocityAir, const gdouble IN_Frequency, const gdouble IN_AC_Offset, const gdouble IN_DC_Offset, const gboolean IN_EquivCircuit, const GPtrArray* IN_TestLevel, gboolean* OUT_isEsdStart, GError **error);

#include "server-guimessdata.h"
//#include "mathematics.h"

static void
gui_mess_data_init (GuiMessData *obj)
{
}

static void
gui_mess_data_class_init (GuiMessDataClass *klass)
{
}

struct pin
{
   unsigned int 	nr;	/*!< pin number */
   vector 		pp;     /*!< pin point */
   vector 		sp;     /*!< safe point */
};

struct plug
{
    unsigned int 	nr;      /*!< plug number */
    GString* 		name;    /*!< plug name */
    GString*		info;    /*!< free description */
    vector 		origin;  /*!< origin of plug relative to  base system */
    vector 		safe;    /*!< plug's safe point relative to base system */
    angles 		turn;    /*!< orientation of plug, angles */
    unsigned int 	slope;   /*!< add a slope to tool before approaching this plug */
    unsigned int 	count;   /*!< count of pins */
    GPtrArray*		pins;    /*!< list of pins, sorted */

};

struct testlevel {
    int nr;                	/*!< identifier of testlevel */
    gboolean dischargTyp; 	/*!< Type of discharge AIR oter CONTACT */
    gboolean isMeasure;     	/*!< if we should measure */
    gboolean isGround;      	/*!< if we should ground */
    unsigned int count;    	/*!< count of discharges with this level */
    signed int voltage;    	/*!< voltage level of test */
};


void
dbase_printESDTestData (const GPtrArray* test_cycle)
{


    printf ("HALLOOOOOOOO\n");
    GValueArray *testLev;
    guint i,j, n=0;
    GValue val = {0, };
  for (j = 0; i< test_cycle->len; i++){
		testLev = (GValueArray*)g_ptr_array_index(test_cycle, j);
        if (testLev){
    	    for (i = 0; i < testLev->n_values; i++)
    	    {         		
      		switch (i){
       		    case 0:  //val = g_value_array_get_nth (testLev, i);
	       		     if (G_VALUE_TYPE (g_value_array_get_nth (testLev, i)) == G_TYPE_UINT){
		       		printf ("%s", n++ == 0 ? "Testlevel:        " : "                  ");
	    	   		printf ("[%2d] ", g_value_get_int(g_value_array_get_nth (testLev, i)));
	       		     }
		             break;
       		    case 1:  //val = g_value_array_get_nth (testLev, i);
			     if (G_VALUE_TYPE (g_value_array_get_nth (testLev, i)) == G_TYPE_BOOLEAN){
		                 printf ("%s", g_value_get_boolean(g_value_array_get_nth (testLev, i)) ? "Contact" : "Air    ");
			     }
			     break;
       		    case 2: //val = g_value_array_get_nth (testLev, i);
			    if (G_VALUE_TYPE (g_value_array_get_nth (testLev, i)) == G_TYPE_BOOLEAN){
		    	         printf ("%s\n", g_value_get_boolean(g_value_array_get_nth (testLev, i)) ? " ; M" : " ");
			    }
			    break; 
	            case 3: //val = g_value_array_get_nth (testLev, i);
			    if (G_VALUE_TYPE (g_value_array_get_nth (testLev, i)) == G_TYPE_BOOLEAN){
		         	printf ("%s", g_value_get_boolean(g_value_array_get_nth (testLev, i)) ? " ; G" : "");
			    }
			    break;
       		    case 4: //val = g_value_array_get_nth (testLev, i);
			    if (G_VALUE_TYPE (&val) == G_TYPE_UINT){
		    	        printf (" ; %2dx", g_value_get_uint(g_value_array_get_nth (testLev, i)));
			    }
			    break;
       		    case 5: //val = g_value_array_get_nth (testLev, i);
			    if (G_VALUE_TYPE (g_value_array_get_nth (testLev, i)) == G_TYPE_UINT){
		 		if (abs(g_value_get_double(g_value_array_get_nth (testLev, i))) < 1000)
				   printf (" ; %6fV ", g_value_get_double(g_value_array_get_nth (testLev, i)));
		   		else
		       		   printf (" ; %6gkV", (float) g_value_get_double(g_value_array_get_nth (testLev, i)) / 1000);
			    }
			    break;
       		    default:   printf ("erreur \n");
                }
    	    }
   	}    
  }
/*
	struct testlevel *level;
	guint n, i;
	printf ("\n ***** TestLevels   ***** \n");	
 	for (i = 0; i< test_cycle->len; i++){
	    level = (struct testlevel*)g_ptr_array_index(test_cycle, i);
	    printf ("%s", n++ == 0 ? "Testlevel:        " : "                  ");
	    printf ("[%2d] ", level->nr);
	    printf ("%s", level->dischargTyp ? "Contact" : "Air    ");
	    printf (" ; %2dx", level->count);
		if (abs(level->voltage) < 1000)
			printf (" ; %6dV ", level->voltage);
		else
		    printf (" ; %6gkV", (float) level->voltage / 1000);
		printf ("%s", level->isGround ? " ; G" : "");
		printf ("%s\n", level->isMeasure ? " ; M" : " ");
	}
*/
	printf ("\n");	
	g_value_array_free (testLev);	
}

void
dbase_printPlugData (const GPtrArray* geoData)
{
	struct pin *p;
	struct plug *data;
   	//angles *angl = NULL;
        guint i, j;
	printf ("\n *****Electronic definition geometry data***** \n");
	for (i = 0; i< geoData->len; i++){
		data = (struct plug*)g_ptr_array_index(geoData, i);
	    	if (data){
		     printf ("Stecker    %d\n", data->nr);
		     printf ("Plugs name %s\n", data->name->str);
		     printf ("Plugs info %s\n", data->info->str);
		     printf ("Origine:    X =%6.1f ;  Y =%6.1f ;  Z =%6.1f\n", data->origin.x, data->origin.y, data->origin.z);
		     printf ("Safe point: X =%6.1f ;  Y =%6.1f ;  Z =%6.1f\n", data->safe.x, data->safe.y, data->safe.z);
		    // angl = math_convertAngles(&data->turn, AF_DEG);
		     printf ("Turn     :  A =%6.1f ;  B =%6.1f ;  C =%6.1f\n", data->turn.A, data->turn.B, data->turn.C);
		     printf ("Slope  :  %d\n", data->slope);
		     printf ("Count  :  %d\n", data->count);
		     for (j = 0; j < data->pins->len; j++){
		   	  p = (struct pin *)g_ptr_array_index(data->pins, j);
			  if (p){
			     printf ("  %2d: p.X =%6.1f ; p.Y =%6.1f ; p.Z =%6.1f / s.X =%6.1f ; s.Y =%6.1f ; s.Z =%6.1f \n",
				p->nr, p->pp.x, p->pp.y, p->pp.z, p->sp.x, p->sp.y, p->sp.z);
			  }
		     }
		     
		}
	}
	
}

gboolean 
gui_data_start_esd_test (GuiMessData *obj, const char * IN_ecuname, const char * IN_info, const char * IN_base, const char * IN_DUTname, const char * IN_DUTno, const char * IN_DUTdescr, const char * IN_Standard, const gdouble IN_HBM_C, const gdouble IN_HBM_R, const gdouble IN_IntervalContact, const gdouble IN_IntervalAir, const gdouble IN_VelocityAir, const gdouble IN_Frequency, const gdouble IN_AC_Offset, const gdouble IN_DC_Offset, const gboolean IN_EquivCircuit, const GPtrArray* IN_TestLevel, gboolean* OUT_isEsdStart, GError **error)
{
     if (IN_ecuname)
     	g_print ("The ECU name is : %s\n", IN_ecuname);
     else{
	 *OUT_isEsdStart = FALSE;
	 return TRUE;
     }
     
     if (IN_info)
     	g_print ("The ECU info is : %s\n", IN_info);
     else{
	 *OUT_isEsdStart = FALSE;
	 return TRUE;
     }

     if (IN_base)
     	g_print ("The ECU base is : %s\n", IN_base);
     else{
	 *OUT_isEsdStart = FALSE;
	 return TRUE;
     }
     if (IN_DUTname)
     	g_print ("The ECU Tech. name is : %s\n", IN_DUTname);
     else{
	 *OUT_isEsdStart = FALSE;
	 return TRUE;
     }
     if (IN_DUTno)
     	g_print ("The ECU Nummer is : %s\n", IN_DUTno);
     else{
	 *OUT_isEsdStart = FALSE;
	 return TRUE;
     }
     if (IN_DUTdescr)
     	g_print ("The ECU Description is : %s\n", IN_DUTdescr);
     else{
	 *OUT_isEsdStart = FALSE;
	 return TRUE;
     }
/*     if (IN_arg6)
     	dbase_printPlugData (IN_arg6);
     else{
	 *OUT_isEsdStart = FALSE;
	 return TRUE;
     } */

     /* Information about the test cycle */
     if (IN_Standard)
     	g_print ("The Standard of the test cycle is : %s\n", IN_Standard);
     else{
	 *OUT_isEsdStart = FALSE;
	 return TRUE;
     }
     if (IN_HBM_C)
     	g_print ("The Capacitance of the HBM is : %f\n", IN_HBM_C);
     else{
	 *OUT_isEsdStart = FALSE;
	 return TRUE;
     }
     if (IN_HBM_R)
     	g_print ("The Resistance of the HBM is : %f\n", IN_HBM_R);
     else{
	 *OUT_isEsdStart = FALSE;
	 return TRUE;
     }
     if (IN_IntervalContact)
     	g_print ("The Intervall between contact discharge is : %f\n", IN_IntervalContact);
     else{
	 *OUT_isEsdStart = FALSE;
	 return TRUE;
     }
     if (IN_IntervalAir)
     	g_print ("The Intervall between air discharge is : %f\n", IN_IntervalAir);
     else{
	 *OUT_isEsdStart = FALSE;
	 return TRUE;
     }
     if (IN_VelocityAir)
     	g_print ("The approching speed in air discharge is : %f\n", IN_VelocityAir);
     else{
	 *OUT_isEsdStart = FALSE;
	 return TRUE;
     }
     if (IN_Frequency)
     	g_print ("The Frequency of the test is : %f\n", IN_Frequency);
     else{
	 *OUT_isEsdStart = FALSE;
	 return TRUE;
     }
     if (IN_AC_Offset)
     	g_print ("The AC-Offset of the test is : %f\n", IN_AC_Offset);
     else{
	 *OUT_isEsdStart = FALSE;
	 return TRUE;
     }
     if (IN_DC_Offset)
     	g_print ("The IN_DC-Offset of the test is : %f\n", IN_DC_Offset);
     else{
	 *OUT_isEsdStart = FALSE;
	 return TRUE;
     }
     if (IN_EquivCircuit)
     	g_print ("The Equivalent Circuit of the test is : %s\n", IN_EquivCircuit ? "SERIE" : "PARALLEL");
     else{
	 *OUT_isEsdStart = FALSE;
	 return TRUE;
     }
     if (IN_TestLevel)
     	dbase_printESDTestData (IN_TestLevel);
     else{
	 *OUT_isEsdStart = FALSE;
	 return TRUE;
     }

    *OUT_isEsdStart = TRUE;
     return TRUE;
}


int
main (int argc, char **argv)
{
  DBusGConnection *bus;
  DBusGProxy *bus_proxy;
  GError *error = NULL;
  GuiMessData *obj;
  GMainLoop *mainloop;
  guint request_name_result;

  g_type_init ();

  {
    GLogLevelFlags fatal_mask;
    
    fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
    fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
    g_log_set_always_fatal (fatal_mask);
  }
  
  dbus_g_object_type_install_info (GUI_MESS_TYPE_DATA, &dbus_glib_gui_data_object_info);

  mainloop = g_main_loop_new (NULL, FALSE);

  bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
  if (!bus)
    lose_gerror ("Couldn't connect to session bus", error);

 bus_proxy = dbus_g_proxy_new_for_name (bus, 
					DBUS_SERVICE_DBUS,
					DBUS_PATH_DBUS,
					DBUS_INTERFACE_DBUS);


  if (!org_freedesktop_DBus_request_name (bus_proxy, "esd.esdtest.esdmessdata", 0, &request_name_result, &error))
      lose_gerror ("Failed to acquire esd.esdtest.esdmessdata", error);

  if (request_name_result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER){
	return FALSE;
  }
  obj = g_object_new (GUI_MESS_TYPE_DATA, NULL);

  dbus_g_connection_register_g_object (bus, "/esd/esdtest/esdmessdata", G_OBJECT (obj));

  printf ("DBus service active Waiting for ESD Messdaten ... \n");

  g_main_loop_run (mainloop);

  exit (0);
}



/**the client  */ 


#include <dbus/dbus-protocol.h>
#include <dbus/dbus-glib-bindings.h>
#include <dbus/dbus-glib.h>
#include <glib.h>
#include <stdio.h>
#include <stdlib.h>

static void lose (const char *fmt, ...) G_GNUC_NORETURN G_GNUC_PRINTF (1, 2);
static void lose_gerror (const char *prefix, GError *error) G_GNUC_NORETURN;

static void
lose (const char *str, ...)
{
  va_list args;

  va_start (args, str);

  vfprintf (stderr, str, args);
  fputc ('\n', stderr);

  va_end (args);

  exit (1);
}

static void
lose_gerror (const char *prefix, GError *error) 
{
  lose ("%s: %s", prefix, error->message);
}
#include "client-guimessdata.h"
//#include "mathematics.h"

enum {KARTESIAN, POLAR};
enum {AIR, CONTACT};
enum {SERIE, PARALLEL};

/*
static void
print_hash_value (gpointer key, gpointer val, gpointer data)
{
  printf ("%s -> %s\n", (char *) key, (char *) val);
}
*/

enum vectortype { VT_XYZ, VT_POLAR };
typedef struct _vector {
	enum vectortype type;
	union {
		double V[3];    /* for using in loops */
		struct {
			double x;   /* kartesian coordinates */
			double y;
			double z;
		};
		struct {
			double r;   /* polar coordinates */
			double a1;
			double a2;
		};
	};
} vector;

enum angleformat { AF_RAD, AF_DEG };
typedef struct _angles {
	enum angleformat fmt;
	double A;        /* rotation    */
	double B;
	double C;
} angles;

struct pin
{
   unsigned int 	nr;	/*!< pin number */
   vector 		pp;     /*!< pin point */
   vector 		sp;     /*!< safe point */
};

struct plug
{
    unsigned int 	nr;      /*!< plug number */
    GString* 		name;    /*!< plug name */
    GString*		info;    /*!< free description */
    vector 		origin;  /*!< origin of plug relative to  base system */
    vector 		safe;    /*!< plug's safe point relative to base system */
    angles 		turn;    /*!< orientation of plug, angles */
    unsigned int 	slope;   /*!< add a slope to tool before approaching this plug */
    unsigned int 	count;   /*!< count of pins */
    GPtrArray*		pins;    /*!< list of pins, sorted */

};

struct testlevel {
    unsigned int nr;           	/*!< identifier of testlevel */
    gboolean dischargTyp; 	/*!< Type of discharge AIR oter CONTACT */
    gboolean isMeasure;     	/*!< if we should measure */
    gboolean isGround;      	/*!< if we should ground */
    unsigned int count;    	/*!< count of discharges with this level */
    signed int voltage;    	/*!< voltage level of test */
};

void init_pin(GPtrArray* ptr_pins);
struct plug * dbase_newPlug (void);
struct pin * dbase_newPin (void);
struct testlevel * dbase_newESDTestLevel (void);
void setTestlevel(GValueArray *testlevel, const int nb, gboolean disTyp, gboolean isMeas, gboolean isGnd, int ct, double volt);
vector* math_initVector (vector *A, double x, double y, double z);

/* -- Vector functions -- */

vector*
math_initVector (vector *A, double x, double y, double z)
{
	A->type = VT_XYZ;
	A->x = x;
	A->y = y;
	A->z = z;
	return A;
}

/* -- rotation functions -- */

angles *
math_initAngles (angles *W, double A, double B, double C)
{
	W->fmt = AF_DEG;
	W->A = A;
	W->B = B;
	W->C = C;
	return W;
}
/* structure to send through Dbus */
struct plug *
dbase_newPlug (void)
{
	struct plug *data;
	
	if ((data = (struct plug *) malloc (sizeof(struct plug)))) {
		data->nr = 0;
		data->name = g_string_new (NULL);
		data->info = g_string_new (NULL);
		math_initVector (&data->origin, 0, 0, 0);
		math_initVector (&data->safe, 0, 0, 0);
		math_initAngles (&data->turn, 0, 0, 0);
		data->slope = 0;
		data->count = 0;
		data->pins = NULL; /* (GSList) GPtrArray of struct pin */
	}
	return data;
}

struct pin *
dbase_newPin (void)
{
	struct pin *data;

	if ((data = (struct pin *) malloc (sizeof(struct pin)))) {
		data->nr  = 0.0;
		math_initVector (&data->pp, 0.0, 0.0, 0.0);
		math_initVector (&data->sp, 0.0, 0.0, 0.0);
	}
	return data;
}

/* structure to send through Dbus */
struct testlevel *
dbase_newESDTestLevel (void)
{
	struct testlevel *data;
	
	if ((data = (struct testlevel *) malloc (sizeof(struct testlevel)))) {
		data->nr            = 0;
		data->dischargTyp   = 0;
		data->isMeasure     = 0;
		data->isGround      = 0;
		data->count         = 0;
		data->voltage       = 0.0;
	}
	return data;
}	
 /* construction of the structure with GValueArray*/
void 
setTestlevel(GValueArray *testlevel, const int nb, gboolean disTyp, gboolean isMeas, gboolean isGnd, int ct, double volt)
{
   testlevel = g_value_array_new (1);
   g_value_array_prepend(testlevel, NULL);
   g_value_init (g_value_array_get_nth(testlevel, 0), G_TYPE_UINT);
   g_value_set_uint (g_value_array_get_nth (testlevel, 0), nb);

   g_value_array_prepend(testlevel, NULL);
   g_value_init (g_value_array_get_nth(testlevel, 0), G_TYPE_BOOLEAN);
   g_value_set_boolean (g_value_array_get_nth (testlevel, 0), disTyp);

   g_value_array_prepend(testlevel, NULL);
   g_value_init (g_value_array_get_nth(testlevel, 0), G_TYPE_BOOLEAN);
   g_value_set_boolean (g_value_array_get_nth (testlevel, 0), isMeas);

   g_value_array_prepend(testlevel, NULL);
   g_value_init (g_value_array_get_nth(testlevel, 0), G_TYPE_BOOLEAN);
   g_value_set_boolean (g_value_array_get_nth (testlevel, 0), isGnd);

   g_value_array_prepend(testlevel, NULL);
   g_value_init (g_value_array_get_nth(testlevel, 0), G_TYPE_UINT);
   g_value_set_uint (g_value_array_get_nth (testlevel, 0), ct);

   g_value_array_prepend(testlevel, NULL);
   g_value_init (g_value_array_get_nth(testlevel, 0), G_TYPE_DOUBLE);
   g_value_set_double (g_value_array_get_nth (testlevel, 0), volt);

}

int
main (int argc, char **argv)
{
  DBusGConnection *bus;
  DBusGProxy *remote_object;

  GError *error = NULL;
  gboolean is_esd_start = FALSE;

  //struct testlevel *test_level = dbase_newESDTestLevel();
  GValueArray *test_level;

  struct pin *ptr_pin = dbase_newPin ();
  //struct plug *ptr_plug = dbase_newPlug (); 
  /* Electrinic definition*/
  char* ecuName = "ABS-E Basic 4S/4M";
  char* info = "Serienummer 446 004 60x 0, ABS-E 12V 4S/4M SAE";
  char* base = "X2.1 -> X1.13 -> X1.15";
  char* dut_name = "DUT Name ";
  char* dut_no = "DUT Nummer";
  char* dut_desc = "DUT Description";
  /* Pins */
  GPtrArray* gpPins;
  gpPins = g_ptr_array_new();
  ptr_pin->nr = 1;
  math_initVector (&ptr_pin->pp, 0.0, 0.0, 0.0);
  math_initVector (&ptr_pin->sp, 0.0, 0.0, -50.0);
  g_ptr_array_add(gpPins, (gpointer)ptr_pin);
  ptr_pin->nr = 2;
  math_initVector (&ptr_pin->pp, 0.0, 5.5, 0.0);
  math_initVector (&ptr_pin->sp, 0.0, 5.5, -50.0);
  g_ptr_array_add(gpPins, (gpointer)ptr_pin);
  ptr_pin->nr = 3;
  math_initVector (&ptr_pin->pp, 0.0, 11.0, 0.0);
  math_initVector (&ptr_pin->sp, 0.0, 11.0, -50.0);
  g_ptr_array_add(gpPins, (gpointer)ptr_pin);

  /*  Plugs  */
/*
  GPtrArray* gpPlugs;
  gpPlugs = g_ptr_array_new();
  ptr_plug->nr = 1;
  ptr_plug->name = g_string_assign(ptr_plug->name, "14_AMP-SKN");
  ptr_plug->info = g_string_assign(ptr_plug->info, "info plug 1");
  math_initVector (&ptr_plug->origin, 0.0, 0.0, 0.0);
  math_initVector (&ptr_plug->safe, 0.0, -100.0, -150.0);
  math_initAngles (&ptr_plug->turn, 0.0, 0.0, 0.0);
  ptr_plug->slope = 1;
  ptr_plug->count = 3;
  ptr_plug->pins  = gpPins;
  g_ptr_array_add(gpPlugs, (gpointer)ptr_plug);

  ptr_plug->nr = 2;
  ptr_plug->name = g_string_assign(ptr_plug->name, "18_AMP-SKN");
  ptr_plug->info = g_string_assign(ptr_plug->info, "info plug 2");
  math_initVector (&ptr_plug->origin, 40.0, 0.0, 0.0);
  math_initVector (&ptr_plug->safe, 40.0, -100.0, -150.0);
  math_initAngles (&ptr_plug->turn, 25.0, 0.0, -80.0);
  ptr_plug->slope = 1;
  ptr_plug->count = 3;
  ptr_plug->pins  = gpPins;
  g_ptr_array_add(gpPlugs, (gpointer)ptr_plug);
*/  
  /* Test definition*/
  char* standard = "ISO 10605";
  double hbmC  = 150;
  double hbmR  = 2000;
  double interval_cont = 5.0;
  double interval_air  = 0.1;
  double freq          = 150.5;
  double ac_Offset     = 50.7;
  double dc_Offset     = 43.9;
  double velocity_air  = 63.0;
  gboolean equivCircuit = SERIE;

  /*  Test Level */
  /* construction of the GPtrArray to send */

  GPtrArray* gpTestLevels;
  gpTestLevels = g_ptr_array_new();
  
  setTestlevel(test_level, 1, CONTACT, 1, 0, 0, 2.0);
  g_ptr_array_add(gpTestLevels, (gpointer)test_level);
  setTestlevel(test_level, 2, CONTACT, 0, 1, 3, 2.0);
  g_ptr_array_add(gpTestLevels, (gpointer)test_level);
  setTestlevel(test_level, 3, CONTACT, 1, 1, 3, -2);
  g_ptr_array_add(gpTestLevels, (gpointer)test_level);
  setTestlevel(test_level, 4, AIR, 0, 1, 3, 8);
  g_ptr_array_add(gpTestLevels, (gpointer)test_level);
  setTestlevel(test_level, 5, AIR, 1, 1, 3, -8);
  g_ptr_array_add(gpTestLevels, (gpointer)test_level);


  g_type_init ();

  {
    GLogLevelFlags fatal_mask;
    
    fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
    fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
    g_log_set_always_fatal (fatal_mask);
  }

  bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
  if (!bus)
    lose_gerror ("Couldn't connect to session bus", error);
  
  remote_object = dbus_g_proxy_new_for_name (bus,
					     "esd.esdtest.esdmessdata",
					     "/esd/esdtest/esdmessdata",
					     "esd.esdtest.esdmessdata");
/*
variable from bus-bingings-tool client
const char * IN_ecuname, const char * IN_info, const char * IN_base, const char * IN_DUTname, const char * IN_DUTno, const char * IN_DUTdescr, const char * IN_Standard, const gdouble IN_HBM_C, const gdouble IN_HBM_R, const gdouble IN_IntervalContact, const gdouble IN_IntervalAir, const gdouble IN_VelocityAir, const gdouble IN_Frequency, const gdouble IN_AC_Offset, const gdouble IN_DC_Offset, const gboolean IN_EquivCircuit, const GPtrArray* IN_TestLevel, gboolean* OUT_isEsdStart, GError **error
*/

/* the call */
  if (!esd_esdtest_esdmessdata_start_esd_test (remote_object, ecuName, info, base, dut_name, dut_no, dut_desc, standard, hbmC, hbmR, interval_cont, interval_air, velocity_air, freq, ac_Offset, dc_Offset, equivCircuit, gpTestLevels, &is_esd_start, &error))
    lose_gerror ("Failed to complete start_esd_test ", error);

  if (is_esd_start)
  	printf ("The ESD Test has started \n");

  g_value_array_free(test_level);
  g_ptr_array_free (gpTestLevels, TRUE);
  g_object_unref (G_OBJECT (remote_object));

  exit(0);
}


/* here is the xml file */

<?xml version="1.0" encoding="UTF-8" ?>
<node name="/esd/esdtest/esdmessdata">
   <interface name="esd.esdtest.esdmessdata">
      <!--Remote Methods of the Pruefprogramms from the GUI Application-->
      <method name="StartEsdTest">  
          <!--Input ECUGeometryData-->      	  
	  <arg type="s" name="ecuname" direction="in"/>
          <arg type="s" name="info" direction="in"/>
	  <arg type="s" name="base" direction="in"/>
	  <arg type="s" name="DUTname" direction="in"/>
	  <arg type="s" name="DUTno" direction="in"/>
	  <arg type="s" name="DUTdescr" direction="in"/>
	  <!-- ecugeometry -->
	  <!--arg type="a(uss(bad(ddd)(ddd))(bad(ddd)(ddd))(bddd)uua(u(bad(ddd)(ddd))(bad(ddd)(ddd))))" direction="in"/ -->
 	  <!--Input TestDefinitionData-->   
	  <arg type="s" name="Standard" direction="in"/>
	  <arg type="d" name="HBM_C" direction="in"/>
	  <arg type="d" name="HBM_R" direction="in"/>
	  <arg type="d" name="IntervalContact" direction="in"/>
	  <arg type="d" name="IntervalAir" direction="in"/>
	  <arg type="d" name="VelocityAir" direction="in"/>
	  <arg type="d" name="Frequency" direction="in"/>
	  <arg type="d" name="AC_Offset" direction="in"/>
	  <arg type="d" name="DC_Offset" direction="in"/>
	  <arg type="b" name="EquivCircuit" direction="in"/>
	  <arg type="a(ubbbui)" name="TestLevel" direction="in"/>
          <!-- arg type="a(iiiiii)" name="TestLevel" direction="in"/  -->
	  <!--Output EsdTestStart-->
	  <arg type="b" name="isEsdStart" direction="out"/>
      </method>     
   </interface>
</node>



Thanks to answer me, I already spent lot of time with this problem
-- 
GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.
Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail


More information about the dbus mailing list