Ok, that is what I thought at first as well. So I just copied the relevant part of my program, where the buffer will be read in one by one in a unsigned char Array. I then deleted one line after the other to find the error and now I just have this basic rest of the code, but it is still not working...
unsigned char incoming_Char[230];
int a=0, b=0, c=0;
unsigned char Read_Serial=0;
void setup()
{
Serial.begin(115200);
}
void loop ()
{
a=0;
if (Serial.available()>0)
{
while (Serial.peek() != 241 )
{
Serial.print("reading: ");
Serial.print(a,DEC);
Serial.print("=");
Serial.println(Serial.peek(),DEC);
incoming_Char[a]=Serial.read();
a++;
Read_Serial=1;
}
}
if (Read_Serial==1)
{
for (int a=0; a<PROTOCOL_SIZE; a++)
{
Serial.print(a,DEC);
Serial.print(":");
Serial.println(incoming_Char[a],DEC);
}
Read_Serial=0;
}
}
As I want to set the brightness of the LEDs from 0 to 254 I am using Decimal as an input and am storing everything in the unsigned char array incoming_char.
With the specific input of "1 2 3 4 .. 96 97 98 241 251 " (sent via HTerm 0.81) I get the following output
...
reading: 67=68<\r><\n>
reading: 68=69<\r><\n>
reading: 69=70<\r><\n>
reading: 70=71<\r><\n>
reading: 71=72<\r><\n>
reading: 72=77<\r><\n>
reading: 73=93<\r><\n>
reading: 74=-1<\r><\n>
reading: 75=-1<\r><\n>
...
?? You see, until 72 everything works fine, then there is a jump to 93 and in the following the serial buffer doesn"t seem to have a content at all (-1)....
Does anyone has an idea what is wrong?
... Thank you very much!
Kai