I hadn't revealed the send/receive process because on another board to do repairs, when you ask for help building what I am (knowing well that others have succeeded), they clam up and you can't get anything else from them. I received ONE reply for 5 messages I posted looking for a clue to get me past a road block. This makes one "gun shy" to be overly specific on details because people tend to scatter like cockroaches if you ask a "secret" question they might get ahead of them on. So, what is my mysterious project? I'm trying to setup a Mega that will act as a casino server. It currently can operate on it's own successfully printing, redeeming, and handling redundant commands in the background. So yeah, I'm one of those "slot machine" guys. The Mega performs as expected on the "base" model program.
I wanted more from my $40 expense and squeeze the blood out of it.
I started programming it to handle every possible command that I can throw at my slot machine via a web interface. Stopping after each new one, uploading, and testing until that process was successful and then squeeze a little more. I've even backed out the last 3 new additions and this phenomenon still exists. Why? I've got no frickin' clue. Is the new Ethernet.server I've added causing the buffer build up? I don't know that either.
Details about the data. Yes, it is a send/response system. I send a code then get a reply with the data I've requested. And it ALWAYS will begin with the HEX code for the number 1, always. The same command response can very possibly be a different length from the last time that it was sent. I have the Mega requesting status at the correct moment that there is no way a buffer can build up in the machine. Can I slow the status requests down? I've tried and I'll get errors in the data stream because the machine wants to "ping" the Mega to make sure it's still there before the Mega can send another message letting it know the link is still good.
I still haven't got to the point others have reached and I've only introduced the Webserver from my "base" fulling-working standalone, point. I've re-read my code 3-4 times to make sure I'm not sending a new command within 200ms of the last and would cause a buffer overrun on the machine The slot machine has yet to throw that certain exception code indicating that it's throwing away data. I'm doing something right there.
I don't know where the extra data is coming from or why they started. They happen with/without a browser connected. That's the reason for this threads subject, if I can use peek() == 0x01 (or even just 1) to find the beginning of the message before I readBytes(). Why do I ask? Because Serial1.peek() >=0 works to tell me when the slot machine is pinging the the Mega and the Mega can start comms. If I use "if(Serial1.available() > 0), then the Mega is constantly reading Serial1 and looking for a signal because Serial1 is available.
Code I use at the beginning of setup():
 if (Serial1.peek() >= 0)
 {
  if (Serial1.available() > 0)
  {
   i = 0;
   SASEvent = 0;
   UCSR1B = 0b10011101;  //Turn 9-bit On
   Serial1.write(0x80);
   delay(20);
   Serial1.write(0x81);
   delay(5);
   UCSR1B = 0b10011100;  //Turn 9-bit OFF
   delay(5);
   SASEvent = Serial1.read();
Code I thought would work to help me find 0x01:
 if (Serial1.peek() == 0x01)
 {
  Serial1.readBytes(CashOut, sizeof(CashOut));
 }
 else
 {
  Serial1.read();
 }