Skip to content
Serial Communication Library for macOS written by Swift.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
SerialGate.xcodeproj
SerialGate
SerialGateDemo
images
.gitignore
LICENSE
README.md
SerialGate.podspec
SerialGateDemo.ino

README.md

SerialGate

Serial Communication Library for macOS written by Swift.

Installation

1.For installation with CocoaPods, simply add the following to your Podfile:

pod 'SerialGate'

2.Put a check mark for "USB" in Capabilities of Targets (SandBox)

sandbox

3.Edit the entitlements and add com.apple.security.device.serial

entitlements

Demo

Serial Communication Demo App for Arduino or mbed is in this Project. entitlements

Usage

  • Get serial ports
let manager = SGPortManager.shared
let serialPorts = manager.availablePorts
  • Open a serial port
port.delegate = self      // SGPortDelegate is required
port.baudRate = B9600
port.open()
  • Close a serial port
port.close()
  • Send a message
let text: String = "Hello World"
port.send(text)
  • Read messages

⚠️ SerialGate waits until gets a new line code ("\n" or "\r\n") and does not return values.

func received(_ texts: [String]) { }   // SGPortDelegate is required
  • Get notification of updated of availablePorts.
func updatedAvailablePorts() { }    // SGPortManagerDelegate is required
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.