         return Array(buf[0..<n])
     }
 
-    public func writeString(_ value: String) {
+    public func readByte() -> UInt8? {
+        var buf = [UInt8](repeating:0, count:1)
+
+        let n = read(fd, &buf, 1)
+        if n<0 {
+            perror("Error while reading from UART")
+            abort()
+        }
+        if n == 0 {
+            return nil
+        }
+        return buf[0]
+    }
+
+    public func write(string value: String) {
         let chars = Array(value.utf8CString)
 
-        writeData(chars)
-    }
-
-    public func writeData(_ value: [CChar]) {
+        write(chars:chars)
+    }
+
+    public func write(chars value: [CChar]) {
         var value = value
 
-        _ = write(fd, &value, value.count)
+        _ = Glibc.write(fd, &value, value.count)
         tcdrain(fd)
+    }
+    
+    public func write(data value:Data) {
+        value.withUnsafeBytes {(bytes: UnsafePointer<CChar>)->Void in
+            _ = Glibc.write(fd, bytes, value.count)
+            tcdrain(fd)
+        }
     }
 
     private func applyConfiguration() {

    func configureInterface(speed: UARTSpeed, bitsPerChar: CharSize, stopBits: StopBits, parity: ParityType)
    func readString() -> String?
    func readLine() -> String?
    func readData() -> [CChar]?
    func writeString(_ value: String)
    func writeData(_ values: [CChar])
}

public enum ParityType {

#else
    import Darwin.C
#endif

import Foundation

extension SwiftyGPIO {

