Error codes

 

The result error code (a 16 bit value) is composed by two fields, as in figure:

 

The first 8 bits (2 nibbles) represent a TCP/IP error. The last two nibbles represent an S7 protocol error

TCP Errors table

 

Mnemonic

HEX

Meaning

errTCPConnectionFailed

0x0001

TCP Connection error.

errTCPConnectionReset

0x0002

Connection reset by the peer.

errTCPDataRecvTout

0x0003

A timeout occurred waiting a reply.

errTCPDataSend

0x0004

Ethernet driver returned an error sending the data.

errTCPDataRecv

0x0005

Ethernet driver returned an error receiving the data.

errISOConnectionFailed

0x0006

ISO connection failed.

errISONegotiatingPDU

0x0007

ISO PDU negotiation failed.

errISOInvalidPDU

0x0008

Malformed PDU supplied.

 

S7 Errors table

 

Mnemonic

HEX

Meaning

errS7InvalidPDU

0x0100

Invalid PDU received.

errS7SendingPDU

0x0200

Error sending a PDU.

errS7DataRead 

0x0300

Error during data read

errS7DataWrite

0x0400

Error during data write

errS7Function 

0x0500

The PLC reported an error for this function.

errBufferTooSmall

0x0600

The buffer supplied is too small.

 

I made this division because in presence of a TCP error the Client should be disconnected and re-connected.

It’s easy knowing this by masking the Hi-byte of the error code.