I have been trying to send just a character to arduino using java gnu.io library.It can read data from the serial port sent by the arduino but cant send data to the serial port.Here is my code where I am trying to send ana receive data
public synchronized void serialEvent(SerialPortEvent oEvent) {
System.out.println("Event Listener Started");
if (oEvent.getEventType() == SerialPortEvent.OUTPUT_BUFFER_EMPTY) {
System.out.println("Sending Data");
try {
char ch = 'P';
output.print(ch);
output.flush();
} catch (Exception e) {
System.err.println(e.toString());
}
}
else if (oEvent.getEventType() == SerialPortEvent.DATA_AVAILABLE) {
System.out.println("Received Data");
try {
String inputLine = input.readLine();
System.out.println(inputLine);
} catch (Exception e) {
System.err.println(e.toString());
}
}
}
Here output is a printstream object;Other codes are just like the code I found in the following link http://playground.arduino.cc/Interfacing/Java#.UyWijKiSweg Any suggestion would be very helpful.