I receive through the serial an ascii value used to display the rpm value of an encoder, I am trying to convert these values to an int but I am having a problem with some values, the following error returns me sometimes java.lang.NumberFormatException: Invalid int: "2"
public void run() {
byte[] rpm = (read.getBytes(StandardCharsets.US_ASCII));
if(rpm.length >=12) {
char ch0 = (char) rpm[9];
char ch1 = (char) rpm[10];
String s = new StringBuilder().append(ch0).append(ch1).toString();
a = Integer.parseInt(s,16);
the log for values ch0 and ch1