     public func readData(ofLength length: Int) throws -> Data {
         let buffer = UnsafeMutablePointer<UInt8>.allocate(capacity: length)
         defer {
-            buffer.deallocate(capacity: length)
+            buffer.deallocate()
         }
 
         let bytesRead = try readBytes(into: buffer, size: length)

        let character = UnicodeScalar(byteRead)
        return character
    }
   
}

// MARK: Transmitting

        guard let fileDescriptor = fileDescriptor else {
            throw PortError.mustBeOpen
        }

        var s: stat = stat()
        fstat(fileDescriptor, &s)
        if s.st_nlink != 1 {
            throw PortError.deviceNotConnected
        }

        let bytesRead = read(fileDescriptor, buffer, size)
        return bytesRead
    }
