|
|
пре 2 година | |
|---|---|---|
| .swiftpm | пре 2 година | |
| Examples | пре 6 година | |
| Sources | пре 2 година | |
| .editorconfig | пре 2 година | |
| .gitignore | пре 2 година | |
| LICENSE | пре 9 година | |
| Package.resolved | пре 2 година | |
| Package.swift | пре 2 година | |
| README.md | пре 2 година | |
| README.original.md | пре 2 година | |
| first-slide.png | пре 9 година | |
| swift-serial-talk-slides.pptx | пре 9 година |
This project began its life as yeokm1's SwiftSerial. He has since archived the project and was kind enough to link this project going forward.
import SwiftSerial
...
// setup
let serialPort = SerialPort(path: "/dev/cu.usbmodem1234") // you'll need to find the correct device on your own, but this is what it will resemble on a mac
try serialPort.openPort()
serialPort.setSettings(
receiveRate: 115200,
transmitRate: 115200,
minimumBytesToRead: 1)
// read output
Task {
let readStream = try serialPort.asyncLines()
for await line in readStream {
print(line, terminator: "")
}
}
// send data
try serialPort.writeString("foo")
// or
try serialPort.writeData(Data([1,2,3,4]))
.package(url: "https://github.com/mredig/SwiftSerial", .upToNextMinor("1.0.0")
SwiftTerminal demo to connect and interface with a serial connection