I'm trying to send a string to the serial port using a DataOutputStream. However when using writeChars(string s) it sends the characters as a series of two byte chars, filling the space with a null char.
I have looked at a direct dump from the device connected to the serial port, I'm trying to send the string "! 200 200 600 1" and the device is receiving char(00)char(21)char(00)char(20)char(00)char(30)ch ar(00)char(20)char(00)char(32)... instead of simply char(21)char(20)char(30)char(20)char(32)... I think the char(00) is a result of writeChars trying to send char(0x21) where I just want it to send char(\x21) i.e.the single byte value.
Thanks for replying, I figured it out anyway - I'm coverting the string to bytes using String.getBytes(); and then using write(byte, 0, byte.length); to write the entire string to the DataOutputStream.
Not sure if its the best/easiest way, but it got rid of all the char(00) which is the main thing!