Hi Mark,
I realized that I turn on the reading function in the simulator but only limited to read 1 data or 70 data.
With this setting "drvModbusAsynConfigure("ctrl", "RKamp",1,6,1, 3,0,100,"RKamp")" it read exactly 3 data at the beginning.
After adding the possibility to read any number of data, I can set the pollMsec=100 without getting any error.
Thank you for your help!
Grass
From: Mark Rivers <rivers at cars.uchicago.edu>
Sent: Thursday, July 1, 2021 11:55 AM
To: Wang, SuYin Grass <grass at anl.gov>
Cc: tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>
Subject: Re: Question about "error calling writeRead" in modbus
Hi Grass,
I have not been able to reproduce your error running a Modbus simulator. What version of the Modbus module are you using?
Mark
________________________________
From: Wang, SuYin Grass <grass at anl.gov>
Sent: Thursday, July 1, 2021 11:22 AM
To: Mark Rivers
Cc: tech-talk at aps.anl.gov
Subject: Re: Question about "error calling writeRead" in modbus
Hi Mark,
Thank you for the quick reply.
The simulator is configured to support Modbus function 3 on those addresses.
I changed the pollMsec=0 and that removed the error. Thanks again!
Grass
________________________________
From: Mark Rivers <rivers at cars.uchicago.edu>
Sent: Thursday, July 1, 2021 11:18 AM
To: Wang, SuYin Grass <grass at anl.gov>
Cc: tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>
Subject: Re: Question about "error calling writeRead" in modbus
Hi Grass,
Ø drvModbusAsynConfigure("ctrl", "RKamp",1,6,1, 3,0,100,"RKamp")
Ø 2021/07/01 09:55:26.074 drvModbusAsyn::doModbusIO port ctrl error calling writeRead, error=xxx.xxx.xxx.xxx:4502 timeout: Resource temporarily unavailable, nwrite=6/6, nread=0
Your drvModbusAsynConfigure command has the following parameters:
- asyn portName = “ctrl”
- asyn tcpPortName = “RKamp”
- slaveAddress = 1
- modbusFunction = 6 (write single register)
- modbusStartAddress = 1
- modbusLength = 3
- datatype = 0
- pollMsec = 100
- plcType = RKamp
Because function code 6 is a write operation and because you have set pollMsec to a non-zero value the Modbus driver will first try to do an initial read of those registers using Modbus function 3 (read holding registers).
I suspect your problem is that you have not configured your Modbus simulator to support Modbus function 3 on those addresses. There are 2 solutions to avoid that error message:
1. Configure your simulator to support Modbus function 3 on those addresses
2. Set pollMsec=0 in that drvModbusAsynConfigure command.
Mark
________________________________
From: Tech-talk <tech-talk-bounces at aps.anl.gov> on behalf of Wang, SuYin Grass via Tech-talk <tech-talk at aps.anl.gov>
Sent: Thursday, July 1, 2021 10:21 AM
To: tech-talk at aps.anl.gov
Subject: Question about "error calling writeRead" in modbus
Hi Everyone,
I have a question about asyn and modbus
I am running the soft IOC with a modbus simulator. Since I don't have permission on the workstation running simulator, I am using port 4502 instead 502
The IOC and simulator run fine, according to "trace_debug.txt" the reading and writing are reasonable.
It is just when the IOC boot up, there is always one line of error about "error calling writeRead" right after the drvModbusAsynConfigure for the writing function.
Any advice?
Thanks!
Grass
===========st.cmd=================================================
##this line is for simulator; this is Modbus TCP, but for this device we must set noProcessEos to 0
drvAsynIPPortConfigure("RKamp","xxx.xxx.xxx.xxx:4502",0,0,0)
modbusInterposeConfig("RKamp",0,2000,0)
drvModbusAsynConfigure("ctrl", "RKamp",1,6,1, 3,0,100,"RKamp")
2021/07/01 09:55:26.074 drvModbusAsyn::doModbusIO port ctrl error calling writeRead, error=xxx.xxx.xxx.xxx:4502 timeout: Resource temporarily unavailable, nwrite=6/6, nread=0
drvModbusAsynConfigure("UINT32", "RKamp",1,3,1,70,0,2000,"RKamp")
drvModbusAsynConfigure("INT32", "RKamp",1,3,1,70,4,2000,"RKamp")
=============================================================================
========the trace_debug.txt===================
2021/06/30 18:21:30.574 xxx.xxx.xxx.xxx:4502 write 12
00 09 00 00 00 06 01 03 00 01 00 46
2021/06/30 18:21:30.575 xxx.xxx.xxx.xxx:4502 read 149
00 09 00 00 00 8f 01 03 8c 00 00 00 00 00 00 00 00 00 00 00
01 00 00 00 00 00 00 00 c9 00 ca 00 cb 00 00 00 00 00 00 00
0b 00 0b 00 0b 00 0b 00 0b 00 0b 00 0b 00 0b 00 0b 00 0b 00
0b 00 0b 00 16 00 16 00 16 00 16 00 16 00 16 00 16 00 32 00
2021/06/30 18:21:31.511 xxx.xxx.xxx.xxx:4502 write 12
00 0a 00 00 00 06 01 03 00 01 00 01
2021/06/30 18:21:31.512 xxx.xxx.xxx.xxx:4502 read 11
00 0a 00 00 00 05 01 03 02 00 00
2021/06/30 18:21:31.513xxx.xxx.xxx.xxx:4502 write 12
00 0b 00 00 00 06 01 06 00 01 00 01
2021/06/30 18:21:31.513 xxx.xxx.xxx.xxx:4502 read 12
00 0b 00 00 00 06 01 06 00 01 00 01
=================================================
|