Pages: [1]   Go Down
Author Topic: Octal character constants in NewSoftSerial.print?  (Read 382 times)
0 Members and 1 Guest are viewing this topic.
Arlington, MA, USA
Offline Offline
Sr. Member
****
Karma: 0
Posts: 259
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 106
Posts: 6374
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 170
Posts: 12465
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

Rob Tillaart

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

Arlington, MA, USA
Offline Offline
Sr. Member
****
Karma: 0
Posts: 259
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Doh!
<smacks forehead>

Thanks, guys! Working like a champ now.
Logged

Pages: [1]   Go Up
Jump to: