I am making an application that works with serial port. The problem is that the device I am controlling receive unsigned bytes range and as I saw java only accepts signed bytes range.
I have googled how to send, but I only got how to receive unsigned bytes.
Thanks EDIT 2: Fix proposed by @durandal to my code to receive:
public void serialEvent(SerialPortEvent event) {
switch (event.getEventType()) {
case SerialPortEvent.DATA_AVAILABLE: {
System.out.println("Datos disponibles");
try {
int b;
int disponibles = input.available();
byte[] rawData = new byte[disponibles];
int count = 0;
while ((b = input.read()) != -1) {
if (count == disponibles - 1) {
break;
}
rawData[count] = (byte) b;
count++;
}
serial.serialDataReceived(bytesToHex(rawData), rawData);
} catch (IOException ex) {
Logger.getLogger(PuertoSerie.class.getName()).log(Level.SEVERE, null, ex);
}
}
break;
}