EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

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  <20212022  2023  2024  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  <20212022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: modbus TCP
From: Mark Rivers via Tech-talk <tech-talk at aps.anl.gov>
To: liuxiaomin <liuxiaomin at sari.ac.cn>
Cc: "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>
Date: Fri, 24 Sep 2021 13:24:52 +0000
> My type of device  at that IP address is MPDU.


I don't know what an MPDU is.  Is this a commercial product, and does it provide Modbus functionality over TCP?  Can you send a link to the product description.

> I changed the IP address. ( 192.168.1.163:8055)

That means you are communicating on port 8055, which is not the standard port for Modbus, which is port 502.  In your original message you were using address "192.168.1.163:502", which is port 502.

Your asynReport shows the the CAT1 asyn port, which is the TCP connection to 192.168.1.163:8055 is OK.


epics> asynReport 1

CAT1 multiDevice:No canBlock:Yes autoConnect:Yes

enabled:Yes connected:Yes numberConnects 1

nDevices 0 nQueued 0 blocked:No

asynManagerLock:No synchronousLock:No

exceptionActive:No exceptionUsers 0 exceptionNotifys 0

traceMask:0x1 traceIOMask:0x0 traceInfoMask:0x1

Port 192.168.1.163:8055: Connected

However, the modbus port driver AI1R is not communicating correctly with that CAT1 port driver


modbus port: AI1R

initialized:        true

asynOctet server:   CAT1

modbusSlave:        0

modbusFunction:     3

modbusStartAddress: 010

modbusLength:       02

absoluteAddressing: false

dataType:           0 (INT16)

plcType:

I/O errors:         9

Read OK:            0

Write OK:           0

pollDelay:          0.100000

Time for last I/O   0 msec

Max. I/O time:      0 msec

Time per hist. bin: 1 msec

Note that I./O errors=9 and Read OK and Write OK are both 0.  This means it is not communicating with the device.

How did you chose port 8055 rather than 502?  Are you sure that this device supports Modbus communications on port 502 or some other port?

Mark

________________________________
From: liuxiaomin <liuxiaomin at sari.ac.cn>
Sent: Friday, September 24, 2021 5:50 AM
To: Mark Rivers
Cc: tech-talk at aps.anl.gov
Subject: 回复: modbus TCP


Hi Mark,

I am sorry to have sent you two emails,the first one can be ignored.

Thank you for your answer,  My type of device  at that IP address is MPDU.

I changed the IP address.( 192.168.1.163:8055) . And the complete output is as follows:



#!../../bin/linux-x86_64/sinModbus

< envPaths

epicsEnvSet("IOC","iocsinModbus")

epicsEnvSet("TOP","/home/iocusr/sinModbus")

epicsEnvSet("MODULES","/opt/epics/base/../modules")

epicsEnvSet("AUTOSAVE","/opt/epics/base/../modules/autosave-R5-7-1")

epicsEnvSet("ASYN","/opt/epics/base/../modules/asyn-R4-41")

epicsEnvSet("BUSY","/opt/epics/base/../modules/busy-1-6-1")

epicsEnvSet("CALC","/opt/epics/base/../modules/calc-R3-7-4")

epicsEnvSet("CAPUTLOG","/opt/epics/base/../modules/caPutLog-3-5")

epicsEnvSet("IOCSTATS","/opt/epics/base/../modules/iocStats-3-1-16")

epicsEnvSet("MODBUS","/opt/epics/base/../modules/modbus-R3-2")

epicsEnvSet("NETDEV","/opt/epics/base/../modules/netDev-1-0-6")

epicsEnvSet("PC-MONITOR","/opt/epics/base/../modules/PC-MONITOR1-0-2")

epicsEnvSet("PROCSERVCONTROL","/opt/epics/base/../modules/procServControl-1-9")

epicsEnvSet("S7NODAVE","/opt/epics/base/../modules/s7nodave-2-1-3")

epicsEnvSet("S7PLC","/opt/epics/base/../modules/s7plc")

epicsEnvSet("SSCAN","/opt/epics/base/../modules/sscan-2-10")

epicsEnvSet("STREAM","/opt/epics/base/../modules/StreamDevice-2-8-9")

epicsEnvSet("SNCSEQ","/opt/epics/base/../modules/seq-2-2-6")

epicsEnvSet("EPICS_BASE","/opt/epics/base")

epicsEnvSet("EPICS_CA_SERVER_PORT", 5064)

#epicsEnvSet("IOCNAME","sinModbus")

## Register all support components

dbLoadDatabase "../../dbd/sinModbus.dbd"

sinModbus_registerRecordDeviceDriver pdbbase

#asynReport(10,"CAT1")

# Configure IP port

drvAsynIPPortConfigure("CAT1","192.168.1.163:8055",0,0,1)

# Configure modbus

modbusInterposeConfig("CAT1",0,2000,0)

drvModbusAsynConfigure("AI1R","CAT1",0,3,0010,2,0,100,"CAT")

#cd "${TOP}/iocBoot/${IOC}"

dbLoadRecords "../../db/dbpdu.db", "DEVNAME=TEST"

iocInit

Starting iocInit

############################################################################

## EPICS R7.0.5

## Rev. 2021-09-13T15:44+0800

############################################################################

drvStreamInit: Warning! STREAM_PROTOCOL_PATH not set. Defaults to "."

sevr=info s7plcInit: no stations configured

iocRun: All initialization complete

dbl

TEST:IN1

epics> 2021/09/24 18:14:37.388 drvModbusAsyn::doModbusIO port AI1R error calling writeRead, error=192.168.1.163:8055 timeout: Resource temporarily unavailable, nwrite=6/6, nread=0



After I  typing asynReport 1,the complete output is as follows:

epics> asynReport 1

