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

Thread: Weird behavior of SerialMonitor

  1. #1
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,508

    Weird behavior of SerialMonitor

    I face the following issue:
    Trying to use MTP-Disk with USB-Serial the TD-SerialMonitor is only showing data in blocks (every 10 seconds data are printed)
    using Putty, data are printed very quickly line-by-line and not in bursts.

    Further, I cannot use automode for download (i.e. butto-press is required)
    My hunch is that the new MTP-descriptor definitions are not suited (recall: ´good´ MTP-Disk descriptor is using Seremu)
    When compiling for Seremu, lines are coming as they are printed and I can use automode for programming

    (Side-note: Serial.flush() with Seremu prints random characters)

    for completeness here are the two descriptors definitions

    Seremu
    Code:
    #elif defined(USB_MTPDISK)
      #define VENDOR_ID             0x16C0
      #define PRODUCT_ID            0x04D1
      #define MANUFACTURER_NAME     {'T','e','e','n','s','y','d','u','i','n','o'}
      #define MANUFACTURER_NAME_LEN 11
      #define PRODUCT_NAME          {'T','e','e','n','s','y',' ','M','T','P',' ','D','i','s','k'}
      #define PRODUCT_NAME_LEN      15
      #define EP0_SIZE              64
    
      #define NUM_INTERFACE		      2
      #define NUM_ENDPOINTS         4
      #define SEREMU_INTERFACE      1	// Serial emulation
      #define SEREMU_TX_ENDPOINT    2
      #define SEREMU_RX_ENDPOINT    2
      #define SEREMU_TX_SIZE        64
      #define SEREMU_RX_SIZE        32
      #define SEREMU_TX_INTERVAL    1	 // TODO: is this ok for 480 Mbit speed
      #define SEREMU_RX_INTERVAL    2	 // TODO: is this ok for 480 Mbit speed
      #define ENDPOINT2_CONFIG	ENDPOINT_RECEIVE_INTERRUPT + ENDPOINT_TRANSMIT_INTERRUPT
    
      #define MTP_INTERFACE         2 // MTP Disk
      #define MTP_TX_ENDPOINT       3
      #define MTP_RX_ENDPOINT       3
      #define MTP_EVENT_ENDPOINT    4
      #define MTP_TX_SIZE_480       512
      #define MTP_RX_SIZE_480       512
      #define MTP_TX_SIZE_12        64
      #define MTP_RX_SIZE_12        64
      #define MTP_EVENT_SIZE        16
      #define MTP_EVENT_INTERVAL    1
    
      #define ENDPOINT3_CONFIG	ENDPOINT_RECEIVE_BULK + ENDPOINT_TRANSMIT_BULK
      #define ENDPOINT4_CONFIG	ENDPOINT_RECEIVE_INTERRUPT + ENDPOINT_TRANSMIT_INTERRUPT  // ????
    Serial
    Code:
    #elif defined(USB_MTPDISK)
      #define VENDOR_ID             0x16C0
      #define PRODUCT_ID            0x04D1
      #define MANUFACTURER_NAME     {'T','e','e','n','s','y','d','u','i','n','o'}
      #define MANUFACTURER_NAME_LEN 11
      #define PRODUCT_NAME          {'T','e','e','n','s','y',' ','M','T','P',' ','D','i','s','k'}
      #define PRODUCT_NAME_LEN      15
      #define EP0_SIZE              64
    
      #define NUM_INTERFACE		      3
      #define NUM_ENDPOINTS         5
    
      #define CDC_IAD_DESCRIPTOR	  1
      #define CDC_STATUS_INTERFACE	0
      #define CDC_DATA_INTERFACE	  1	// Serial
      #define CDC_ACM_ENDPOINT	    2
      #define CDC_RX_ENDPOINT       3
      #define CDC_TX_ENDPOINT       3
      #define CDC_ACM_SIZE          16
      #define CDC_RX_SIZE_480       512
      #define CDC_TX_SIZE_480       512
      #define CDC_RX_SIZE_12        64
      #define CDC_TX_SIZE_12        64
      #define ENDPOINT2_CONFIG	ENDPOINT_RECEIVE_UNUSED + ENDPOINT_TRANSMIT_INTERRUPT
      #define ENDPOINT3_CONFIG	ENDPOINT_RECEIVE_BULK + ENDPOINT_TRANSMIT_BULK
    
      #define MTP_INTERFACE         2 // MTP Disk
      #define MTP_TX_ENDPOINT       4
      #define MTP_RX_ENDPOINT       4
      #define MTP_EVENT_ENDPOINT    5
      #define MTP_TX_SIZE_480       512
      #define MTP_RX_SIZE_480       512
      #define MTP_TX_SIZE_12        64
      #define MTP_RX_SIZE_12        64
      #define MTP_EVENT_SIZE        16
      #define MTP_EVENT_INTERVAL    1
    
      #define ENDPOINT4_CONFIG	ENDPOINT_RECEIVE_BULK + ENDPOINT_TRANSMIT_BULK
      #define ENDPOINT5_CONFIG	ENDPOINT_RECEIVE_INTERRUPT + ENDPOINT_TRANSMIT_INTERRUPT  // ????
    Not sure what I´m missing
    Oh: windows10 Arduino 1.8.10 TD 1.49

  2. #2
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,508
    some debugging info:
    (to be clear I use the example program of MTP_t4)
    flush callback is called (with 10 or 6 bytes ) as it should according to setup/loop
    But data do not "arrive" on SerialMonitor but are combined to multiple lines.

  3. #3
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,508
    Further info
    this burst behaviour does not occur with Serial+Midi, so it is related with MTP_DISK descriptor and Serial_Monitor.

    If I send 65 bytes in loop (Compiled with native serial MTP Disk)

    Code:
    void setup() {
      // put your setup code here, to run once:
    
    }
    
    void loop() {
      // put your main code here, to run repeatedly:
    Serial.println("012345678901234567890123456789012345678901234567890123456789012");
    delay(1000);
    }
    (63 + CRLF)
    then SerialMonitor is in sync with program.

    conclusion: somewhere are 65 bytes buffered!

    Is SerialMonitor sensitive to USB class code? (serial, Midi, etc?)

  4. #4
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,508

    Maybe issue found?

    To understand the blocking behaviour of SerialMonitor I simply changed the product id to a MidiDevice
    Code:
    #elif defined(USB_MTPDISK)
      #define VENDOR_ID             0x16C0
      #define PRODUCT_ID            0x0489 //0x04D1
      #define BCD_DEVICE		0x0215
      
      #define MANUFACTURER_NAME     {'T','e','e','n','s','y','d','u','i','n','o'}
      #define MANUFACTURER_NAME_LEN 11
      #define PRODUCT_NAME          {'T','e','e','n','s','y',' ','M','T','P',' ','D','i','s','k'}
      #define PRODUCT_NAME_LEN      15
      #define EP0_SIZE              64
    
      #define NUM_INTERFACE		      3
      #define NUM_ENDPOINTS         5
    
      #define CDC_IAD_DESCRIPTOR	  1
      #define CDC_STATUS_INTERFACE	1
    
      #define CDC_DATA_INTERFACE	  2	// Serial
      #define CDC_ACM_ENDPOINT	    2
      #define CDC_RX_ENDPOINT       3
      #define CDC_TX_ENDPOINT       3
      #define CDC_ACM_SIZE          16
      #define CDC_RX_SIZE_480       512
      #define CDC_TX_SIZE_480       512
      #define CDC_RX_SIZE_12        64
      #define CDC_TX_SIZE_12        64
      #define ENDPOINT2_CONFIG	ENDPOINT_RECEIVE_UNUSED + ENDPOINT_TRANSMIT_INTERRUPT
      #define ENDPOINT3_CONFIG	ENDPOINT_RECEIVE_BULK + ENDPOINT_TRANSMIT_BULK
    
      #define MTP_INTERFACE         3 // MTP Disk
      #define MTP_TX_ENDPOINT       4
      #define MTP_RX_ENDPOINT       4
      #define MTP_EVENT_ENDPOINT    5
      #define MTP_TX_SIZE_480       512
      #define MTP_RX_SIZE_480       512
      #define MTP_TX_SIZE_12        64
      #define MTP_RX_SIZE_12        64
      #define MTP_EVENT_SIZE        16
      #define MTP_EVENT_INTERVAL    1
    
      #define ENDPOINT4_CONFIG	ENDPOINT_RECEIVE_BULK + ENDPOINT_TRANSMIT_BULK
      #define ENDPOINT5_CONFIG	ENDPOINT_RECEIVE_INTERRUPT + ENDPOINT_TRANSMIT_INTERRUPT  // ????
    Now, the comport is shown as COM11 Serial+MIDI (Teensy4)
    The Serial port is responding in sync to short Teensy loop writes, however, the MTP is also showing the disk.
    So it really seems that the Teensy SerialMonitor is interpreting the product id and reacts correspondingly.

    So, conclusion: we need to wait for Paul to implement MTP_DISK in core AND to decide to use Serial, or Serialemu, or both.
    (Or not to use Teensy SerialMonitor)

    Hopefully, it is an easy fix?

Posting Permissions

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