Skip to content

Add support for data bits, parity, and stop bits to HardwareSerial [imported] #770

@cmaglie

Description

@cmaglie

This is Issue 770 moved from a Google Code project.
Added by 2012-01-04T02:55:47.000Z by mark.l.s...@gmail.com.
Please review that bug for more context and additional comments, but update this bug.
Closed (Fixed).

Original labels: Type-Defect, Priority-Medium, Component-Core, Milestone-1.0.2, Component-Serial

Original description

What steps will reproduce the problem?
1.currently you have to bypass the Arduino libraries in order to use parity or 2 stop bits or data length other than 8 bits
2.
3.

What is the expected output? What do you see instead?

Please use labels and text to provide additional information.

Several times I have seen requests for support for even/odd parity and for 2 stop bits. The only thing Arduino currently supports is 8, 1, none

I propose to add 3 more OPTIONAL arguments to Serial.begin

void HardwareSerial::begin(long baud, uint8_t dataBits = 8, uint8_t stopBits = 1, char parity = 'N');

A 2nd way to do this is to have a separate routine

void HardwareSerial::setDataFormat(int dataBits, int stopBits, int parity);

Data bits supported would be 5,6,7,8,9 (default 8)
Stop bits supported would be 1 or 2 (default 1)
parity supported would be 'N' 'E' 'O' for None Even, Odd (default NONE)

These are the options that the atmega chip supports, it would be nice to be able to use all of them without having to bypass the Arduino abstraction layer.

Impact, NONE, since they new arguments would default to the current mode (8, 1, None), there would be no impact to any existing code.

For those of you that have never heard of 5 or 6 bit data, early teletype was 5 bit Baudot code, then the newspapers came out with Typesetter code which was 6 bits. Both of these were long before ASCII was invented

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