Send Hex 0 to the serial port

Hello
The print command does not send hex 0(null) over the Serial port.
What do I wrong?

Thanks for helping
Uli

 Serial.write(12);                        // <Clear Display> /  works OK
 Serial.print("\x1B" "O" "\x5" "\x1");    // <Set Cursor> /  works OK
 Serial.print("Hallo Uli"); 
 
// ---- Begin hide Cursor ----    works OK
 Serial.write(27);  // ESC
 Serial.write(67);  // Char O 
 Serial.write(0);   // Hex 0
// ---- End hide Cursor ---- 

Serial.print("\x1B" "\x67" "\x0"); // <hide Cursor>  "\x0"   > Hex 0 ignored
Serial.print("\x1B" "C" "\x0");    // <hide Cursor>  "\x0"   > Hex 0 ignored

Is "\x0" being interpreted as the end of string marker ?

Serial.write() sends binary data Serial.print() sends ASCII text

Yes it is.

Hello What do you mean with "Yes it is."?

Thank you Uli

I mean: “\x0” being interpreted as the end of string marker

Serial.print("\x1B" "\x67" "\x0"); // <hide Cursor>  "\x0"   > Hex 0 ignored

C strings already have 0x00 at the end of them, so adding your own doesn’t help.

You would need to do something like:

Serial.print("\x1B" "\x67"); // <hide Cursor>  
Serial.write (0);

I think .write(char *, int) will send the number of characters specified by 'int'. You can use it like this:

Serial.write("\x1B" "\x67" "\x0", 3);
Serial.write("\x1B" "C" "\x0", 3);

// Equivalent to:
Serial.write("\x1B\x67\x0", 3);
Serial.write("\x1BC\x0", 3);

The end of a C style string, normally held in an array of chars, is marked by a zero. Hence when Serial.print() outputs the "\x1B" "C" "\x0" it stops when it comes to the "\0" and does not output it because as far as it is concerned the end of the string has been reached.

Serial.write() outputs binary data so it does output the zero.

Hello Helpers

Thanks for all informations. I understand now the syntax.