Skip to content

9-bit frame support to Hardware Serial 1.0.X #2292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

9-bit frame support to Hardware Serial 1.0.X #2292

wants to merge 1 commit into from

Conversation

Bouni
Copy link

@Bouni Bouni commented Sep 8, 2014

I've added support for sending and receiving 9-bit frames for AVR based boards.
The changes are tested with a test sketch [1] and also with a logic analyzer (Saleae Logic 8).

I use two bytes in the buffer for storing a 9 bit frame. So i don't have to change the buffer type to uint16_t which means that all other modes then 9 bit don't waste RAM. The only downside for 9 bit users is that the buffer has only half the size.

[1] Test Sketch

@Bouni Bouni changed the title Added 9-bit frame support to Hardware Serial 9-bit frame support to Hardware Serial 1.0.X Sep 8, 2014
@ArduinoBot
Copy link
Contributor

Can one of the admins verify this patch?

@cmaglie cmaglie added feature request A request to make an enhancement (not a bug fix) Component: HardwareSerial The hardware serial functionality of the core libraries labels Apr 15, 2015
@NicoHood
Copy link
Contributor

NicoHood commented Jun 1, 2015

I like the idea but would rather use templates for this. Because as it is right now it adds more flash to the serial. And its not likely that people will use this 9 bit more, even though its really cool.

So in my opinion the whole Serial should be reworked as template, but they wont accept this anyways I guess.

@Bouni
Copy link
Author

Bouni commented Jun 2, 2015

Unfortunately i have no idea how to use templates to achieve this :-/

@NicoHood
Copy link
Contributor

NicoHood commented Jun 5, 2015

FYI: I also found this:
#1221

@Bouni
Copy link
Author

Bouni commented Jun 5, 2015

@NicoHood
I was in touch with @agalliazzo before i started my work on the 9-bit support.
He said that his work was made such a long time ago that it will be a pain to merge it with the state of the Arduino code at that time.
Also i wanted an approach that doesn't require to change the entire buffers to 16-bit.

@NicoHood
Copy link
Contributor

NicoHood commented Jun 5, 2015

Well this now also applies to your code, as I've checked it.
the Arduino core now uses 3 different .cpp files for each Serial instance. So you have to migrate it anyways.

I am currently working on a basic setup to send 9N1 bytes. I got it working with 8N1. with 9N1 as sending setting and 8N1 as receiving setting I still get the lower 8 byte of data. Is this a normal behaviour? the extra bit is just thrown away as far as I can see.

@Bouni
Copy link
Author

Bouni commented Jun 12, 2015

@NicoHood
Have you seen my other Pull request #2291 ?

@NicoHood
Copy link
Contributor

I think I've missed it. Thanks.
I currently have no time to test it though.

Edit: but you could test a simple hello world print with 8 bit compared to the 9 bit. It would be nice to know how much overhead of ram and flash this takes. (for 1.6.x of course).

@Bouni
Copy link
Author

Bouni commented Jun 17, 2015

@NicoHood you mean compare the standard Arduino IDE to my extended 9-bit version?

@NicoHood
Copy link
Contributor

Yes. But with the 1.6.x release. So we can see if it adds much overhead if this would be merged.
Compare a standard 8N1 setting with the standard IDE and your code and also post how big a 9N1 setting (not available in the IDE) compiles. So we have 3 setting to compare:

IDE 8N1
PR 8N1
PR 9N1

with ram and flash usage.

@Bouni
Copy link
Author

Bouni commented Jun 17, 2015

@NicoHood Can you explain how I can get the RAM and Flash usage?

@NicoHood
Copy link
Contributor

Its displayed after compiling.

@Bouni
Copy link
Author

Bouni commented Jun 17, 2015

@NicoHood Ok, i did a few tests:

i compiled SerialCallResponse.ino with 4 different Arduino setups using the CLI (except for 1.0.5)

./arduino --verify --board arduino:avr:uno examples/04.Communication/SerialCallResponse/SerialCallResponse.ino

Arduino 1.0.5 (master branch at the time i did my modifications)

Binary sketch size: 3,060 bytes (of a 32,256 byte maximum)

Arduino ide-1.5.x (for comparison to 1.0.5)

Sketch uses 2,986 bytes (9%) of program storage space. Maximum is 32,256 bytes.
Global variables use 192 bytes (9%) of dynamic memory, leaving 1,856 bytes for local variables. >Maximum is 2,048 bytes.

Arduino ide-1.5.x-hardware-serial-9-bit

Sketch uses 3,470 bytes (10%) of program storage space. Maximum is 32,256 bytes.
Global variables use 194 bytes (9%) of dynamic memory, leaving 1,854 bytes for local variables. >Maximum is 2,048 bytes.

Arduino 1.6.4 (current version installed from arch linux AUR repo)

Sketch uses 2,878 bytes (8%) of program storage space. Maximum is 32,256 bytes.
Global variables use 196 bytes (9%) of dynamic memory, leaving 1,852 bytes for local variables. >Maximum is 2,048 bytes.

@NicoHood
Copy link
Contributor

Those results are unclear to me. What is 1.5.x? What exact version did you use here? And what serial setting? 8N1 or 9N1? You have to tell me the Serial setting, otherwise it doesnt make any sense. I personally also do not care about 1.0.5 at all.

You need to test all 3 that I listed above with 1.6.4 (or 1.6.5).

IDE 8N1 vs PR 8N1 tells us how much overhead this PR gives us when its just implemented. If nobody uses those 9N1 function he also has the delta in his sketch. If this delta is too big its not worth to merge the PR.

PR 8N1 vs PR 9N1 tells us if using 9N1 with the PR already enabled gives us even more overhead. But my guess is that there is no more overhead.

@Bouni
Copy link
Author

Bouni commented Jun 17, 2015

@NicoHood post code snippet(s) you want to have compiled and i'll do it for 1.6.4, and the Pull request!

What is 1.5.x?
its the branch ide-1.5.x which was the development branch for the 1.5 version of Arduino at that time,
1.5 was not released back then.

@NicoHood
Copy link
Contributor

A simple Serial.begin(9600, 8N1) in setup() and a Serial.println("Hello World"); delay(1000); in the loop() should do it.

@facchinm
Copy link
Member

Closing as 1.0.x branch is in maintenance mode only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: HardwareSerial The hardware serial functionality of the core libraries feature request A request to make an enhancement (not a bug fix)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants