read byte feature add
This commit is contained in:
@@ -460,8 +460,23 @@ extension SerialPort {
|
|||||||
let character = UnicodeScalar(buffer[0])
|
let character = UnicodeScalar(buffer[0])
|
||||||
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]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user