Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a167032f3 | ||
|
|
27a5d92aa0 | ||
|
|
2cb65bc2ff | ||
|
|
34e59a7d87 | ||
|
|
496a62549f | ||
|
|
9799f402e7 |
5
.gitlab-ci.yml
Normal file
5
.gitlab-ci.yml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
build:
|
||||||
|
stage: build
|
||||||
|
image: vato.ddns.net:8083/swift:5.2.4
|
||||||
|
script:
|
||||||
|
- swift build
|
||||||
@@ -165,6 +165,11 @@ public enum BaudRate {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if os(OSX)
|
||||||
|
// Darwin doesn't provide this
|
||||||
|
private let FIONREAD: UInt = 0x541B
|
||||||
|
#endif
|
||||||
|
|
||||||
public enum DataBitsSize {
|
public enum DataBitsSize {
|
||||||
case bits5
|
case bits5
|
||||||
case bits6
|
case bits6
|
||||||
@@ -217,6 +222,7 @@ public class SerialPort {
|
|||||||
|
|
||||||
var path: String
|
var path: String
|
||||||
var fileDescriptor: Int32?
|
var fileDescriptor: Int32?
|
||||||
|
private var dtrState = false
|
||||||
|
|
||||||
public init(path: String) {
|
public init(path: String) {
|
||||||
self.path = path
|
self.path = path
|
||||||
@@ -365,6 +371,29 @@ public class SerialPort {
|
|||||||
}
|
}
|
||||||
fileDescriptor = nil
|
fileDescriptor = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public var dtr: Bool {
|
||||||
|
get{
|
||||||
|
return dtrState
|
||||||
|
}
|
||||||
|
set (value){
|
||||||
|
guard let fileDescriptor = fileDescriptor else {
|
||||||
|
// Need to open port first.
|
||||||
|
return
|
||||||
|
}
|
||||||
|
dtrState = value
|
||||||
|
var flags = TIOCM_DTR
|
||||||
|
if(ioctl(fileDescriptor, UInt(dtrState ? TIOCMBIS : TIOCMBIC), &flags) != 0){
|
||||||
|
print("Failed to apply dtr")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public var inWaiting: Int {
|
||||||
|
get{
|
||||||
|
return Int(ioctl(fileDescriptor!, UInt(FIONREAD)))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Receiving
|
// MARK: Receiving
|
||||||
|
|||||||
Reference in New Issue
Block a user