6 Commits
0.1.0 ... 0.1.1

Author SHA1 Message Date
Yeo Kheng Meng
86625ee414 Merge pull request #14 from nallick/swift-tools-version-5
Update SPM to swift-tools-version:5.0
2019-10-01 09:47:49 +08:00
Nick Nallick
29bbe8505f Update examples to Swift 5 2019-09-30 14:06:53 -06:00
Nick Nallick
005183c282 Update SPM to swift-tools-version:5.0 2019-09-30 13:50:13 -06:00
Yeo Kheng Meng
ddc06f53ef Merge pull request #12 from EmreSURK/master
XCode sandbox mode explained.
2019-05-02 22:16:54 +08:00
Emre ŞURK
1027251723 Merge pull request #1 from EmreSURK/EmreSURK-patch-1
Added XCode Sanbox advise.
2019-05-02 11:35:24 +03:00
Emre ŞURK
6db41b985c Added XCode Sanbox advise. 2019-05-02 11:35:08 +03:00
6 changed files with 54 additions and 11 deletions

View File

@@ -1,8 +1,20 @@
// swift-tools-version:5.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription import PackageDescription
let package = Package( let package = Package(
name: "SwiftSerialExample", name: "SwiftSerialExample",
dependencies: [ dependencies: [
.Package(url: "https://github.com/yeokm1/SwiftSerial.git", majorVersion: 0) .package(url: "https://github.com/yeokm1/SwiftSerial.git", from: "0.1.1")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "SwiftSerialExample",
dependencies: ["SwiftSerial"],
path: "Sources"
),
] ]
) )

View File

@@ -32,9 +32,9 @@ do {
transmitRate: .baud9600, transmitRate: .baud9600,
minimumBytesToRead: 1) minimumBytesToRead: 1)
print("Writing test string <\(testString)> of \(testString.characters.count) characters to serial port") print("Writing test string <\(testString)> of \(testString.count) characters to serial port")
var bytesWritten = try serialPort.writeString(testString) let bytesWritten = try serialPort.writeString(testString)
print("Successfully wrote \(bytesWritten) bytes") print("Successfully wrote \(bytesWritten) bytes")
print("Waiting to receive what was written...") print("Waiting to receive what was written...")
@@ -54,7 +54,7 @@ do {
var multiLineString: String = "" var multiLineString: String = ""
for i in 1...numberOfMultiNewLineTest { for _ in 1...numberOfMultiNewLineTest {
multiLineString += testString + "\n" multiLineString += testString + "\n"
} }

View File

@@ -1,8 +1,20 @@
// swift-tools-version:5.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription import PackageDescription
let package = Package( let package = Package(
name: "SwiftSerialIM", name: "SwiftSerialIM",
dependencies: [ dependencies: [
.Package(url: "https://github.com/yeokm1/SwiftSerial.git", majorVersion: 0) .package(url: "https://github.com/yeokm1/SwiftSerial.git", from: "0.1.1")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "SwiftSerialIM",
dependencies: ["SwiftSerial"],
path: "Sources"
),
] ]
) )

View File

@@ -113,7 +113,7 @@ do {
while true { while true {
var enteredKey = getKeyPress() let enteredKey = getKeyPress()
printToScreenFrom(myself: true, characterToPrint: enteredKey) printToScreenFrom(myself: true, characterToPrint: enteredKey)
var _ = try serialPort.writeChar(enteredKey) var _ = try serialPort.writeChar(enteredKey)
} }

View File

@@ -1,5 +1,19 @@
// swift-tools-version:5.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription import PackageDescription
let package = Package( let package = Package(
name: "SwiftSerial" name: "SwiftSerial",
products: [
.library(name: "SwiftSerial", targets: ["SwiftSerial"]),
],
dependencies: [],
targets: [
.target(
name: "SwiftSerial",
dependencies: [],
path: "Sources"
),
]
) )

View File

@@ -1,5 +1,5 @@
# SwiftSerial # SwiftSerial
A Swift Linux and Mac library for reading and writing to serial ports. This library has been tested to work on macOS Sierra, Linux Mint 18 (based on Ubuntu 16.04) and on the [Raspberry Pi 3 on Ubuntu 16.04](https://wiki.ubuntu.com/ARM/RaspberryPi). Other platforms using Ubuntu like the Beaglebone might work as well. A Swift Linux and Mac library for reading and writing to serial ports. This library has been tested to work on macOS Mojove, Linux Mint 18 (based on Ubuntu 16.04) and on the [Raspberry Pi 3 on Ubuntu 16.04](https://wiki.ubuntu.com/ARM/RaspberryPi) and Raspberry Pi 4 on Raspian Buster. Other platforms using Ubuntu like the Beaglebone might work as well.
This library is an improvement over my previous now deprecated library [SwiftLinuxSerial](https://github.com/yeokm1/SwiftLinuxSerial) which was less Swifty and supported only Linux. This library is thanks largely to [Jay Jun](https://github.com/jayjun). His original pull request can be found [here](https://github.com/yeokm1/SwiftLinuxSerial/pull/1). This library is an improvement over my previous now deprecated library [SwiftLinuxSerial](https://github.com/yeokm1/SwiftLinuxSerial) which was less Swifty and supported only Linux. This library is thanks largely to [Jay Jun](https://github.com/jayjun). His original pull request can be found [here](https://github.com/yeokm1/SwiftLinuxSerial/pull/1).
@@ -21,6 +21,11 @@ I gave a talk on this library and one of its examples SwiftSerialIM. Click on th
You should have Xcode 8 installed with the command line tools. You should have Xcode 8 installed with the command line tools.
To develop app with XCode, enable the App Sandbox capability in Xcode, and under Hardware, select USB. (Mac Apps are sandboxed and you need the USB entitlement.)
<img src="https://user-images.githubusercontent.com/5688874/55690960-6ff8fb00-5998-11e9-9df6-7e3ebe50e19a.png" alt="Swift 3.0">
## Linux System Preparation ## Linux System Preparation
Before using this library, I assume you already have Ubuntu installed and fully updated on your system or single-board computer. To get Ubuntu installed on the Raspberry Pi, use this [link](https://wiki.ubuntu.com/ARM/RaspberryPi). Before using this library, I assume you already have Ubuntu installed and fully updated on your system or single-board computer. To get Ubuntu installed on the Raspberry Pi, use this [link](https://wiki.ubuntu.com/ARM/RaspberryPi).
@@ -112,7 +117,7 @@ Add SwiftSerial as a dependency to your project by editing the `Package.swift` f
let package = Package( let package = Package(
name: "NameOfMyProject", name: "NameOfMyProject",
dependencies: [ dependencies: [
.Package(url: "https://github.com/yeokm1/SwiftSerial.git", majorVersion: 0), .package(url: "https://github.com/yeokm1/SwiftSerial.git", from: "0.1.1"),
... ...
] ]
... ...