Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 14 of 14

Thread: Serial Monitor missing data on some Macintosh computers

  1. #1
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,057

    Serial Monitor missing data on some Macintosh computers

    When Teensy sends data very rapidly with the lines/sec benchmark, on some Macs the serial monitor loses parts of the incoming data.

    Click image for larger version. 

Name:	serial_monitor_issue_mac.png 
Views:	4 
Size:	63.2 KB 
ID:	16561

    But when I run it here on my Macbook Air, I see this:

    Click image for larger version. 

Name:	screen.png 
Views:	9 
Size:	230.1 KB 
ID:	16562

    Why the data loss happens on some Macs but not others is a mystery.

  2. #2
    Junior Member
    Join Date
    Nov 2017
    Posts
    6
    Encountering this issue! Are there any tests I could run Paul to see why this is happening?

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,057
    Yes, here's a first guess to try... a copy of usb_serial.c without any transmit flushing. This will cause problems with other programs, so it's only meant for testing with this speed benchmark. Other programs which don't transmit tons of data continuously will withhold sending until you've printed a multiple of 64 bytes. The idea is to make sure we only send full 64 byte USB packets to your Mac, to see if that makes any difference.

    To use this, control-click Arduino and select "Show Package Contents" from the context menu.

    Then in the new window, navigate to Conents/Java/hardware/teensy/avr/cores/teensy3. Copy this usb_serial.c file into that folder, replacing the copy already there. You shouldn't need to restart Arduino. It is supposed to notice the file is new and automatically recompile it on your next Upload or Verify.
    Attached Files Attached Files

  4. #4
    Forget what I said on twitter, I found a 3.6!

    Ok this first test is Arduino 1.8.8, macOS 10.13.6, Teensduino 1.45. I'll update to latest and try again in a bit.

    Old usb_serial.c (included with package):
    Click image for larger version. 

Name:	Screen Shot 2019-05-07 at 11.42.04 AM.jpg 
Views:	10 
Size:	109.2 KB 
ID:	16566

    New usb_serial.c (provided my Paul):
    Click image for larger version. 

Name:	Screen Shot 2019-05-07 at 11.46.01 AM.jpg 
Views:	9 
Size:	109.8 KB 
ID:	16567

    Both just stop printing at the point where it cuts off (10001323 in the second one). I also get "An error occurred while uploading the sketch" but teensyduino shows the new sketch uploading. This is a common problem for me when using any Teensy board I've learned to ignore it but could be related (it has been brought up in previous forum discussions on this same topic).

  5. #5
    Just as a reminder - the missed data and hanging only happens when USB Type is set to something including Serial. If it's set to Raw HID then the serial printout works perfectly (but only in Arduino Serial Monitor, of course. No other serial terminal sees it).

  6. #6
    Member
    Join Date
    Mar 2019
    Location
    Bordeaux / France
    Posts
    67
    I'm on Mac OS 10.12.6 (Sierra) and there's no problem nor with Arduino 146 with Arduino serial monitor neither with custom build (core from github master) + (iTerm2 or xterm) with tycmd monitor
    Tried Teensy on Mac usb Port, Teensy on Thunderbold Dock's USB, even on USB hub -> TB Dock : no loss, around 34900+ lines/second in all cases

    The tests I did were -DUSB_MIDI_AUDIO_SERIAL

    Is it a Mojave+ problem ? If not may be you setup a poll, with OS version and USB Mac's chipset type/manufacturer or whatever

  7. #7
    It has existed since at least Sierra. High Sierra did some fixes to serial in the OS that we hoped would fix the problem but didn't seem to.

  8. #8
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,057
    Ok, looks like the problem may be something on the Macintosh side.

    Next thing to try is whether Coolterm can receive the data without dropouts.

    To select the serial port, click Connection > Options, then click the "Re-Scan Serial Ports" button at the bottom if Teensy doesn't show in the Port drop-down. The other settings don't matter. Here's a screenshot of how I tested.

    Click image for larger version. 

