     }
 
     public func readString() -> String? {
-        var buf = readData()
+        var buf = readChars()
         if buf == nil {
             return nil
         }

    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 {

        return Array(buf[0..<n])
    }

    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)

        write(chars:chars)
    }

    public func write(chars value: [CChar]) {
        var value = value

        _ = 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() {
