Hi,
Your db and st.cmd files look OK except perhaps for this:
modbusInterposeConfig("PSU0",1,300,4)
That sets a timeout of 300 ms for receiving a reply from the device. That may be too short, I suggest increasing that to 2000.
You should enable asynTrace on the serial port so that you can see the full communication between the IOC and the device.
Add these lines to your st.cmd right after modbusInterposeConfig()
asynSetTraceIOMask("PSU0",0,”HEX”)
asynSetTraceMask(“PSU0”,0,”ERROR|DRIVER”)
Once you do that please send the complete output when the IOC boot and runs for 20 seconds or so.
Mark
From: Tech-talk <tech-talk-bounces at aps.anl.gov>
On Behalf Of ??????? ???????? via Tech-talk
Sent: Monday, March 29, 2021 8:13 AM
To: tech-talk at aps.anl.gov
Subject: modbus read error
Hi all, Im a student and a beginner in EPICS.
I am currently developing an IOC to drive a power supply (PS) via Modbus RTU. Using lib modbus R3-2.
I have a problem with DO reading, DO writing is successful. I can see, PS receives message and answers (what I dont know).
I thought there was a mistake in the argument in function in st.cmd, but I tested modbus start address and slave address in Modpoll.
Also asynReport was used, and according to it: ....name=IO_ERRORS, value=49,...... (depends on run time)
TEST-MSC-FUN:COIL-ONOFF-GET devAsynUInt32Digital::processCallbackInput process read error.
drvModbusAsyn::doModbusIO port SET writeRead status back to normal having had 1 errors, nwrite=6/6, nread=5
What shout I pay attention to?
record (bi,"TEST-MSC-FUN:COIL-ONOFF-GET")
field(DESC, "Ctrl on/off PSU")
field(DTYP, "asynUInt32Digital")
field(INP, "@asynMask(GET 1 0x1) MODBUS_DATA")
record (bo,"TEST-MSC-FUN:COIL-ONOFF-SET")
field(DESC, "ON OFF PSU")
field(DTYP, "asynUInt32Digital")
field(OUT, "@asynMask(SET 1 0x1)")
drvAsynSerialPortConfigure("PSU0", "/dev/ttyS1", 0, 0, 0)
asynSetOption("PSU0",0,"baud","57600")
asynSetOption("PSU0",0,"parity","none")
asynSetOption("PSU0",0,"bits","8")
asynSetOption("PSU0",0,"stop","1")
modbusInterposeConfig("PSU0",1,300,4)
drvModbusAsynConfigure("GET", "PSU0", 1, 1, 0, 300, 0, 500, "PSU")
drvModbusAsynConfigure("SET", "PSU0", 1, 5, 0, 128, 0, 1000, "PSU")
|