MacWise terminal emulation for Mac OSX - Best telnet, ssh & serial for Wyse 50, Wyse 60, Wyse 370, ADDS Viewpoint, Televideo 925, DEC VT100, VT220 and Prism - connecting Macs to host computers running systems such as PICK, UNIX, uniVerse, UniData, GA, Prime, Ultimate and McDonnell Douglas, Xymox and more. This assumes you are using a Windows PC. If you are using a Mac or Linux you will need to install similar terminal software to connect to the Serial port provided by the USB serial Bluetooth card. I have used CoolTerm for Mac which I downloaded from the freeware.the-meiers.org site.
![]()
Background Information A simple serial port program has three main functions. First it should init the serial port, and then it should read data from the serial port and transmit data read from the serial port. The latter requirement means that two processes are necessary running simultaneously. In a Unix environment a serial port is accessed via a file descriptor. This means a terminal program uses the file access API to read and write data to a serial port. The serial port handle is available in /dev and has the prefix cu, which stands for calling-unit.
To access the serial port, this handle is just opened as an ordinary file. The opened serial port file descriptor also conforms to the TTY API for setting serial port specific settings like baudrate.
![]()
This tutorial describes how to implement the simple serial port program in OS X in Swift. Accessing a serial port in OS X requires the use of three API’s: IOKit, common BSD file handling APIs and BSD TTY APIs. The first two are reasonably easy to use from Swift, but the third does not import quite well. The BSD TTY APIs uses complex macros and varargs which are not supported by Swift directly. The obvious choice is to use an Objective-C or C wrapper as we also will do in this tutorial.
We could write our own wrapper, but luckily, an excellent serial port library exists. This library is which provides a great API for using serial ports in OS X. The last nice feature of the ORSSerialPort library is that it also handles the threading related to using the serial port. Pod update During downloading the dependencies CocoaPods creates an Xcode workspace project. Close your earlier created project, and reopen the workspace file. Xcode should now open with a new folder “Pods” containing the ORSSerialPort. Try to run the project, it should print “Hello World!”. Note, the ORSSerialPort library uses the newest API functionality of Apple, like NS ASSUME NONNULL and nullable.
In case you use XCode prior to 6.3.2 you need to disable the NS ASSUME NONNULL BEGIN and NS ASSUME NONNULL END macros and remove the ‘nullable’ property in de ORSSerialPort source code.
Comments are closed.
|
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |