1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
void *alert (gpointer *data)
{
int i;
int val;
while(1)
{
//----------------------PASSE EN COURS--------------------------/
TrameRead(buffer2,1,03, //buffer ,esclave, fonction
0xE192, //adresse
0x0002, //Nombre ADD
0xffff //CRC 16
);
LectureCOM( retour2, 9);
//--------------------------------------------------------------/
val=retour2[6];
gchar * strr =g_strdup_printf("PASSE EN COURS: %d \n",val);
gtk_text_buffer_set_text(GTK_TEXT_BUFFER(data),strr,-1);
for(i=1;i<100000000;i++){}
}
}
gboolean th_fonc(gpointer data)
{
gdk_threads_enter();
g_thread_create(alert,data,FALSE,NULL);
gdk_threads_leave();
}
int main(int argc, char **argv)
{
GtkWidget *pWindow;
GtkWidget *pVBox,*pVBox2;
g_thread_init (NULL);
gdk_threads_init ();
gdk_threads_enter ();
gtk_init(&argc, &argv);
/* .
.
.
*/
g_idle_add(th_fonc,p_buff);
while (gtk_events_pending ()) { gtk_main_iteration (); }
gtk_main();
gdk_threads_leave ();
return EXIT_SUCCESS;
} |
Partager