Pages: [1]   Go Down
Author Topic: Serial Communication between 2 mega  (Read 396 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 92
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

Boards: 2x Seeduino Mega
Baud: 4800

I am currently trying to communicate between two mega over Serial2 (HardwareSerial).  Code is pretty basic. I am sending 2000 times 17 bytes as fast as the hardware let me call .  

Code:
for(int i = 0 ; i < iu8_len ; i++)
{
Serial2.print(iau8_array[i]);
i_sent++;
}


On the other end it is a basic receive


Code:

// Serial is at 57600
// Serial2 is at 4800

if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial2.read();

// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
                u8_bytes_cnt++;
}

However, I am always not getting the full 2000 * 17 bytes on the other end.   Is it something I should expect at such a slow baud rate or I have other problem?
« Last Edit: July 08, 2011, 11:16:43 am by Mart » Logged

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

Quote
I am currently trying to communicate between two mega over Serial2 (HardwareSerial).  Code is pretty basic. I am sending 2000 times 17 bytes.
In what period of tome? A week? A day? An hour? A second?

Quote
However, I am always not getting the full 2000 * 17 bytes on the other end.  Is it something I should expect at such a slow baud rate or I have other problem?
The printing of the received data takes time. Depending on the speed that you print at, it could be causing the receive buffer to overflow, since more data is coming in than can be handled.

Try dropping the number of characters send out. Instead of "I received: ", use "In:"
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 129
Posts: 8589
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Baud rate should have nothing to do with it as such.

Quote
I am always not getting the full 2000 * 17 bytes
How many are you getting?

What data are you sending and what are you receiving?

How fast is the Serial.print running? If it's < about 15x (the length of "I received: nn") the 4800 baud you may be overflowing the receive buffer.

You need to post both halves of the code.

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Pages: [1]   Go Up
Jump to: