read byte feature add

This commit is contained in:
AleyRobotics Aleynikov Yuri
2017-06-24 11:21:58 +03:00
parent d36d0132a8
commit 543e7d39e0

View File

@@ -461,7 +461,22 @@ extension SerialPort {
return character return character
} }
} }
}
public func readByte() throws -> UInt8 {
let buffer = UnsafeMutablePointer<UInt8>.allocate(capacity: 1)
defer {
buffer.deallocate(capacity: 1)
}
while true {
let bytesRead = try readBytes(into: buffer, size: 1)
if bytesRead > 0 {
return buffer[0]
}
}
} }
} }