I'm working on a project that uses RXTX and protobuf to communicate with an application on a development board and I've been running into issues which implies that I'm likely doing things the wrong way. Here's what I currently have for writing the request to the board (the read code is similar):
public void write(CableCommandRequest request, OutputStream out) {
CodedOutputStream outStream = CodedOutputStream.newInstance(out);
request.writeTo(outStreatm);
outStream.flush();
}
The following is the setting that are used to prepare the RXTX serial connection which in turn suplies the OutputStream
used by the write
command:
// The baud rate to use when connecting to the development board
private final static int BAUD_RATE = 115200;
// The timeout to use for the serial port
private final static int CONNECTION_TIMEOUT = 50;
// The serial break for the development board, 100
private final static int SERIAL_BREAK = 100;
// <SNIP> ...
SerialPort serialPort = (SerialPort)port.open(appName, CONNECTION_TIMEOUT);
serialPort.setSerialPortParams(BAUD_RATE,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
serialPort.sendBreak(SERIAL_BREAK);
The OutputStream
that is used is prepared by RXTX and the development board seems to indicate that data is being received, but it is getting garbled or is otherwise not being understood.
So far all of the usual suspects (e.g. serial connection not being established, communication issues, etc.) have been eliminated so it appears that the problem is in how the call to writeTo
is made since communications over the serial connection are successful.
There seems to be little documentation on using protobuf over a serial connection so I'm assuming that passing the OutputStream
should be sufficient. Is this in fact correct, or is this the wrong way of sending the response over the serial connection?