diff options
-rw-r--r-- | main.vala | 13 | ||||
-rw-r--r-- | serial.vala | 2 |
2 files changed, 14 insertions, 1 deletions
@@ -14,6 +14,14 @@ public static int main(string[] args) { while(true) { uint8 buf[64]; + uint8 buf2[64] = {0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; + int size = (int) Posix.read(s.fd, buf, 64); for(int i = 0; i < size; i++) @@ -22,6 +30,11 @@ public static int main(string[] args) { } else { if(detected.length > 0) { detected += '\0'; + + /* use led as feedback */ + Posix.write(s.fd, buf2, 64); + Posix.tcflush(s.fd, Posix.TCOFLUSH); + interpret((string) detected); } detected = {}; diff --git a/serial.vala b/serial.vala index f6901f0..acdcf41 100644 --- a/serial.vala +++ b/serial.vala @@ -8,7 +8,7 @@ public class Serial { public Serial(string device, int rate, int bits, int stopbits) { Posix.speed_t baudrate = Posix.B9600; - fd = Posix.open(device, Posix.O_RDONLY /*| Posix.O_NONBLOCK*/); + fd = Posix.open(device, Posix.O_RDWR /*| Posix.O_NONBLOCK*/); if(fd < 0) { fd = -1; |