Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
640cf2f7c3 | ||
|
|
21adc2c8f4 |
@@ -25,6 +25,7 @@ do {
|
|||||||
print("Serial port \(portName) opened successfully.")
|
print("Serial port \(portName) opened successfully.")
|
||||||
defer {
|
defer {
|
||||||
serialPort.closePort()
|
serialPort.closePort()
|
||||||
|
print("Port Closed")
|
||||||
}
|
}
|
||||||
|
|
||||||
serialPort.setSettings(receiveRate: .baud9600,
|
serialPort.setSettings(receiveRate: .baud9600,
|
||||||
@@ -74,8 +75,8 @@ do {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print("End of example");
|
||||||
|
|
||||||
print("We successfully received back \(numberOfMultiNewLineTest) lines")
|
|
||||||
|
|
||||||
} catch PortError.failedToOpen {
|
} catch PortError.failedToOpen {
|
||||||
print("Serial port \(portName) failed to open. You might need root permissions.")
|
print("Serial port \(portName) failed to open. You might need root permissions.")
|
||||||
|
|||||||
@@ -66,9 +66,13 @@ To get started quickly, you can take a look at my example project [here](Example
|
|||||||
git clone https://github.com/yeokm1/SwiftSerial.git
|
git clone https://github.com/yeokm1/SwiftSerial.git
|
||||||
cd SwiftSerial/Examples/SwiftSerialExample/
|
cd SwiftSerial/Examples/SwiftSerialExample/
|
||||||
swift build
|
swift build
|
||||||
#You need root to access the serial port. Replace /dev/ttyUSB0 with the name of your serial port under test
|
|
||||||
|
#For Linux: You need root to access the serial port. Replace /dev/ttyUSB0 with the name of your serial port under test
|
||||||
sudo ./.build/debug/SwiftSerialExample /dev/ttyUSB0
|
sudo ./.build/debug/SwiftSerialExample /dev/ttyUSB0
|
||||||
|
|
||||||
|
#For Mac: Root is not required
|
||||||
|
./.build/debug/SwiftSerialExample /dev/tty.usbserial
|
||||||
|
|
||||||
#If all goes well you should see a series of messages informing you that data transmitted has been received properly.
|
#If all goes well you should see a series of messages informing you that data transmitted has been received properly.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user