Search code examples
serial-portcinder

Serial Communication in Cinder on Mac


I'm using Cinder 0.8.6 on mac OSX 10.10. I am pulling in serial data via usb from an Arduino. The data is showing up fine in Arduino's serial monitor, but the Cinder SerialCommunication example is giving me:

Device: cu.usbmodem1451
Device: tty.usbmodem1451
Device: cu.Bluetooth-Incoming-Port
Device: tty.Bluetooth-Incoming-Port
Device: cu.Bluetooth-Modem
Device: tty.Bluetooth-Modem
There was an error initializing the serial device!

I'm wondering what next steps to take in order to troubleshoot this so that Cinder can collect the serial data coming in from the Arduino.

UPDATE I've found that if I close the arduino serial monitor, the Cinder SerialCommunication app loads, takes over the port, and I don't get the error, but it hangs immediately. The data coming in from the Arduino looks like this:

E2: D=3  V=13
E2: D=2  V=15
E2: D=3  V=18
E2: D=3  V=21
E3: D=-1  V=-1
E3: D=1  V=0
E3: D=-1  V=-1
E3: D=1  V=0
E3: D=-1  V=-1
E1: D=3  V=3
E1: D=3  V=6
E1: D=4  V=10
E1: D=4  V=14
E1: D=5  V=19
E1: D=6  V=25

Solution

  • This looks like your Arduino:

    Device: cu.usbmodem1451
    Device: tty.usbmodem1451
    

    You may need to tweak this section in the sample's setup function:

    Serial::Device dev = Serial::findDeviceByNameContains( "tty.usbserial" );
    

    to be something like this:

    Serial::Device dev = Serial::findDeviceByNameContains( "tty.usbmodem" );
    

    e.g.

    try {
            Serial::Device dev = Serial::findDeviceByNameContains( "tty.usbmodem" );
            mSerial = Serial::create( dev, 9600 );
        }
        catch( SerialExc &exc ) {
            CI_LOG_EXCEPTION( "coult not initialize the serial device", exc );
            exit( -1 );
        }
    

    Alternatively you could explicitly use the full path:

    Serial::findDeviceByName("tty.usbmodem1451");
    

    but this may be less flexible since the digits after "tty.usbmodem" may change if you use a different USB port on OSX.