Losing the end of my data

Hello all

This is a snippet that I have written from memory of some code on my other laptop, so please bear with me.
If I can, I will lift the code on a memory stick tomorrow.

I am trying to retrieve some data over serial. Using a Mega2560p.

This data arrives, but is missing the end. Looks to me to be receiving 63 characters and then cutting off (so that would say to me the buffer is filling up?)

I can quiz the source using the serial monitor, and it returns the whole message.

I declare the following:

char IncomingData[161];
int ReceivedData;
int DataCount;


Then the data retrieval loop is as follows:

char ReceivedData=Serial1.read();
IncomingData[DataCount] = ReceivedData;
} while (Serial1.available());


This only ever retrieves the first part of the incoming data.

What am I missing? Probably something obvious.

If I can, I will lift the code on a memory stick tomorrow

Please post the code that actually has the problem, using code tags, as described in How to use this forum.

We are in no hurry to see it.


at 250,000 bps, are you sure the ISR and code can keep up without overflow?

Using a do..while would be a fairly unusual to receive data - your first character might not have arrived yet, but you read it anyway.

OK. I goes to that routine using an if (Serial1.available()) in the main loop.

I wondered about the 250000 baud. Trouble is, I can't change the speed of the incoming data.

Have you fixed the do..while?

Does the do while need fixing if it only starts reading if data is available?

It never misses the start of the data

Why do we have to play guessing game?

Just post the code.

In code tags.

Well don't. Doesn't matter if you explain at the beginning that you don't have the code to hand.
I was just asking for any ideas.

Don't worry your pretty little heads

OK, thanks.

Don't use inappropriate programming constructs.