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

Re: Monitoring IO



On Wed, Dec 06, 2000 at 12:44:41PM -0500, Chris Blazie wrote:
> Hello,
> 
> 	I'm working on some applications that need to monitor and interact
> with arbitrary external IO (for now, the serial port).  For starters
> (since I'm new to GTK development), I wrote a tiny app that instantiates a
> GtkText widget, registers a GIO Channel via the gtk_input_add_full()
> wrapper, and writes to the GtkText box from the input callback:
> 
> s_port = fopen( "/dev/ttyS0", "r" );
> 
> off = gtk_input_add_full( (gint) s_port, GDK_INPUT_READ,
> 				(GdkInputFunction) input_callback,
> 				NULL, data, NULL );
> 
> 
> The input_callback function looks like this:
> 
> void input_callback( gpointer          data, gint              source, 
>                      GdkInputCondition condition )
> {
> 	gtk_text_insert( GTK_TEXT(textedit), NULL, NULL, NULL, "data
> added\n", -1 );
> 
> }
> 
> 	For some reason the input_callback function never gets called.
> I suspect I'm not using the FILE pointer correctly, but I don't know how.
> Can someone tell me what I'm missing here?
> 
  you should use 
  off = gtk_input_add_full(fileno (s_port),
                           GDK_INPUT_READ,
                           (GdkInputFunction) input_callback,
                            NULL, data, NULL );
  have a look at man fileno

    I hope this helps,

              DindinX
  
-- 
 David.Odin@bigfoot.com




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