visdde.txt

来自「对做的MODBUSRTU的同志很有用,在PC机上模拟对应的MODBUSRTU主机」· 文本 代码 · 共 44 行

TXT
44
字号
Visual Basic DDE and Mdbus

The following demonstrates the procedure to obtain coil data from mdbus 
or have mdbus send a coil command in Master Mode or set its internal data 
in Slave Mode.  The DDE section of Mdbus details the DDE procedure for the 
other data types.

1. To obtain Coil Data from Mdbus

Under program control, the following code will bring back coil data from 
coils 1,2 and place the data into textbox text1.  The different coil data 
will be seperated by commas.

text1.linktopic="mdbus|poke"
text1.linkitem="coil 0001 2"
text1.linkmode=2
text1.linkrequest

Alternately, the properties of text1 could be set as follows:

set link topic to mdbus|poke
set linkitem to coil 0001 2
set linkmode to 2

Then under program control, execute the statement text1.linkrequest

2.  To turn a coil on or off with Mdbus

Under program control, the following code will take the data in 
textbox text1 (either 0 or 1) and send it to coil 1.

text1.linktopic="mdbus|poke"
text1.linkitem="coil 0001"
text1.linkmode=2
text1.linkpoke

Alternately, the properties of text1 could be set as follows:

set link topic to mdbus|poke
set linkitem to coil 0001
set linkmode to 2

Then under program control, execute the statement text1.linkpoke

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?