GIOChannel assistance (GTK 1.2.10)



I am using a GTK GUI to monitor the parameters in a real time application and I need to synchronize the 
results in the RT package with the display on the GUI. To do this I am attempting to use a GIOChannel, the RT 
software will write to a file descriptor (temporary file) at the end of its processing frame and then the 
GIOChannel should execute the function it has been assigned so as to record the output for that frame. The 
problem I am having is that the gtk main loop is executing the GIOFunc continuosly. Here is the code I am 
using, it is very basic as I am just learning the process. Any comments/help will be greatly appreciated.
{
   int TIMING_FD;
   TIMING_FD = open("TEMPORARY_TIMING", O_RDWR | O_CREAT | O_TRUNC | O_NONBLOCK,
                                        S_IRWXU);
  if(TIMING_FD != -1)
  {
     timing_chan = g_io_channel_unix_new(TIMING_FD);
     g_io_add_watch(timing_chan, G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_PRI,
                    TIMING_FUNCTION, (gpointer)FRAME);
  }
   gtk_main();
   g_io_channel_close(timing_chan);
   close(TIMING_FD);
}

gboolean
TIMING_FUNCTION(GIOChannel *timing_chan, GIOCondition CONDITION,
                gpointer FRAME)
{
   static int frame;
   static char buf[32];
   frame = (int)FRAME;
   read(GBB_TIMING, buf, 32);
   printf("%d, %d\n", frame, CONDITION);
   return(TRUE);
}
--
Marco Quezada 
Aerospaceo Engineero 
NLX - RockwellCollins 
22626 Sally Ride Dr. 
Sterling, V.A., 20164 
703-234-2100 ext. 1028


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]