FAQ
Cover
\
Build
\
Source
\
Bugs
\
Reference
\
Libraries
\
Tools
The bugs database has moved
here
.
Bug 574 : Serial com.write(String) Not working with char (-127 ...)
Last modified: 2008-06-11 08:24
P
roject:
processing
trash
Version:
unspecified
Co
m
ponent:
android
book
core
libraries
pde
reference
tools
web
Status:
RESOLVED
Resolution:
INVALID -
Pr
i
ority:
P2
Severity:
normal
Platform
All
O
S:
All
Windows
Mac OS
Linux
Other
Reporter:
gll
Assigned To:
fry
Attachment
Type
Created
Size
Actions
Description
: Opened: 2007-05-27 16:27
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
***
Bug 575
has been marked as a duplicate of this bug. ***
Additional Comment
#2 From fry 2008-06-11 08:23
***
Bug 576
has been marked as a duplicate of this bug. ***
Additional Comment
#3 From fry 2008-06-11 08:24
sending chars will be subject to the conversion depending on what your
platform is using. send bytes instead.