Abdellazizhammami / arduino

Automatically exported from code.google.com/p/arduino
Other
0 stars 0 forks source link

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

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
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

Original issue reported on code.google.com by mark.l.s...@gmail.com on 4 Jan 2012 at 2:55

GoogleCodeExporter commented 8 years ago
If this is done, the HardwareSerial::setDataFormat() has the nice advantage of 
placing all the extra code into a function which the linker will only add to 
the final binary file if it's actually used.  Placing this code in the 
constructor would enlarge all output for this seldom-used feature.

Original comment by paul.sto...@gmail.com on 4 Jan 2012 at 9:00

GoogleCodeExporter commented 8 years ago
How much overhead do you think it's likely to add?  In these kinds of cases, I 
tend to prefer API simplicity (adding it to begin()) vs. saving a few bytes of 
flash.

Original comment by dmel...@gmail.com on 4 Jan 2012 at 9:15

GoogleCodeExporter commented 8 years ago
I will write the code and come up with an exact code increase

Mark

Original comment by mark.l.s...@gmail.com on 4 Jan 2012 at 10:30

GoogleCodeExporter commented 8 years ago
Dupe of http://code.google.com/p/arduino/issues/detail?id=573  ?

Original comment by tweakne...@googlemail.com on 17 Jan 2012 at 2:53

GoogleCodeExporter commented 8 years ago
Issue 573 has been merged into this issue.

Original comment by dmel...@gmail.com on 11 Mar 2012 at 5:05

GoogleCodeExporter commented 8 years ago
Mark, any updates on this?

Original comment by dmel...@gmail.com on 11 Mar 2012 at 5:05

GoogleCodeExporter commented 8 years ago
this will be very ok!!
a problem avoider

Original comment by freesm...@gmail.com on 18 Apr 2012 at 12:43

GoogleCodeExporter commented 8 years ago
https://github.com/arduino/Arduino/commit/a72d05b2de3bf614aa1564792f4816a65189bd
f0
https://github.com/arduino/Arduino/commit/ae9b90603b0603d31910700f18628e6dd4ec11
7b
https://github.com/arduino/Arduino/commit/a374e8b7660dc24d379b0b2ea85eebcd2cf9ce
33

This was fixed by Alarus, although I made a couple of tweaks.

Original comment by dmel...@gmail.com on 30 Aug 2012 at 12:55

GoogleCodeExporter commented 8 years ago
is this in? thanks a lot! :)

Original comment by frozenf...@gmail.com on 30 Aug 2012 at 6:25

GoogleCodeExporter commented 8 years ago
Have you seen my request regarding potential significant RAM decrease (and 
minor flash decrease) http://code.google.com/p/arduino/issues/detail?id=1021 

Original comment by jaguar3s...@gmail.com on 31 Aug 2012 at 8:07

GoogleCodeExporter commented 8 years ago
to be honest, if I want to "make something" I will pick a mega2650. if i want 
to test something like I2C or serial string to another device, I will use an 
uno. I think assuming that everyone will use a mega is OK, so a little more RAM 
useage for better dev enviroment is OK

Original comment by frozenf...@gmail.com on 31 Aug 2012 at 8:20

GoogleCodeExporter commented 8 years ago
So do I need to update this library manually or wait for a major arduino update?

Original comment by jason.ji...@commagility.com on 8 Sep 2012 at 8:08

GoogleCodeExporter commented 8 years ago
I have been looking for a solution to communicate to a device using 7 
parity,Odd,2 stop. Looks like it has been addressed here. Can I get the code 
somewhere?

Original comment by Serindip...@gmail.com on 22 Nov 2012 at 1:25

GoogleCodeExporter commented 8 years ago
This is in Arduino 1.0.2.  I just pushed the documentation live here: 
http://arduino.cc/en/Serial/Begin

Original comment by dmel...@gmail.com on 22 Nov 2012 at 3:18

GoogleCodeExporter commented 8 years ago
Adding an example using config would clarify the fact the config specifiers are 
symbols not strings.

Original comment by jaguar3s...@gmail.com on 24 Nov 2012 at 5:45

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I'm new to Arduino/C++ and I have no idea how to supply the config specifiers.

Neither Serial.begin(9600, SERIAL_8N2) nor Serial.begin(9600, "SERIAL_8N2") is 
working with 1.0.2. An example would be extremely helpful!

Original comment by elba...@googlemail.com on 8 Dec 2012 at 2:33

GoogleCodeExporter commented 8 years ago
I found out that Serial.begin(9600, SERIAL_8N2) should be correct. However, 
it's still not compiling for my Arduino Leonardo Board.

I posted a question to 
http://stackoverflow.com/questions/13773764/how-to-supply-the-config-parameter-f
or-serial-beginspeed-config

Original comment by elba...@googlemail.com on 8 Dec 2012 at 3:18

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I need 9 bit data, i think that was in Marks original request. Can you please 
concider that?

Original comment by goran.an...@telia.com on 26 Mar 2013 at 11:07

GoogleCodeExporter commented 8 years ago
Can´t set partity for Arduino DUE board.

Code:

void setup()
{
  Serial3.begin(19200,SERIAL_8E1);
}

Error:
Arduino: 1.5.4 (Windows 7), Board: "Arduino Due (Programming Port)"

sketch_sep25a.ino: In function 'void setup()':
sketch_sep25a:3: error: 'SERIAL_8E1' was not declared in this scope

Original comment by gustavo....@gmail.com on 25 Sep 2013 at 7:59