We are using a JeVois camera for vision processing and the data is being sent to the roboRIO using serial over USB. When we connect the JeVois to out laptop, it sends the data fine with no lag or delay, but when it is hooked up to the roboRIO and we read it from that, there is always a few second delay. At this point, we are just setting up the serial connection, reading from it, and putting the value to the dashboard to see what it is. Our baud rate is at 115200, we set the read buffer size to 1, and the count parameter for the serial Read function is set to 4 because we expect to read a number that is at most 3 digits. Any help with this delay is appreciated.
I suspect your problem is waiting for the timeout on the serial port, when you read less than 4 bytes. Below is how we handle dynamic line lengths. It would be even more efficient to have a fixed size line, but be careful to never get out of sync.
We use this utility class: https://github.com/frc-862/Gemini2019/blob/svision/src/main/java/frc/lightning/util/SerialByLine.java to pump values into this subsystem https://github.com/frc-862/Gemini2019/blob/svision/src/main/java/frc/robot/subsystems/SimpleVision.java
Seems to work with very low latency, we are running against a 50fps vision loop.