.esctype Property

Function:

Defines, for the selected serial port (selection is made through ser.num), whether serial escape sequence recognition is enabled and, if yes, what type of escape sequence is to be recognized.

Type:

Enum (pl_ser_esctype, byte)

Value Range:

  • 0 — PL_SER_ET_DISABLED (default): Recognition of serial escape sequences disabled.
  • 1 — PL_SER_ET_TYPE1: Escape sequences of type 1 are to be recognized.
  • 2 — PL_SER_ET_TYPE2: Escape sequences of type 2 are to be recognized.

See Also:

UART Mode, Serial Settings


Details

An escape sequence is a special occurrence of characters in the incoming data received by the serial port. Escape sequences are only recognized in the UART mode of operation (ser.mode = 0 — PL_SER_MODE_UART).

When an escape sequence is detected, the on_ser_esc event is generated and the serial port is disabled (ser.enabled = 0 — NO). When enabled, serial escape sequence detection works even when buffer shorting is employed (see ser.redir property). Below, we explain the two types of escape sequences.


Type 1

The type 1 escape sequence consists of three consecutive escape characters (the ASCII code of the escape character is defined by the ser.escchar property). For the escape sequence to be recognized, each of the escape characters must be preceded by a time gap of at least 100ms:

...previous data<--100ms-->E.C.<--100ms-->E.C.<--100ms-->E.C.

If the time gap before a certain escape character exceeds 100ms, then this character is considered to be a part of the escape sequence and is not recorded into the RX buffer. If the time gap before a certain escape character is less than 100ms, than this character is considered to be a normal data character and is saved into the RX buffer. Additionally, the escape character counter is reset and the escape sequence must be started again. The following example illustrates one important point (escape characters are shown as "<"). Suppose the serial port receives the following string:

ABC<--100ms--><<--100ms--><<DE

The first two escape characters is this example had correct time gap before them, so they were counted as a part of the escape sequence and not saved into the buffer. The third escape character did not have the correct time gap, so it was interpreted as a data character and saved into the buffer. The following was recorded into the RX buffer:

ABC<DE

The side effect and the point this example illustrates is that the first two escape characters were lost — they neither became a part of a successful escape sequence (because this sequence wasn't completed), nor were they saved into the buffer.


Type 2

A type 2 escape sequence is not based on any timing. The escape sequence consists of an escape character (defined by the ser.escchar property) followed by any character other than the escape character. To receive a data character whose ASCII code matches that of the escape character, the serial port must get this character twice. This will result in a single character being recorded into the RX buffer.

The following sequence will be recognized as an escape sequence (that is, if the current escape character is not "D"):

ABC<D

In the sequence below, two consecutive escape characters will be interpreted as data (data recorded to the RX buffer will contain only one such character):

ABC<<


.esctype Property

Details

Type 1

Type 2