Pages: [1]   Go Down
Author Topic: Serial.available() buffer reduced ??  (Read 591 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 0
Posts: 146
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i was using in arduino 022

while( Serial.available() < 127 );

but now the programm stalls at this point

but if i use

while( Serial.available() < 63 );

it continiues normanly

can we make it work again with 127???


thanks a lot
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 217
Posts: 13707
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


you can do that yourself:

goto - C:\Program Files (x86)\arduino-0022\hardware\arduino\cores\arduino -

edit HardwareSerial.cpp and search this code

#if (RAMEND < 1000)
  #define RX_BUFFER_SIZE 32
#else
  #define RX_BUFFER_SIZE 128
#endif

and change the 32 in 128 too ...
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

0
Offline Offline
Full Member
***
Karma: 0
Posts: 146
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks a lot it worked
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 613
Posts: 49343
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
while( Serial.available() < 127 );
Why are you not reading and storing the data as soon as it is available? What benefit is obtained by waiting until there is a truckload of data to process?
Logged

Seattle, WA
Offline Offline
God Member
*****
Karma: 11
Posts: 673
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Or if you wanted to be portable, you could do

Code:
while( Serial.available() < RX_BUFFER_SIZE )
Logged


0
Offline Offline
Full Member
***
Karma: 0
Posts: 146
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
while( Serial.available() < 127 );
Why are you not reading and storing the data as soon as it is available? What benefit is obtained by waiting until there is a truckload of data to process?

because then i want to send them over I2C

and because I2C is faster than Uart its not working
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 613
Posts: 49343
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
because then i want to send them over I2C
Which uses a 32 byte buffer. Makes sense.

Quote
and because I2C is faster than Uart its not working
The UART IS working, even when you aren't reading the data that it is buffering.
Logged

Pages: [1]   Go Up
Jump to: