Serial Communication between Mega2560 & CHR-6d

Hey pylon,

thanks for your reply.

Is it possible that the packet has to be finished with a line feed/carriage return or both?

I don't think so. The Sensor (CHR-6d) will recognize the packet length from byte five. When using HTerm I'm not sending line feed or carriage return as well. I'm just sending let's say 73 6E 70 83 00 01 D4 in hex code entry method for setting the silent mode. And it works just perfect.

Serial1.println(F("73:6E:70:83:00:01:D4"));

I've tried this and it seems to work, but now I'm receiving a packet from sensor which contains "buffer_overflow". Meaning the internal receive buffer of the CHR-6d overflows before receiving a full packet. I'm not sure, but should I synchronize Sensor's reading and Mega's writing somehow?

Alex

whole programm code follows:

int inByte = 0;

void setup()
{
  Serial.begin(115200);
  Serial1.begin(115200);
  delay(5000);
  //Serial1.println(F("73 6E 70 01 00 01 52"));
  //Serial1.println(F("0x730x6E0x700x830x000x010xD4"));
  Serial1.println(F("73 6E 70 83 00 01 D4"));
 }

void loop()
{
  if (Serial.available() > 0)
  {
    inByte = Serial.read();
    Serial1.write(inByte);
  }
 
  if (Serial1.available() > 0)
  {
    inByte = Serial1.read();
    Serial.write(inByte);
  }
   
  
}