cancel
Showing results for 
Search instead for 
Did you mean: 

PCO Socket agent hex characters

pieter_conradie2
Explorer
0 Kudos

Dear Forum,

I have a requirement to connect to a plant PLC using a socket connection in SAP PCO to extract batching weights for produced product. To communicate with the PLC different strings need to be sent to it to get these results back. A typical wake-up string template would be "SYN(16) SYN(16) ENQ(05) ID# ID# EOT(04)" which will return "SYN(16) ACK(06) Status Code EOT(04) CR(0D)". (Hex in brackets)

I have successfully connected to the PLC via the socket agent, but when sending the wake-up string from MII to PCO it results in error:

Message sent - CALL SEND(address='nnn.nn.n.nn', port='7000', message='\16\16\05 0115AF\04');

Error received - Query execution failed due to following:

[Tag] : Exception [TokenizerException] - Token error (Invalid Escape Character), at location 55, expected tokens [String,Double,Long,Time].

rt='7000', message='                     \16\16\05 0115AF\04'                    ^

The question is: How do I escape the control characters in the message to get a successful transmission?

SAP MII version 15.0 SP3 Patch 0

SAP PCO version 2.3 SP4

Accepted Solutions (1)

Accepted Solutions (1)

pieter_conradie2
Explorer
0 Kudos

Resolved it myself. Control charters should be sent in the following format:

Text string:     <16><16><05> 011AF<04>

Hex string:     &#22;&#22;&#05; 011AF&#04;

Answers (2)

Answers (2)

former_member196557
Active Contributor
0 Kudos

Hi Pieter,

Use an additional backslash character (\) to escape each backslash character.  I have tested this with PCo 2.305.2141.1051 and it works correctly:

CALL SEND(address='127.0.0.1', port='20000', message='\\16\\16\\05 0115AF\\04');

Just curious, which PLC model are you connecting to?

Regards, Steve

pieter_conradie2
Explorer
0 Kudos

Hi Steve,

Thank you for the reply. Padding the string with the additional escape character did resolve the error in PCo, but sniffing the data packet revealed that the string no contained the second "\" character. Thus not sending the string as control characters.

Just to eliminate any other errors, I patch PCo to 2.305.2177.1541

Any other thoughts?

I am connecting to a niche application used for batching a product. It uses the modified BISYNC protocol on TCP/IP socket connection

Regards, Pieter

former_member196557
Active Contributor
0 Kudos

HI Pieter,

Let me do some checking internally.

Regards, Steve

manishagb
Explorer
0 Kudos

Hi Pieter,

try to encode the message string before sending. It wont accept something with <space>.

Regards,

Manisha