osx - Swift 3 ORSSerialPort read from arduino -


so i'm trying read arduino output orsserialport lib. if use example code, of lib, named orsserialportdemo, works. thing mis in demo how used serialportdemocontroller.swift in there viewcontroller.

i created standard project, has viewcontroller.swift. bridge header imports done, references compile. rather using gui select usb-port , baud rate, set them in code.

something this:

var serial: serialportdemocontroller? serial = serialportdemocontroller() serial.path = "dev/cu.usbserial-a6006hps" serial.baudrate = 9600 serial.open() 

then al need read port. should work, function: func serialport(_ serialport: orsserialport, didreceive data: data)? in functio this:

if let string = nsstring(data: data, encoding: string.encoding.utf8.rawvalue)  {     print(string) } 

i have looked around, nothing seems work. if point me in right direction great.

thanks!


Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

android - ConstraintLayout: Realign baseline constraint in case if dependent view visibility was set to GONE -