diff options
author | Lennart Weller <lhw@ring0.de> | 2012-06-05 22:26:02 +0200 |
---|---|---|
committer | Lennart Weller <lhw@ring0.de> | 2012-06-06 09:59:39 +0200 |
commit | 90bb7b126311144960e5c7b23d1607b5d2b8f6b4 (patch) | |
tree | dcb0e5aa4237c590ccc0c64250c73834d0a4bc58 /device.vala | |
parent | 27b1dce0c3b9e604409a614339e2bc3e1eef467d (diff) | |
download | serial-barcode-scanner-90bb7b126311144960e5c7b23d1607b5d2b8f6b4.tar.bz2 |
working eventbased setup
Diffstat (limited to 'device.vala')
-rw-r--r-- | device.vala | 12 |
1 files 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); |