Bug 575 : Serial com.write(String) Not working with char (-127 ...)
Last modified: 2008-06-11 08:23




Status:
RESOLVED
Resolution:
DUPLICATE of bug 574
Priority:
P2
Severity:
normal

 

Reporter:
gll
Assigned To:
fry

Attachment Type Created Size Actions

Description:   Opened: 2007-05-27 16:29
It seems that the conversion between String to Bytes is not accurate inside
the serial Library. When I convert the String to a Byte[], it works fine,
but using String with char as char a = (char)129 --> 0x39 is sent (?)

Could it be a problem with Java to C unsigned conversion?

It has been tested on windows XP with arduino on P5v124.
Serial Lib is dated: 04-02-2007

[code]
////////////////////////
String s;

for(byte i=0; i<50; i++)
s += (char)(i+124);

com.write(s);

(input s) --> |}~?�???????????�?��????????????�?? ¡¢£¤¥¦§¨©ª«¬­
(output)---> |}~???????????????????????????????? ¡¢£¤¥¦§¨©ª«¬­



////////////////////////
////////////////////////
String s;

for(byte i=0; i<50; i++)
s += (char)(i+124);

for(int i=0; i<s.length(); i++)
com.write((byte)s.charAt(i));



(input bytes) --> |}~?�???????????�?��????????????�?? ¡¢£¤¥¦§¨©ª«¬­­
(output)---> |}~?�???????????�?��????????????�?? ¡¢£¤¥¦§¨©ª«¬­
[/code]
Additional Comment #1 From fry 2008-06-11 08:23


*** This bug has been marked as a duplicate of 574 ***