Hi. First, thanks for this great resource. I have a project I am working on that requires multiple read/write operations in a very short time. Right now, I can't achieve the performance I want due to the length of time it takes to open the port and then set the parameters like so:
ubxPort.openPort(50);
ubxPort.setComPortParameters(115200, 8, 1, 0);
ubxPort.setFlowControl(0);
out.write(command.getBytes());
out.flush();
out.close();
ubxPort.setComPortTimeouts(SerialPort.TIMEOUT_READ_SEMI_BLOCKING, 50, 0);
InputStream in =ubxPort.getInputStream(); // Read input from PLC device
byte[] newData = new byte[ubxPort.bytesAvailable()];
int numRead = ubxPort.readBytes(newData, newData.length);
response = new String(newData, "UTF-8");
System.out.println(response);
ubxPort.closePort();
My data returned is small. It's like "OK,1" or "ERROR". Very basic text strings.
I found the documentation about openPort() and setting that timeout and that helped quite a bit, but I am wondering if there are other tuning opportunities I can use to speed it up further. FYI, my app dispenses water, and when my delay to turn a valve off is 1/2 second, I still get quite a bit of water after clicking a button. One thought I had was to open the port and set parameters globally when the app launches but I have thus far been unsuccessful in that approach.
I appreciate any insight or suggestions you might be able to offer.
Hi. First, thanks for this great resource. I have a project I am working on that requires multiple read/write operations in a very short time. Right now, I can't achieve the performance I want due to the length of time it takes to open the port and then set the parameters like so:
ubxPort.openPort(50);
ubxPort.setComPortParameters(115200, 8, 1, 0);
ubxPort.setFlowControl(0);
out.write(command.getBytes());
out.flush();
out.close();
ubxPort.setComPortTimeouts(SerialPort.TIMEOUT_READ_SEMI_BLOCKING, 50, 0);
InputStream in =ubxPort.getInputStream(); // Read input from PLC device
byte[] newData = new byte[ubxPort.bytesAvailable()];
int numRead = ubxPort.readBytes(newData, newData.length);
response = new String(newData, "UTF-8");
System.out.println(response);
ubxPort.closePort();
My data returned is small. It's like "OK,1" or "ERROR". Very basic text strings.
I found the documentation about openPort() and setting that timeout and that helped quite a bit, but I am wondering if there are other tuning opportunities I can use to speed it up further. FYI, my app dispenses water, and when my delay to turn a valve off is 1/2 second, I still get quite a bit of water after clicking a button. One thought I had was to open the port and set parameters globally when the app launches but I have thus far been unsuccessful in that approach.
I appreciate any insight or suggestions you might be able to offer.