diff --git a/Sources/SwiftSerial.swift b/Sources/SwiftSerial.swift index 94e56e7..c504fb0 100644 --- a/Sources/SwiftSerial.swift +++ b/Sources/SwiftSerial.swift @@ -165,6 +165,11 @@ public enum BaudRate { } #endif +#if os(OSX) +// Darwin doesn't provide this +private let FIONREAD: UInt = 0x541B +#endif + public enum DataBitsSize { case bits5 case bits6 @@ -384,6 +389,12 @@ public class SerialPort { } } } + + public var inWaiting: Int? { + get{ + return Int(ioctl(fileDescriptor!, FIONREAD)) + } + } } // MARK: Receiving