View Single Post
  #5   Spotlight this post!  
Unread 14-03-2011, 10:08
drakesword drakesword is offline
Registered User
AKA: Bryant
FRC #0346 (Robohawks)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2004
Location: USA
Posts: 200
drakesword is on a distinguished road
Re: Reading characters from socket wierdness

Sure

On the robot.
Code:
*snip*
client = scn.acceptAndOpen();
reader = new BufferedReader(new InputStreamReader(client.openInputStream()));
*snip*
char[] data = reader.readLine().toCharArray();

for(lcv = 0; lcv < dat.length; lcv++)
{
    System.out.print((int)data[lcv] + " ");
}
System.out.println();

On the computer

Code:
*snip*
out = new BufferedWriter(new OutputStreamWriter(out.getOutputStream()));
*snip*
out.write(new char[]{1,2,3,100,150,180});
out.write("\n");
out.flush();
So I am sending 1 2 3 100 150 180
robot reports it is receiving 1 2 3 100 194 150 194 180

Even larger numbers have other strangeness with them. Sent a 200 and the robot received a 131 199
Reply With Quote