Rs232 Serial Communication

Hi,
I have a Arduino Mega 2560, a rs232 to ttl converter and a device that has a RS232 plug and i want to chat with it through Arduino.
When sending #S it is suppose to answer STAND-BY but nothing happens.

To check if my source is well written i've made several tests : (PC -> Hyperterminal)

Arduino to PC with the RS232 serial converter It Worked
Device to PC It worked as well

and the part when i try to get Arduino and the device to communicate just fail.
Serial is USB Serial Monitor to arduino and Serial1 is the device.
I put some "Serial.print()" here and there to check where my program is read and the function serialEvent1() is never triggered.
In the serial monitor, i've put those settings : NL & CR / 9600bd

 char byte = 0;
String str = "";
boolean flag_str = false;
char byte1 = 0;
String str1 = "";
boolean flag_str1 = false;

void setup()
{
  Serial.begin(9600);
  Serial1.begin(9600);
  
  Serial.flush();
  Serial1.flush();
}

void loop()
{
  if (flag_str)
  {
    int nb = Serial1.print(str);
    Serial.println(nb); // It displays the right length (4)
    Serial.println(str);
    flag_str = false;
    str = "";
  }
  
  if (flag_str1)
  {
    Serial.println("String received from the device");
    Serial.print(str1);
    flag_str1 = false;
    str1 = "";
  }
}

void serialEvent()
{
  Serial.println("serialEvent triggered");
  delay(40);
  while ( Serial.available() > 0 && flag_str == false)
  {
    byte = Serial.read();
    str += byte;
    if (byte == '\n')
      flag_str = true;
  }
}

void serialEvent1()
{
  Serial.println("serialEvent1 triggered");
  delay(40);
  while ( Serial1.available() > 0 && flag_str1 == false)
  {
    byte1 = Serial1.read();
    str1 += byte1;
    if (byte1 == '\n')
      flag_str1 = true;
  }
}

So what's wrong?
If anyone has some ideas or suggestions, please let me know

Thanks for reading

Looking at your code, how will your serial flags ever get changed from false. I see the serialEvent() and serialEvent1() functions, but nothing ever calls them. Is there some sort of interrupt triggering that happens on the mega that I'm not aware of, or are you expecting some sort of interrupt triggering that doesn't exist?

Ok, so ignore me. I just checked the Serial reference pages on arduino.cc and saw the serialEvent() documentation. Not quite interrupt driven, but looks to be a nice shortcut for serial data driven applications. Gonna watch this thread to learn something new tho...

Double check the speed and encoding options for both serial connections. If you haven't already tried it, try crossing the Rx and Tx lines between the Arduino and your device.

We were far far far away from the issue....

In fact, it was a physical matter : i had a problem with a rs232 cable which wasnt always working !!

My teacher told me : always double check your connectics, 80% of the case its a connectic issue !

Thanks for replying though, and bye