summaryrefslogtreecommitdiff
path: root/aoview/aoview_serial.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2009-05-17 22:29:06 -0700
committerKeith Packard <keithp@keithp.com>2009-05-17 22:29:06 -0700
commit2c780d67b8a22d75a2da4b2af21fd35f0c6f5236 (patch)
treed41ddf8f23cf21c19b1d9d792e27a13f4c358424 /aoview/aoview_serial.c
parent69616104813fc5ba89fb3128d04fb9328961c59c (diff)
Handle disappearing serial devices
Put up a dialog when the serial open fails, and shut down monitoring when the serial device disappears while running. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'aoview/aoview_serial.c')
-rw-r--r--aoview/aoview_serial.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/aoview/aoview_serial.c b/aoview/aoview_serial.c
index 5cb286f8..1721a286 100644
--- a/aoview/aoview_serial.c
+++ b/aoview/aoview_serial.c
@@ -191,6 +191,7 @@ serial_dispatch(GSource *source,
gpointer user_data)
{
struct aoview_serial *serial = (struct aoview_serial *) source;
+ aoview_serial_callback func = (aoview_serial_callback) callback;
gint revents = serial->poll_fd.revents;
if (revents & G_IO_IN)
@@ -199,8 +200,8 @@ serial_dispatch(GSource *source,
if (revents & G_IO_OUT)
aoview_buf_flush(&serial->out_buf, serial->fd);
- if (callback && (revents & G_IO_IN))
- (*callback)(user_data);
+ if (func)
+ (*func)(user_data, serial, revents);
return TRUE;
}
@@ -262,9 +263,9 @@ aoview_serial_close(struct aoview_serial *serial)
void
aoview_serial_set_callback(struct aoview_serial *serial,
- GSourceFunc func,
+ aoview_serial_callback func,
gpointer data,
GDestroyNotify notify)
{
- g_source_set_callback(&serial->source, func, data, notify);
+ g_source_set_callback(&serial->source, (GSourceFunc) func, data, notify);
}