Skip to content

Don't call Serial.begin() #2

@matthijskooijman

Description

@matthijskooijman

I noticed that right now, the begin() method accepts an enumeration to switch between the primary serial port and softwareserial, and begin() also calls the begin() method on the chosen serial object. This approach is very inflexible, since:

  • It doesn't allow use of other serial ports (like Serial1, AltSoftSerial, etc.)
  • It requires SoftwareSerial to always be linked in, even if it is unused (which hijacks the PCINT ISRs on AVR).

Instead, it would be better to just let begin() accept a Stream& reference, and expect the sketch to call begin() on that and specify the baudrate. For example, the xbee-arduino library also uses this approach:
https://github.com/andrewrapp/xbee-arduino/blob/master/XBee.cpp#L786-L788
https://github.com/andrewrapp/xbee-arduino/blob/master/examples/AtCommand/AtCommand.pde#L54-L55

With this library still being new, hopefully you'll consider this change now, before it would break too many existing sketches.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy