hello
im using a PIC to transmit 5 HEX numbers. I see my results displayed very nicely on a PC terminal program. Im not using hyperterminal but instead another thrid party terminal program which allows you to view binary information via serial port. This terminal program is called "SuperMon Serial Ver 5.5".
Now after the successfull test with the above, i then wrote my own JAVA program and used the RXTX package to use the serial port with JAVA language. Sadly now when I power up the PIC i do not get any thing displayed in my window. Interstingly my JAVA program compiles but is not displaying anything!
Also interestingly is the fact that if I send ASCII characters from the PIC 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. Please can someone look at it and kindly suggest why can i not print the HEX numbers on screen.
im using a PIC to transmit 5 HEX numbers. I see my results displayed very nicely on a PC terminal program. Im not using hyperterminal but instead another thrid party terminal program which allows you to view binary information via serial port. This terminal program is called "SuperMon Serial Ver 5.5".
Now after the successfull test with the above, i then wrote my own JAVA program and used the RXTX package to use the serial port with JAVA language. Sadly now when I power up the PIC i do not get any thing displayed in my window. Interstingly my JAVA program compiles but is not displaying anything!
Also interestingly is the fact that if I send ASCII characters from the PIC 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. Please can someone look at it and kindly suggest why can i not print the HEX numbers on screen.
Code:
public void serialEvent(SerialPortEvent event) //listens to incoming data from serial port
{
switch (event.getEventType()) //receiving data from serial port
{
case SerialPortEvent.DATA_AVAILABLE:
// instantiating and initiallizing receiving byte[] array
byte[] readBuffer = new byte[8];
try
{
// read data and place in byte[]
while (inputStream.available() > 0)
{
int numBytes = inputStream.read(readBuffer);
}
//If the below numbers are received then print on screen
if(readBuffer[0] == 0x61 &&
readBuffer[1] == 0x78 &&
readBuffer[2] == 0x79 &&
readBuffer[3] == 0x7A &&
readBuffer[4] == 0xAB )
{
System.out.println(readBuffer[0]);
System.out.println(readBuffer[1]);
System.out.println(readBuffer[2]);
System.out.println(readBuffer[3]);
System.out.println(readBuffer[4]);
}
}
catch (IOException e)
{}
break;
}
} //end of serialEvent()