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

Thread: Serial.addMemoryForWrite

  1. #1
    Member
    Join Date
    Jan 2020
    Location
    Port Elizabeth
    Posts
    71

    Serial.addMemoryForWrite

    I know I am late to the party but I have only recently discovered the very useful methods
    such as
    Serial1.addMemoryForRead(s1RxBuffer, sizeof(s1RxBuffer));
    Serial1.addMemoryForWrite(s1TxBuffer, sizeof(s1TxBuffer));
    which work nicely for me.

    But when I try this
    Serial.addMemoryForWrite(s1TxBuffer, sizeof(sTxBuffer));
    I get the this
    error: 'class usb_serial_class' has no member named 'addMemoryForWrite'

    So Serial does not have methods such as 'addMemoryForWrite'.
    Why is this?
    Is there no need to adjust the receive and transmit buffer sizes for Serial?
    Why?

    Peter.

  2. #2
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    8,230
    "Serial" uses USB, which is orders of magnitude faster and additionally uses USB buffers that are larger than those for HW serial.
    The code is completely different.

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    24,017
    Quote Originally Posted by PDOS View Post
    Is there no need to adjust the receive and transmit buffer sizes for Serial?
    Usually not.


    Why?
    Because USB virtual serial has built-in flow control as a fundamental part of the underlying USB protocol.

    Usually RTS/CTS flow control with ordinary serial eliminates the need for larger buffers too.

  4. #4
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    8,230
    Sure, for receive.
    For transmit, larger buffers allow to fill them without beeing forced to wait.

  5. #5
    Member
    Join Date
    Jan 2020
    Location
    Port Elizabeth
    Posts
    71
    Quote Originally Posted by Frank B View Post
    Sure, for receive.
    For transmit, larger buffers allow to fill them without beeing forced to wait.
    Thanks for the answers. Yes, my concern, as Frank noted, was to transmit big blocks of data over Serial without adding undue delays within the main loop. But my blocks are in any case going out suspiciously fast, so it appears there are already quite big buffers in place.

Posting Permissions

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