1

I'm working on an RS485 project, In the CPP file there are const variables declared in the following manner:

#include <RS485_protocol.h>
const byte STX = '\2'; 
const byte ETX = '\3';

What does the '\2' and '\3' mean?

MichaelT
  • 887
  • 3
  • 8
  • 21
mjrleap
  • 11
  • 2

1 Answers1

1

The '\2' and '\3' are characters with octal code 2 and 3. Which is nothing more then 2 and 3 in octal and in decimal. The author could simply write const byte STX = 2; const byte ETX = 3;.

Characters with ASCII code 2 and 3 are control characters STX (start of text) and ETX (end of text). Control characters are invisible characters used to control the terminal or as mark characters in communication.

Juraj
  • 18,037
  • 4
  • 29
  • 49
  • Perhaps the question is more about the '' than the 2 and 3. A list is here: https://en.cppreference.com/w/cpp/language/escape – Jot Nov 17 '18 at 15:43