From 22f7cca9be9ef5b4d2973770edab5ebc30408093 Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Thu, 17 May 2012 15:04:24 +0200 Subject: fix Device.receive() --- device.vala | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'device.vala') diff --git a/device.vala b/device.vala index ee0967b..454e79b 100644 --- a/device.vala +++ b/device.vala @@ -125,23 +125,23 @@ public class Device { char[] detected = {}; char buf[64]; - int size = (int) this.read(buf, 64); - - if(size <= 0) - error("serial device lost.\n"); - - for(int i = 0; i < size; i++) { - if(buf[i] != '\r' && buf[i] != '\n') { - detected += (char) buf[i]; - } else { - if(detected.length > 0) { - detected += '\0'; - return (string) detected; + while(true) { + int size = (int) this.read(buf, 64); + + if(size <= 0) + error("serial device lost.\n"); + + for(int i = 0; i < size; i++) { + if(buf[i] != '\r' && buf[i] != '\n') { + detected += (char) buf[i]; + } else { + if(detected.length > 0) { + detected += '\0'; + return (string) detected; + } } } } - - return ""; } /** -- cgit v1.2.3