Hi Vishnu,
> (2) With holding register(03) READ function is ok.
> But write gives an error as below
> 2019/10/22 15:11:41.117 drvModbusAsyn::doModbusIO port DACD_AMT_EU1_RW_MW_11000 error calling writeRead, error=, nwrite=6/6, nread=0
> iocRun: All initialization complete
> epics> 2019/10/22 15:12:20.517 drvModbusAsyn::writeUInt32D port DACD_AMT_EU1_RW_MW_11000 invalid request for Modbus function 3
> 2019/10/22 15:12:20.517 DACD_AMT_W_FR1 devAsynUInt32Digital::processCallbackOutput process error
The problem is that you are trying to use the same port for the read operation and the write operation, which is not correct. The port was created with Modbus function 3 which is Read Holding Registers. You need to create a second port with Modbus function 6 which is "Write Single Register". The longin record uses the port with function 3 and the longout record uses the port with function 6 (or 16).
> (1)I used write function for "write multiple coils (15)" modbus function.
> drvModbusAsynConfigure("DACD_AMT_EU1_WRITE_MB_0000", "DACD_AMT_EU1", 1, 15, 0, 32, 0, 100, "EU")
> The function error output below.
> 2019/10/22 14:58:49.789 drvModbusAsyn::doModbusIO port DACD_AMT_EU1_WRITE_MB_0000 error calling writeRead, error=, nwrite=6/6, nread=0
First, have you checked that the device supports function code 15? The manual should tell you what function codes are supported.
Second, this error
> 2019/10/22 14:58:49.789 drvModbusAsyn::doModbusIO port DACD_AMT_EU1_WRITE_MB_0000 error calling writeRead, error=, nwrite=6/6, nread=0
is not what I expect if the device does not support the operation or if you are using an invalid address etc. The above error says that the device did not send any response at all. What it should do is to send an error code.
You said the device is RTU. With RTU you need to set a delay before each write to the device with the writeDelayMsec argument to modbusInterposeConfig:
modbusInterposeConfig(portName,
linkType,
timeoutMsec,
writeDelayMsec)
Did you do that? Is your device serial, and if so what baud rate?
You can enable ASYN_TRACEIO_DRIVER in the underlying serial port or TCP driver to see all of the messages sent and received.
Mark
________________________________
From: Tech-talk <[email protected]> on behalf of Vishnu Patel via Tech-talk <[email protected]>
Sent: Tuesday, October 22, 2019 4:47 AM
To: [email protected]
Subject: modbus Write operation
Hi,
I would like to write using modbusRTU EPICS Driver.
(1)I used write function for "write multiple coils (15)" modbus function.
drvModbusAsynConfigure("DACD_AMT_EU1_WRITE_MB_0000", "DACD_AMT_EU1", 1, 15, 0, 32, 0, 100, "EU")
The function error output below.
2019/10/22 14:58:49.789 drvModbusAsyn::doModbusIO port DACD_AMT_EU1_WRITE_MB_0000 error calling writeRead, error=, nwrite=6/6, nread=0
(2) With holding register(03) READ function is ok.
But write gives an error as below
2019/10/22 15:11:41.117 drvModbusAsyn::doModbusIO port DACD_AMT_EU1_RW_MW_11000 error calling writeRead, error=, nwrite=6/6, nread=0
iocRun: All initialization complete
epics> 2019/10/22 15:12:20.517 drvModbusAsyn::writeUInt32D port DACD_AMT_EU1_RW_MW_11000 invalid request for Modbus function 3
2019/10/22 15:12:20.517 DACD_AMT_W_FR1 devAsynUInt32Digital::processCallbackOutput process error
I am reading and write Holding Register 11000 using longin & longout record.
file "../../db/longin.template" { pattern
{P, R, PORT, OFFSET, SCAN}
{DACD_AMT_, R_FR1, DACD_AMT_EU1_RW_MW_11000, 0, "I/O Intr"}
}
file "../../db/longout.template" { pattern
{P, R, PORT, OFFSET}
{DACD_AMT_, W_FR1, DACD_AMT_EU1_RW_MW_11000, 0}
I am not able to write "multiple coils" function and "write holding register" .
Thanks
Vishnu
- References:
- modbus Write operation Vishnu Patel via Tech-talk
- Navigate by Date:
- Prev:
modbus Write operation Vishnu Patel via Tech-talk
- Next:
New areaDetector releases: ADCore R3-8, ADGenICam R1-1, ADAravis R1-1, ADVimba R1-0, ADViewers R1-4, ADSimDetector R2-10 Mark Rivers 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
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
modbus Write operation Vishnu Patel via Tech-talk
- Next:
New areaDetector releases: ADCore R3-8, ADGenICam R1-1, ADAravis R1-1, ADVimba R1-0, ADViewers R1-4, ADSimDetector R2-10 Mark Rivers 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
2021
2022
2023
2024
|