Go Down

Topic: Serial Communication between 2 mega (Read 411 times) previous topic - next topic

Mart

Jul 08, 2011, 05:46 pm Last Edit: Jul 08, 2011, 06:16 pm by Mart Reason: 1
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: [Select]

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: [Select]


// 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?

PaulS

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:"

Graynomad

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
Rob Gray aka the GRAYnomad www.robgray.com

Go Up