SoftwareSerial read data incorrectly.

Hi,

I'm using Arduino Duemilanove to receive serial communication wirelessly, when I send "test" to PC the terminal prints "test".

When I send "test" from PC, the serial on the Arduino side prints "F4E5F3F4" as it suppose to be "74657374".

Has anyone experienced this problem and can give me some advise?

Thank you.

void loop()
{
  while (mySerial.available()) {
      delay(2);
      incomingByte = mySerial.read();
      str += incomingByte;
    }
    if (str.length() >0) {
      for(int i=0;i<str.length();i++){
       myPtHex(str[i]);
      }
      str="";
    }
}

void myPtHex(int g){
  int a = g& 0xf0;
  a = a >> 4;
  int b = g& 0x0f;
  char c = a < 10 ? a + '0' : a + 'A' - 10;
  Serial.write(c);
  c = b < 10 ? b + '0' : b + 'A' - 10;
  Serial.write(c);
} // myPtHex

Maybe the PC is sending the wrong stuff. The Arduino code looks reasonable - though I have not studied your HEX function. Just print it is decimal or chars in case the problem is with your function.

Can't you use Serial.print(var, HEX); to do the conversion?

...R

Hi Robin2,

Thanks, I've tried the conversion you suggested:

if (mySerial.available())
      Serial.print(mySerial.read(),HEX);

Still not receiving the correct data, still getting "F4E5F3F4".

Is the sending device sending 7 bit data with parity?
Given the data, it doesn't look likely, but worth checking.

sec33567:
Still not receiving the correct data, still getting "F4E5F3F4".

Then it sounds like the problem is with the PC - or a mismatch between the PC and the Arduino.

...R