Hi Zhefu,
If you look at the difference between the example Koyo1.cmd startup script between R1-2 and R2-9 you will see the following. For simplicity I have removed the commented out lines that relate to serial RTU and serial ASCII since those don't apply to you.
*******************************************
corvette:modbus/iocBoot/iocTest>git diff -U9 R1-2 R2-9 Koyo1.cmd
diff --git a/iocBoot/iocTest/Koyo1.cmd b/iocBoot/iocTest/Koyo1.cmd
index 7a9d0f4..7434046 100755
--- a/iocBoot/iocTest/Koyo1.cmd
+++ b/iocBoot/iocTest/Koyo1.cmd
@@ -3,91 +3,94 @@
dbLoadDatabase("../../dbd/modbus.dbd")
modbus_registerRecordDeviceDriver(pdbbase)
# Use the following commands for TCP/IP
#drvAsynIPPortConfigure(const char *portName,
# const char *hostInfo,
# unsigned int priority,
# int noAutoConnect,
# int noProcessEos);
-drvAsynIPPortConfigure("Koyo1","164.54.160.158:502",0,1,1)
+drvAsynIPPortConfigure("Koyo1","164.54.160.158:502",0,0,1)
#modbusInterposeConfig(const char *portName,
-# int slaveAddress,
# modbusLinkType linkType,
-# int timeoutMsec)
-modbusInterposeConfig("Koyo1",0,0,5000)
+# int timeoutMsec,
+# int writeDelayMsec)
+modbusInterposeConfig("Koyo1",0,5000,0)
# NOTE: We use octal numbers for the start address and length (leading zeros)
# to be consistent with the PLC nomenclature. This is optional, decimal
# numbers (no leading zero) or hex numbers can also be used.
+# In these examples we are using slave address 0 (number after "Koyo1").
# The DL205 has bit access to the Xn inputs at Modbus offset 4000 (octal)
# Read 32 bits (X0-X37). Function code=2.
-drvModbusAsynConfigure("K1_Xn_Bit", "Koyo1", 2, 04000, 040, 0, 100, "Koyo")
+drvModbusAsynConfigure("K1_Xn_Bit", "Koyo1", 0, 2, 04000, 040, 0, 100, "Koyo")
*******************************************
So the differences are:
- In the drvAsynIPPortConfigure command in R1-2 the noAutoConnect flag was set. This should not be set in R2-9, so you should change this:
drvAsynIPPortConfigure("Koyo3R", "192.168.1.241:502",0,1,1)
to this:
drvAsynIPPortConfigure("Koyo3R", "192.168.1.241:502",0,0,1)
- The arguments to modbusInterfaceConfigure were changed from this in R1-2:
modbusInterposeConfig(const char *portName,
int slaveAddress,
modbusLinkType linkType,
int timeoutMsec)
to this in R2-9:
modbusInterposeConfig(const char *portName,
modbusLinkType linkType,
int timeoutMsec
int writeDelayMsec)
So you should change this:
modbusInterposeConfig("Koyo3R",2,0,2000)
to this:
modbusInterposeConfig("Koyo3R",0,2000,0)
- Finally the drvModbusAsynConfigure command has changed from this in R1-2:
drvModbusAsynConfigure(portName,
tcpPortName,
modbusFunction,
modbusStartAddress,
modbusLength,
dataType,
pollMsec,
plcType);
to this in R2-9:
drvModbusAsynConfigure(portName,
tcpPortName,
slaveAddress,
modbusFunction,
modbusStartAddress,
modbusLength,
dataType,
pollMsec,
plcType);
This means that the slaveAddress argument has moved from the modbusInterposeConfig function to the drvModbusAsynConfigure function.
Since you were previously using slaveAddress=0 in modbusInterposeConfig, you should now use slaveAddress=0 in drvModbusAsynConfigure. Thus you should change this:
drvModbusAsynConfigure("RD3R", "Koyo3R", 3, 0, 95, 0, 1160, "rpDevice")
to this:
drvModbusAsynConfigure("RD3R", "Koyo3R", 0, 3, 0, 95, 0, 1160, "rpDevice")
Mark
________________________________
From: [email protected] <[email protected]> on behalf of lzf neu <[email protected]>
Sent: Wednesday, January 24, 2018 2:00 AM
To: [email protected]
Subject: Question about communications based on modbus tcp.
Hi,
There are radiation dose monitor devices by using modbus tcp protocol to communicate.
The communications have succeeded to establish by using epics 3.14.12.5, modbusR1-2 combined with asynR4-9 (very old version) many years ago.
Therefore, I want to upgrade to the latest program by using modbusR2-9 combined with asynR4-30 and epics 3.14.12.5.
My settings are the same as the old version of modbusR1-2 in start.cmd file:
drvAsynIPPortConfigure("Koyo3R", "192.168.1.241:502",0,1,1)
modbusInterposeConfig("Koyo3R", 2,0,2000)
drvModbusAsynConfigure("RD3R", "Koyo3R", 3, 0, 95, 0, 1160, "rpDevice") # modbusR1-2 version
I noticed that there was a little difference of parameter settings in the command drvModbusAsynConfigure of new version (modbusR2-9). The manual says :"For TCP the slave address is used for the "unit identifier", the last field in the MBAP header.", and the last field in the MBAP header, as i know, is the slave address (ranging from 1 to 247). So, i randomly set:
drvModbusAsynConfigure("RD3R", "Koyo3R", 111, 3, 0, 95, 0, 1160, "rpDevice") # modbusR2-9 version, I randomly set 111
or:
drvModbusAsynConfigure("RD3R", "Koyo3R", 0xFF, 3, 0, 95, 0, 1160, "rpDevice") # use 0xFF to disable the parameter
however, I cannot establish the communications by using the new version of modbus and I have no idea how to do.
The error messages are as follows:
epics> 2018/01/24 15:19:26.062 drvModbusAsyn::doModbusIO port RD3R is disconnected
2018/01/24 15:19:30.069 drvModbusAsyn::doModbusIO port RD3R error calling writeRead, error=192.168.1.241:502 timeout: Resource temporarily unavailable, nwrite=6/6, nread=0
2018/01/24 15:19:31.229 drvModbusAsyn::doModbusIO port RD3R has I/O error
2018/01/24 15:19:35.234 drvModbusAsyn::doModbusIO port RD3R error calling writeRead, error=192.168.1.241:502 timeout: Resource temporarily unavailable, nwrite=6/6, nread=0
Any help will be appreciated, and thanks in advance !
Zhefu
- Replies:
- 答复: Question about communications based on modbus tcp. lzf neu
- References:
- Question about communications based on modbus tcp. lzf neu
- Navigate by Date:
- Prev:
Driver support of VMM ControlNet interface module (5136-CN-VME) 李刚
- Next:
Re: Driver support of VMM ControlNet interface module (5136-CN-VME) Kasemir, Kay
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
<2018>
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
Question about communications based on modbus tcp. lzf neu
- Next:
答复: Question about communications based on modbus tcp. lzf neu
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
<2018>
2019
2020
2021
2022
2023
2024
|