Ser.Esctype Property

Top  Previous  Next

 

Function:

Defines, for 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 recognised.

Type:

Enum (pl_ser_esctype, byte)

Value Range:

0- PL_SER_ET_DISABLED (disabled): 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

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 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 the buffer shorting is employed (see ser.redir property).

Follows is the description of two escape sequence types:

 

Type 1Type1 escape sequence consists of three consecutive escape characters (ASCII code of 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, 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 <). Supposing the serial port receives the following string:

 

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

 

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 a 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 first two escape characters were lost — they neither became a part of a successful escape sequence (because this sequence wasn't completed), nor were saved into the buffer.

 

 

Type 2Type 2 escape sequence is not based on any timing. Escape sequence consists of escape character (defined by the ser.escchar property) followed by any character other than escape character. To receive a data character whose ASCII code matches that of 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 escape sequence (that is, if 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<<