CAT1 multiDevice:No canBlock:Yes autoConnect:Yes

enabled:Yes connected:Yes numberConnects 1

nDevices 0 nQueued 0 blocked:No

asynManagerLock:No synchronousLock:No

exceptionActive:No exceptionUsers 0 exceptionNotifys 0

traceMask:0x1 traceIOMask:0x0 traceInfoMask:0x1

Port 192.168.1.163:8055: Connected

AI1R multiDevice:Yes canBlock:Yes autoConnect:Yes

enabled:Yes connected:Yes numberConnects 1

nDevices 1 nQueued 0 blocked:No

asynManagerLock:No synchronousLock:No

exceptionActive:No exceptionUsers 0 exceptionNotifys 0

traceMask:0x1 traceIOMask:0x0 traceInfoMask:0x1

addr 0 autoConnect Yes enabled Yes connected Yes exceptionActive No

        exceptionActive No exceptionUsers 0 exceptionNotifys 0

        blocked No

        traceMask:0x1 traceIOMask:0x0 traceInfoMask:0x1

modbus port: AI1R

initialized:        true

asynOctet server:   CAT1

modbusSlave:        0

modbusFunction:     3

modbusStartAddress: 010

modbusLength:       02

absoluteAddressing: false

dataType:           0 (INT16)

plcType:

I/O errors:         9

Read OK:            0

Write OK:           0

pollDelay:          0.100000

Time for last I/O   0 msec

Max. I/O time:      0 msec

Time per hist. bin: 1 msec

Port: AI1R

  Timestamp: <undefined>

  Input EOS[0]:

  Output EOS[0]:

Parameter list 0

Number of parameters is: 12

Parameter 0 type=asynInt32, name=MODBUS_DATA, value is undefined

Parameter 1 type=asynInt32, name=MODBUS_READ, value is undefined

Parameter 2 type=asynUInt32Digital, name=ENABLE_HISTOGRAM, value is undefined

Parameter 3 type=asynInt32, name=READ_HISTOGRAM, value is undefined

Parameter 4 type=asynInt32, name=HISTOGRAM_BIN_TIME, value is undefined

Parameter 5 type=asynInt32Array, name=HISTOGRAM_TIME_AXIS, value is undefined

Parameter 6 type=asynFloat64, name=POLL_DELAY, value is undefined

Parameter 7 type=asynInt32, name=READ_OK, value=0, status=0

Parameter 8 type=asynInt32, name=WRITE_OK, value=0, status=0

Parameter 9 type=asynInt32, name=IO_ERRORS, value=9, status=0

Parameter 10 type=asynInt32, name=LAST_IO_TIME, value=0, status=0

Parameter 11 type=asynInt32, name=MAX_IO_TIME, value=0, status=0

epics>



Then,

$ caget TEST:IN1

CA.Client.Exception…............................................

Warning: “Identical process variable names on multiple servers”

Context: “Channel: “TEST:IN1”, Connecting to: 192.168.1.160:41299, Ignored: 192.168.1.160:5064”

Source File: ../cac.cpp line 1320

Current Time: Fri Sep 24 2021 18:16:53.789456666

…...............................................................

TEST:IN1                       0



Finally, I found  the result read value was wrong.







从 Windows 版邮件<https://go.microsoft.com/fwlink/?LinkId=550986>发送



发件人: Mark Rivers<mailto:rivers at cars.uchicago.edu>
发送时间: 2021年9月22日 20:51
收件人: liuxiaomin<mailto:liuxiaomin at sari.ac.cn>
抄送: tech-talk at aps.anl.gov<mailto:tech-talk at aps.anl.gov>
主题: Re: modbus TCP



Hi,





Sorry I did not see your second message before I answered your first one.





The st.cmd looks OK to me.  Please send the complete output when the IOC boots.





Mark





________________________________

From: Tech-talk <tech-talk-bounces at aps.anl.gov> on behalf of liuxiaomin via Tech-talk <tech-talk at aps.anl.gov>

Sent: Wednesday, September 22, 2021 1:45 AM

To: tech-talk at aps.anl.gov

Subject: modbus TCP





Hi,



  I am trying to use modbus on debian system to control device,



The st.cmd files is as follows:



drvAsynIPPortConfigure("CAT1","192.168.1.163:502",0,0,1)



modbusInterposeConfig("CAT1",0,2000,0)



drvModbusAsynConfigure("CAT_AI1R","CAT1",0,3,0008,2,0,100, "CAT")



The db files is as follows:



record(ai, "$(DEVNAME):IN1") {



    field(DTYP,"asynInt32")



    field(INP,"@asynMask(CAT_AI1R 0 16)INT16")



    field(PREC,"1")



    field(SCAN,"I/O Intr")



}







When I execute the st.cmd file,it shows the following error:







drvStreamInit: Warning! STREAM_PROTOCOL_PATH not set. Defaults to "."



TEST:CAT1:IN1 devAsynInt32::initCommon connectDevice failed asynManager:connectDevice port CAT_AI1R not found







How can I solve this problem?



Thanks,



Xiaomin











从 Windows 版邮件<https://go.microsoft.com/fwlink/?LinkId=550986>发送







References:
modbus TCP liuxiaomin via Tech-talk
Re: modbus TCP Mark Rivers via Tech-talk
回复: modbus TCP liuxiaomin via Tech-talk

Navigate by Date:
Prev: 回复: modbus TCP liuxiaomin via Tech-talk
Next: Re: modbus TCP Ralph Lange via Tech-talk
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  <20212022  2023  2024 
Navigate by Thread:
Prev: 回复: modbus TCP liuxiaomin via Tech-talk
Next: Re: modbus TCP Ralph Lange via Tech-talk
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  <20212022  2023  2024 
ANJ, 24 Sep 2021 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·