Go Down

Topic: Octal character constants in NewSoftSerial.print? (Read 550 times) previous topic - next topic

tastewar

I'm trying to send a string containing some control characters via a NewSoftSerial port. A snippet of my code looks like this:

    bbPort.print ( "\000\000\000\000\000\001Z00\002A0\033 t" );
    bbPort.print ( "Date: " );
...
    bbPort.print ( "\004" );

I see the string "Date: ", a bunch of stuff after that, and I see the \004 come through on the serial port I'm connected to. But I see none of the characters from the first line. What have I neglected?

Thanks for any help!
--Tom

westfw

You're not going to be able to send null (zero) characters by including them in a C-like string.  The \000 will be interpretted as the end-of-string by the print function.

robtillaart

maybe try single quote send them as char?
- bbPort.print ( '\000' ); 
- bbPort.print ( '\004' ); 

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

tastewar

Doh!
<smacks forehead>

Thanks, guys! Working like a champ now.

Go Up