for (int i = 0; i < message.length(); i++) {
char c = message.charAt(i);
String bereit = Integer.toHexString(c);
System.out.println(bereit);
byte[] send = bereit.getBytes();
connected.write(send);
//connected.write(abschluss);
}
As you see your write gets called every time for each character. That write calls:
mmOutStream.write(bytes);
I'm not sure, but could it be that every write gets closed with a \r? The '\r' is the carriage return (cr) which is indeed 0D in hex.
Or maybe it looks like your command is never understood because it doesn't receive the cr. Maybe it gives a timeout or something, because it keeps waiting for your cr?
Anyway, try to send a '\r' after your loop.
for (int i = 0; i < message.length(); i++) {
char c = message.charAt(i);
String bereit = Integer.toHexString(c);
System.out.println(bereit);
byte[] send = bereit.getBytes();
connected.write(send);
}
//Send your '\r' here.
PS: You say you need to write in hex to the OBD-II dongle? You might want to try that in ASCII, as most of the documentation is in ASCII and the ELM327 protocol understands ASCII.
Let me know your progress!