使用搜索功能查看 Kepware 的信息库,其中包含 500 多篇知识库文章。缩小搜索结果范围,或在下面的搜索字段中输入您的查询。

或者,如果您无法找到解决方案,我们还有另一个资源:我们的 PTC eSupport Portal。 如果系统提示您登录 eSupport Portal,您可以使用“我的 Kepware”凭据。需要一个“我的 Kepware”帐户吗?在此处创建

搜索解决方案结果:
View All Solutions

Kepware Knowledge Base: Solution


Updating a Tag With a Specific String When the Device Returns an Integer Value in a Tag


Last Update: 2018/11/12

The following pseudo code shows how to configure a read transaction to enumerate a response from a device. It is assumed that the device uses a binary protocol, and that the responded data is a byte with a hex value of 0x00 to 0x03. The tag name is "Message". The tag properties are selected in the U-CON Transaction Editor, and not in the main server window. They are as follows:

1. The data type is String.

2. Format ASCII String [ccc...]. Then, click Format properties... and select the following:

  • Not fixed length
  • Do not parse to next delimiter
  • Read up to 0 bytes from frame end

Step, Command, Value/Format, Description
1, Write Character, 2 0x02 STX, Start Byte
2, Write DeviceID, 8 Bit Intel Hi,
3, Write Character, 42 0x2A *, Read Data Command
4, Write Character, 33 0x21 !, Data Address
5, Write Character, 3 0x03 ETX, End Byte
6, Transmit
7, Read Response, Wait For 5 Bytes, Read data from PLC
8, Test Character, 0 0x00 Null, GoTo Val_0 if True Continue if False
9, Test Character, 1 0x01 SOH, GoTo Val_1 if True Continue if False
10, Test Character, 2 0x02 STX, GoTo Val_2 if True Continue if False
11, Test Character, 3 0x03 ETX, GoTo Val_3 if True GoTo Bad_Data if False
12, Label, Val_0, N/A,
13, Write String, Value is 0, Sample string for enumeration Data destination, Scratch Buffer, 2,
14, Update Tag, Message Data Source, Scratch Buffer, 2, Start Byte 1
15, End, End transaction so process pointer does not fall through to next line
16, Label, Val_1, N/A,
17, Write String, Value is 1, Sample string for enumeration Data destination, Scratch Buffer, 2,
18, Update Tag, Message Data Source, Scratch Buffer, 2, Start Byte 1
19, End, End transaction so process pointer does not fall through to next line
20, Label, Val_2, N/A,
21, Write String, Value is 2, Sample string for enumeration Data destination, Scratch Buffer, 2,
22, Update Tag, Message Data Source, Scratch Buffer, 2, Start Byte 1
23, End, End transaction so process pointer does not fall through to next line
24, Label, Val_3, N/A,
25, Write String, Value is 3, Sample string for enumeration Data destination, Scratch Buffer, 2,
26, Update Tag, Message Data Source, Scratch Buffer, 2, Start Byte 1
27, End, End transaction so process pointer does not fall through to next line
28, Label, Bad_Data, N/A,
29, Log Event, Invalid message value received., Log a message to the server event log.
30, End, End transaction

Note: The Write String Command's "Data Destination" option was added in KEPServerEX version 4.200.353.