Objective-C Serial - Mac OS X

前端 未结 4 1329
傲寒
傲寒 2021-01-02 06:12

I\'m currently running the followin in Terminal to send a command over USB serial.

/Users/drummerboyx/Library/Scripts/arduino-serial -b 9600 -p /dev/tty.usbs         


        
4条回答
  •  醉梦人生
    2021-01-02 06:48

    ORSSerialPort is a newer, easier to use alternative to AMSerialPort.

    Using ORSSerialPort to open a port and send data can be as simple as this:

    ORSSerialPort *serialPort = [ORSSerialPort serialPortWithPath:@"/dev/cu.KeySerial1"];
    serialPort.baudRate = [NSNumber numberWithInteger:4800];
    [serialPort open];
    [serialPort sendData:someData]; // someData is an NSData object
    [serialPort close];
    

提交回复
热议问题