Pages: [1]   Go Down
Author Topic: Serial Reading - Char Limit?  (Read 612 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is there a limit to the number of char inputs the Serial can read at one time?
Logged

Peoples Republic of Cantabrigia
Offline Offline
God Member
*****
Karma: 6
Posts: 691
Arduino happiness
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The serial buffer as of Arduino 1.0+ is 64 bytes.

If you're using SoftSerial, only one softserial connection can receive data at a given time.
« Last Edit: July 12, 2012, 10:23:47 am by Constantin » Logged

UK
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3969
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes.  One.

Serial reads one character at a time from the input.

It places those characters, one at a time, into an input buffer - the size of which depends on the Arduino you are using.

You then read those characters from the input buffer using the Serial.read() function, which returns the characters from the buffer one at a time.

If you want to read more than one at a time you can use the Serial.readBytes(buffer,len) function to read up to "len" characters from the serial buffer into the memory pointer to by "buffer":

Code:
char buf[10];

Serial.readBytes(buf,9);

- that will read 9 bytes into the variable "buf", leaving room for one extra character for the null-termination for the string.
Logged

Why not visit my eBay shop? http://stores.ebay.co.uk/Majenko-Technologies
Replacement for the Arduino IDE: UECIDE - Proper serial terminal, graphing facilities, plugins, overhauled internals.
Java isn't bad in itself, but it has enabled morons to write programs.

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Okay, I suppose I should have asked how many characters the Serial can hold. It's 64 bytes? Does that come out to about 64 characters?
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 549
Posts: 46110
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
It's 64 bytes? Does that come out to about 64 characters?
No. It comes out to exactly 64 characters. If using Arduino IDE 1.0+. On older versions, the buffer size was 128 characters.
Logged

Pages: [1]   Go Up
Jump to: