Re: Monitoring IO



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

-- 
J.A.K. (Erik) Mouw, Information and Communication Theory Group, Department
of Electrical Engineering, Faculty of Information Technology and Systems,
Delft University of Technology, PO BOX 5031,  2600 GA Delft, The Netherlands
Phone: +31-15-2783635  Fax: +31-15-2781843  Email: J A K Mouw its tudelft nl
WWW: http://www-ict.its.tudelft.nl/~erik/




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