open port params separate for mac
This commit is contained in:
@@ -233,16 +233,24 @@ public class SerialPort {
|
||||
throw PortError.mustReceiveOrTransmit
|
||||
}
|
||||
|
||||
var readWriteParam : Int32
|
||||
|
||||
if receive && transmit {
|
||||
fileDescriptor = open(path, O_RDWR | O_NOCTTY)
|
||||
readWriteParam = O_RDWR
|
||||
} else if receive {
|
||||
fileDescriptor = open(path, O_RDONLY | O_NOCTTY)
|
||||
readWriteParam = O_RDONLY
|
||||
} else if transmit {
|
||||
fileDescriptor = open(path, O_WRONLY | O_NOCTTY)
|
||||
readWriteParam = O_WRONLY
|
||||
} else {
|
||||
fatalError()
|
||||
}
|
||||
|
||||
#if os(Linux)
|
||||
fileDescriptor = open(path, readWriteParam | O_NOCTTY)
|
||||
#elseif os(OSX)
|
||||
fileDescriptor = open(path, readWriteParam | O_NOCTTY | O_EXLOCK | O_NONBLOCK)
|
||||
#endif
|
||||
|
||||
// Throw error if open() failed
|
||||
if fileDescriptor == PortError.failedToOpen.rawValue {
|
||||
throw PortError.failedToOpen
|
||||
@@ -259,10 +267,13 @@ public class SerialPort {
|
||||
useHardwareFlowControl: Bool = false,
|
||||
useSoftwareFlowControl: Bool = false,
|
||||
processOutput: Bool = false) {
|
||||
print("top")
|
||||
|
||||
guard let fileDescriptor = fileDescriptor else {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
// Set up the control structure
|
||||
var settings = termios()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user