Serial Monitor and Null terminator

When you write in the serial monitor, when you type a word for example hello does it have a null terminator?

bastjan:
When you write in the serial monitor, when you type a word for example hello does it have a null terminator?

No. The serial monitor sends just what you typed plus the "line ending" characters that you have set as an option in the serial monitor:

  • No line ending
  • Newline (Carriage Return, ASCII-13)
  • Linefeed character (ASCII-10)
  • Both characters (CR&LF)

Thanks for the reply buddy , do you know if a GSM return a null terminated string or just carriage return when he replies with "ok"

bastjan:
Thanks for the reply buddy , do you know if a GSM return a null terminated string or just carriage return when he replies with "ok"

No serial device sending ASCII-Codes should send ASCII-0 as the terminating character.

All serial devices that I know send CR or CR+LF as the line terminating code after sending one line of information.

The examples in Serial Input Basics may be helpful. The 2nd and 3rd examples add null characters at the end of the received message.

...R

Yes! Thanks for that article.

\0 is the null character for serial port.
that is backslash zero

jurs:
No. The serial monitor sends just what you typed plus the "line ending" characters that you have set as an option in the serial monitor:

  • No line ending
  • Newline (Carriage Return, ASCII-13)
  • Linefeed character (ASCII-10)
  • Both characters (CR&LF)

In the Serial Monitor of Arduino IDE, we have the following options at the line ending tab (Fig-1):
lineEnd.png
(1) No line ending: nothing is sent at the end of the message.
(2) Newline: ASCII Code 0x0A (for chatacter: '\n') is sent at the end of message.
(3) Carriage return : ASCII Code 0x0D (for charcater: '\r') is sent at the end of message.
(4) Both NL (ASCII Code: 0x0A) & CR (ASCII Code: 0x0D): 0x0D is sent first and then 0x0A at the end of message.

SerialMonitor.png
Figure-1:

SerialMonitor.png

lineEnd.png