Tuesday, May 1, 2012

[android-developers] Re: To write array data to serial port in ascii

In the first array you are using characters i.e. actual ascii.  In the second you are using integer values which are not equivalent to ascii values so if you actually want to see "10" show up on your screen and not the ascii value for byte 10 then you would have to send it as {49, 48}


On Wednesday, April 4, 2012 7:58:41 AM UTC-4, srinivasan shanmugam wrote:
Dear All,

As am new to this Java/android development, I'm using Android device to transmit array data.  I want  my results to be displayed on a PC terminal program using hyper terminal.   

 If I send ASCII characters such as 'a' 'b' 'c' 'd' ... etc, then my JAVA program displays those characters on screen with out any problem.  So i know that my JAVA program does receive from the serial port and does work... but only for ASCII characters though. 

Below is the code snippet of the JAVA code which actually receives data via serial port and displays it on screen when declared array as character by character.  

public final static byte[] buffer_RFID = {'A','D','4','9','8','6','5','2','3'};


try {
mOutputStream.write(buffer_RFID,0,buffer_RFID.length);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

But when I declare the array as below am not able to see the values as 10, 20, 30, 40 in the hyperterminal through serial port

public final static byte[] buffer_RFID = {10,20,30,40};

 try {
mOutputStream.write(buffer_RFID,0,buffer_RFID.length);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Please can someone look at it and kindly suggest why can i not print the ASCII values on screen, could any body please suggest me with any corrections to be done in the above code so that what ever the array contents gets displayed as it is in hyper terminal through serial port


Any help would be greatly appreciated


Advanced thanks,
Srinivasan S

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment