MyEclipse: Display the Data from RS232 Com1 port in the console in Hex arunsny - Feb 01, 2012 - 12:29 PM Post subject: Display the Data from RS232 Com1 port in the console in Hex
Hallo Friends,
I have a program in which i'm trying to view the data read from the RS232 COM1 port in the console of myeclipse. I have already run the program but it is showing some rubbish values may be in ASCII as shown in the screen shot.
Can any one please help me how i can display the values in Hexadecimal or other readable format. It would be of great help.
/*
* Serial Write Method
*/
public static void write(String toPort) {
try {
serialPort.openPort();//Open serial port
serialPort.setParams(SerialPort.BAUDRATE_57600,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);//Set params. Also you can set params by this string: serialPort.setParams(9600, 8, 1, 0);
serialPort.writeBytes(toPort.getBytes());//Write data to port
serialPort.closePort();//Close serial port
System.out.println("Writing Successful");
}
catch (SerialPortException ex) {
System.out.println(ex);
}
}
/*
* Serial dataIn byte to string conversion Method
*/
public static String getString(byte[] b) throws UnsupportedEncodingException {
String result = "";
for (int i=0; i < b.length; i++) {
result += (char)b[i];
}
return result;
}
}
looking forward to hear from you.
Best regards
Arunsupport-joy - Feb 03, 2012 - 11:49 AM Post subject:
Arun,
Have you tried to run your application in debug mode? Your issue is related to development. I would recommend you cross-post on relevant forums.