beautypg.com

A.1.5 error- checking code, Using the non-intelligent terminal protocol – Siemens SIMATIC TIWAY 1 User Manual

Page 180

background image

USING THE NON-INTELLIGENT TERMINAL PROTOCOL

UNILINK HOST ADAPTER

A-4

USER MANUAL

A.1.5

Error-Checking Code

Following the message body is an ASCII four-character error-checking code
(ECC) in the form of a 16-bit hexadecimal number that is included at the end of
the message just before the semicolon terminator. The ECC is a checksum
computed by both the sending and receiving stations as follows:

1.

Divide the character count and the message body into blocks of four
characters, left-justified and zero-filled. The beginning and ending
delimiters are not included in the calculation.

2.

Treat each block as a four-digit hexadecimal number.

3.

Sum the resulting numbers (blocks).

4.

Take the two’s complement of the sum to get the ECC.

As an example, consider a message whose body is the CONFIGURE ADAPTER
command:

20

32

30

01

30

31

00

30

30

02

30

32

02

30

32

00

30

30

0E

30

45

ASCII
Codes

The total character count is found by adding together the number of characters
in the message, the four characters for the ECC, the four characters for the
character count, and the two characters used to delimit the message. Thus, the
total character count for a message containing “2001000202000E” is

Starting Delimiter –
Character Count –
Message Body – 2001000202000
Error–checking Code
Ending Delimiter –

Total Character Count

* Numbers in parentheses are the corresponding
decimal values.

:
?
E
?
;

=
=
=
=
=

01
04

0E

04
01

(1)*
(4)
(14)
(4)
(1)

0018 (24)