Name:	coolterm1.jpg 
Views:	10 
Size:	67.2 KB 
ID:	16568

    Then click the "Connect" button in the toolbar. Here's how it looks on my Macbook Air.

    Click image for larger version. 

Name:	coolterm2.jpg 
Views:	5 
Size:	96.1 KB 
ID:	16569

    If Coolterm can receive the data without problems, then the bug is very likely in Teensyduino serial monitor code. Or maybe in the Arduino IDE itself?

  9. #9
    Now using a Teensy LC (left the 3.6 at home, sorry for the change but the behaviour is the same).

    First upload. Actually worked fine but Arduino Serial Monitor hung after a second or so.
    Click image for larger version. 

Name:	Screen Shot 2019-05-08 at 1.50.36 PM.jpg 
Views:	4 
Size:	125.3 KB 
ID:	16575

    SIDENOTE: Just as a reminder, once in a while it works fine. AND that uploaded sketch continues to work. BUT if you re-upload the same sketch without changing anything, the missed characters bug shows up. It seems to me that it is usually the first upload that is more likely to work but I have never been able to consistently repeat it.

    Next upload. Missed characters and Serial Monitor hang (i.e. serial data stops streaming).
    Click image for larger version. 

Name:	Screen Shot 2019-05-08 at 1.50.54 PM.jpg 
Views:	4 
Size:	112.8 KB 
ID:	16576

    Same upload checked in CoolTerm. Many missed characters BUT does not hang (i.e. serial data continues to stream).
    Click image for larger version. 

Name:	Screen Shot 2019-05-08 at 1.51.40 PM.jpg 
Views:	3 
Size:	156.5 KB 
ID:	16577

    These screenshots were all done with the 64-byte modified usb_serial.c. But I just switched back to the original file and ran it again and the behaviour is exactly the same.

  10. #10
    Paul, let me know if you'd like me to test anything else.

    The only hint I've got to think about is something to do with serial modems in the OS - sometimes in the network preferences teensy will keep creating new modem devices (USB Serial, USB Serial 1, USB Serial 2...). BUT this is also not consistently repeatable. Adafruit SAMD based boards will sometimes do this too, but they don't drop serial data...

  11. #11
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,057
    Quote Originally Posted by brendanmatkin View Post
    Adafruit SAMD based boards will sometimes do this too, but they don't drop serial data...
    Can you try running the benchmark program on an Adafruit board?

    https://github.com/PaulStoffregen/US...rint_speed.ino

    What speed do you get?

  12. #12
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    1,973
    I did some quick testing with T3.6 and adafruit M4 feather (SAMD51) using USB lines sketch to MAC OS 10.13.6, arduino serial monitor on macbook pro.

    T3.6 no losses lines/sec=35401
    ada M4 no losses lines/sec=12814

    using 1.8.8 with 1.47-beta2
    Last edited by manitou; 05-15-2019 at 06:00 PM.

  13. #13
    Just tested with a Feather M0 Bluefruit, and a Trinket M0. Both work as expected - not hanging and not dropping data - settling around 5500 lines/sec.

    Tried multiple uploads and power cycles on each just to be sure.

  14. #14
    p.s. FYI just did another test with Teensy to verify that it fails after Adafruit succeeds and it behaves just like before (i.e. it still drops data and hangs the serial monitor)

    NOTE: I can stop the monitor from hanging on Teensy if I add a delay(1) to the end of your benchmark program (see below just to be clear). It still drops data just like the previously seen but doesn't hang anymore.

    Code:
    void setup() {
      Serial.begin(1000000); // edit for highest baud your board can use
      while (!Serial) ;
      count = 10000000;
      prior_count = count;
      count_per_second = 0;
      prior_msec = millis();
    }
    
    void loop() {
      Serial.print("count="); 
      Serial.print(count);
      Serial.print(", lines/sec=");
      Serial.println(count_per_second);
      count = count + 1;
      uint32_t msec = millis();
      if (msec - prior_msec > 1000) {
        // when 1 second as elapsed, update the lines/sec count
        prior_msec = prior_msec + 1000;
        count_per_second = count - prior_count;
        prior_count = count;
      }
      delay(1);
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •