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  2021  <20222023  2024  2025  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  <20222023  2024  2025 
<== Date ==> <== Thread ==>

Subject: Re: PINI field not working with modbus
From: Mark Rivers via Tech-talk <tech-talk at aps.anl.gov>
To: "Marco A. Barra Montevechi Filho" <marco.filho at lnls.br>, "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>
Date: Wed, 27 Jul 2022 12:02:34 +0000
Hi Marco,

I'm glad that adding the epicsThreadSleep(1.0) fixes the problem.

>  I was not aware that this is how the modbus driver worked.

The behavior for read functions is documented here:


Mark


From: Marco A. Barra Montevechi Filho <marco.filho at lnls.br>
Sent: Wednesday, July 27, 2022 6:57 AM
To: Mark Rivers <rivers at cars.uchicago.edu>; tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>
Subject: Re: PINI field not working with modbus
 
Oh! this makes sense and also explains the wireshark capture. I was not aware that this is how the modbus driver worked.

I tested just now and it works. Thanks!

From: Mark Rivers <rivers at cars.uchicago.edu>
Sent: 27 July 2022 08:52
To: Marco A. Barra Montevechi Filho <marco.filho at lnls.br>; tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>
Subject: Re: PINI field not working with modbus
 
Hi Marco,

I think I understand why you are not seeing the correct value when you use PINI=YES and SCAN=Passive.  The problem is a race condition.

As I said in a previous message, it appears that you have set the MBUS_POLL macro to 1000, which means the poller for that Modbus driver is running every 1000 ms (1 second).  The poller waits for this delay at the beginning of the poll loop.  The poller thread is started when your startup script calls drvModbusAsynConfigure().  When the record processes during iocInit() because PINI=YES it just gets the most recent value from the poller.

However, in your case because you have a slow polling rate of 1 second it is likely that the poller has not yet done the first poll when the record is processed during iocInit, so there is no value to use.

I believe you can fix the problem by adding this line to your startup script just before iocInit()

epicsThreadSleep(1.0)

Mark


References:
PINI field not working with modbus Marco A. Barra Montevechi Filho via Tech-talk
Re: PINI field not working with modbus Mark Rivers via Tech-talk
Re: PINI field not working with modbus Marco A. Barra Montevechi Filho via Tech-talk
RE: PINI field not working with modbus Mark Rivers via Tech-talk
Re: PINI field not working with modbus Mark Rivers via Tech-talk
Re: PINI field not working with modbus Marco A. Barra Montevechi Filho via Tech-talk

Navigate by Date:
Prev: Re: PINI field not working with modbus Mark Rivers via Tech-talk
Next: Re: PINI field not working with modbus bob dalesio 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  <20222023  2024  2025 
Navigate by Thread:
Prev: Re: PINI field not working with modbus Marco A. Barra Montevechi Filho via Tech-talk
Next: Re: PINI field not working with modbus bob dalesio 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  <20222023  2024  2025 
ANJ, 14 Sep 2022 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions ·
· Download · Search · IRMIS · Talk · Documents · Links · Licensing ·