[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: Monitoring IO
- From: David Helder <dhelder umich edu>
- To: Chris Blazie <chris blazie com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Monitoring IO
- Date: Wed, 6 Dec 2000 15:00:35 -0500 (EST)
Or call fileno(file) to get the fd of the file.
David
On Wed, 6 Dec 2000, Erik Mouw wrote:
> Hi Chris,
>
> I didn't expect you on this list... ;-)
>
> On Wed, Dec 06, 2000 at 12:44:41PM -0500, Chris Blazie wrote:
> > 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?
>
> gtk_input_add_full() needs a file descriptor, not a FILE pointer. Open
> the serial port with:
>
> int s_port;
>
> s_port = open("/dev/ttyS0", O_RDONLY);
>
> Hope this helps,
>
>
> Erik
>
>
--
__ _ __ David Helder - University of Michigan
___/ /__ __ __(_)__/ / dhelder@umich.edu
/ _ / _ `/ |/ / / _ / http://www.eecs.umich.edu/~dhelder
|_,_/|_,_/|___/_/|_,_/ Jungle Monkey: http://www.junglemonkey.net
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]