I am fairly new to Java, but with a rather complicated question.
We are looking at reading some bytes coming in from an Arduino. The Arduino sends bytes in the form:
Serial.print(Voltage1);
Serial.print(voltage2);
Since these voltages are numbers of the format "1.62", two digits after the decimal point, the Arduino sends 8 bytes, 4 for each voltage.
Previously in a MATLAB test we managed that by making the inputbuffer=8, and then splitting the bytes by doing something of the sort A=buffer(1:4) B=buffer(5:8), and as such we could plot or read the signals from the Arduino.
Is there a way to achieve this in Java? At the moment we are creating an input stream, and we tried to limit that to a buffer of the correct size, but we do not get anything even close to the expected. Most of the time our input from inputstream.read() gives us negatives, but not even something that we can understand or work with.
I hope this is well explained, and I really wish someone knows how to deal with this problem.