From 66d6b9ce2a2ec3ede7f765b20c35c2d0c1e960c6 Mon Sep 17 00:00:00 2001 From: Lennart Weller Date: Tue, 5 Jun 2012 22:26:02 +0200 Subject: working eventbased setup --- device.vala | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/device.vala b/device.vala index 32af831..01b8663 100644 --- a/device.vala +++ b/device.vala @@ -116,7 +116,7 @@ public class Device { try { io_read = new IOChannel.unix_new(fd); io_read.set_line_term("\r\n", 2); - if(io_read.set_encoding("") != IOStatus.NORMAL) + if(io_read.set_encoding(null) != IOStatus.NORMAL) error("Failed to set encoding"); if(!(io_read.add_watch(IOCondition.IN | IOCondition.HUP, device_read) != 0)) { error("Could not bind IOChannel"); @@ -134,12 +134,7 @@ public class Device { stdout.printf("HUP. Do something"); try { - stdout.printf("trying to read message\n"); - if((ret = gio.read_line(out msg, out len, out term_char)) != IOStatus.NORMAL) { - received_barcode("SCANNER RETURNED INCORRET DATA"); - return false; - } - stdout.printf("read message\n"); + ret = gio.read_line(out msg, out len, out term_char); msg = msg[0:(long)term_char]; if(msg.has_prefix("USER ") || msg.has_prefix("AMOUNT ")) { @@ -150,7 +145,8 @@ public class Device { received_barcode(msg); } } - + else + received_barcode(msg); } catch(IOChannelError e) { stderr.printf("IOChannel Error: %s", e.message); -- cgit v1.2.3