Re: Glib: Adding watch in the glib event poll
- From: Jacques Pelletier <jpelletier ieee org>
- To: gtk-app-devel-list gnome org
- Subject: Re: Glib: Adding watch in the glib event poll
- Date: Sun, 27 Jan 2008 20:19:06 -0500
On January 25, 2008 01:45:40 pm Jacques Pelletier wrote:
Hi,
I want to do a customized input routine for specialized hardware plugged
into a parallel port. I don't have any device driver yet for this hardware.
I have to poll bits; in my case, if the BUSY bit = 0, there's a character
available on the data lines.
I made my own version of add watch routines by copying the giounix.c code
in glib and modifiying to my needs.
Here are my questions:
In giounix.c there is this:
GSourceFuncs g_io_watch_funcs = {
g_io_unix_prepare,
g_io_unix_check,
g_io_unix_dispatch,
g_io_unix_finalize
};
Do I need to modify the g_io_unix_check routine for my needs also?
static gboolean
g_io_unix_check (GSource *source)
{
GIOUnixWatch *watch = (GIOUnixWatch *)source;
GIOCondition buffer_condition = g_io_channel_get_buffer_condition
(watch->channel);
GIOCondition poll_condition = watch->pollfd.revents;
return ((poll_condition | buffer_condition) & watch->condition);
}
If I use it as is, it doesn't call my read_function.
What is it supposed to check? While it's self documented, I don't get the
higher picture.
For the record, I managed to make it work by making a copy of g_io_unix_check
and modifying for my needs. However, I don't know if it's "clean" code.
Here it is:
gboolean pt_8255_check (GSource *source)
{
/* returns true if the /OBF line is asserted (==0) */
return ((par_read_status(parallel_fd) & PAR_8255_RECV_MASK) == 0);
}
--
JP
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]