Serial Communication Library for macOS written in Swift.
MIT License
Serial Communication Library for macOS written in Swift.
com.apple.security.device.serial
Serial Communication Demo App for Arduino or mbed is in this Project.
Sample Arduino code is here.
import Combine
import SerialGate
var cancellables = Set<AnyCancellable>()
SGPortManager.shared.availablePortsPublisher
.sink { ports in
// get ports
}
.store(in: &cancellables)
try? port.setBaudRate(B9600)
try? port.open()
try? port.close()
let text: String = "Hello World"
try? port.send(text)
port.receivedTextPublisher
.sink { (error, text) in
if let text {
Swift.print(text)
}
}
.store(in: &cancellables)
port.changedPortStatePublisher
.sink { portState in
Swift.print(portState.rawValue)
}
.store(in: &cancellables)