in the twowaycommuncation class, you can do something like this in that if statement:
if ( commPort instanceof SerialPort )
{
SerialPort serialPort = (SerialPort) commPort;
serialPort.setSerialPortParams(115200,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);
InputStream in = serialPort.getInputStream();
OutputStream out = serialPort.getOutputStream();
out1=out; //add this line, where out1 is a global variable//
(new Thread(new SerialReader(in))).start();
(new Thread(new SerialWriter(out))).start();
}
then from anywhere in this class you send a string like this:
public void writetoport(String send) {
try {
out1.write(send.getBytes());
out1.flush();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
or whatever way you want to do.
so now you can send strings you have defined in you code or by inputting it in the console.