Go Down

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


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!


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.


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)


<smacks forehead>

Thanks, guys! Working like a champ now.

Go Up

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it's been approved by a moderator.

shortcuts: alt+s submit/post or alt+p preview