Characters on USB Serial on Reboot (Mac OS X)

Status
Not open for further replies.

ohhorob

Active member
I couldn't find anyone mentioning this, but while troubleshooting a temperamental USB Serial connection (missing output in my serial console) I found there are some characters waiting to be read every time Teensy connects..

Code:
Slurped serial bytes.
0x4D 0x35 0x30 0x31 0xA 
M501

Connected USB.
19200

TAB => showPorts()
ENTER => setupPorts()
SPACE => readEprom()

I'm not expecting the "M501<enter>" bytes when the Teensy connects to the Mac!

Has anyone else noticed something like this. Any suggestions for tracking down and removing what's causing it??

This is the code I use in setup() to produce the output shown above:

Code:
void setup() {
    Serial.begin(1);  // USB, communication to PC or Mac
    setupLED();
    delay(750);

    while (!Serial.availableForWrite()) {
        analogWrite(LED_RED, 180);
        delay(100);
    }
    analogWrite(LED_GREEN, 50);
    size_t len = 0;
    if (Serial.available()) {
        len = Serial.readBytes(usb_chars, 64);
    }
    Serial.write(ERASE_DISPLAY, 4);
    if (len > 0) {
        Serial.println("Slurped serial bytes.");
        for (size_t i = 0; i < len; i++) {
            Serial.print("0x");
            Serial.print(usb_chars[i], HEX);
            Serial.print(' ');
        }
        Serial.println();
        for (size_t i = 0; i < len; i++) {
            Serial.print(usb_chars[i]);
        }
        Serial.println();
    }

    Serial.println();
    Serial.println("Connected USB.");
    Serial.println(Serial.baud());

    // Enable the EPROM output
    pinMode(EPROM_ENABLE, OUTPUT);
    digitalWrite(EPROM_ENABLE, HIGH);
    delay(50);
    digitalWrite(EPROM_ENABLE, LOW);
    delay(200);
    analogWrite(LED_GREEN, 2);

    Serial.println();
    Serial.println("TAB => showPorts()");
    Serial.println("ENTER => setupPorts()");
    Serial.println("SPACE => readEprom()");

}

// For completeness..


// PWM pins for RGB LED
#define LED_RED   25
#define LED_GREEN  3
#define LED_BLUE  32
void setupLED() {

    // Setup RGB LED on PWM
    pinMode(LED_RED, OUTPUT);
    pinMode(LED_GREEN, OUTPUT);
    pinMode(LED_BLUE, OUTPUT);

    analogWrite(LED_RED,     0);
    analogWrite(LED_GREEN,   0);
    analogWrite(LED_BLUE,    0);
}

My serial terminal is minicom, installed via homebrew.

Code:
$ brew install minicom

And the connection is made with:

Code:
$ minicom -D /dev/cu.usbmodem1244611 -b 19200 -8 -c on -a on

Any other details relevant to the troubleshooting?
 
Status
Not open for further replies.
Back
Top