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 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 2022 2023 2024 2025 |
<== Date ==> | <== Thread ==> |
---|
Subject: | Re: asynPortDriver: get all addresses for ASYN_MULTIDEVICE |
From: | "Dunning, Michael via Tech-talk" <[email protected]> |
To: | Mark Rivers <[email protected]> |
Cc: | tech-talk <[email protected]> |
Date: | Wed, 20 Nov 2019 13:20:16 -0800 |
Hi Michael,
One solution is to implement the drvUserCreate() method in your driver.
drvUserCreate can call the getAddress() method to get the address of this device from the pasynUser passed to it. You can then build an std::set of the addresses that are actually used. You only insert a new address into the set if std::set.find() does not find the address in the set already. Once you call getAddress() you then call the base class asynPortDriver::drvUserCreate() to complete the operation.
Your driver can then loop over the entries in the std::set.
Mark
________________________________
From: Tech-talk <[email protected]> on behalf of Dunning, Michael via Tech-talk <[email protected]>
Sent: Tuesday, November 19, 2019 4:02 PM
To: EPICS Tech-Talk
Subject: asynPortDriver: get all addresses for ASYN_MULTIDEVICE
I've written an asynPortDriver for a TCP/IP-to-BitBus gateway which talks to power supply controllers. The driver sends addressed messages to each controller and receives similar messages as responses. The controllers may have non-sequential addresses in the [1, 200] range.
It works well with a single controller, and now I'm adding support for multiple controllers. Since the gateway doesn't support multiple sockets, I'm using ASYN_MULTIDEVICE (multiple addresses using a single asyn port).
To poll the controllers, I need to loop over all addresses in my driver. If I have sequential addresses that's easy, but mine may be non-sequential and I don't want to loop over non-existent addresses.
Is there a way to get a list of all registered addresses for a given port from asynManager somehow? By "registered" I mean an address that's present in a record and tied to a specific port, e.g.:
record(bo, "$(ps):StateSetpt") {
field(DESC, "Power Supply On/Off")
field(DTYP, "asynInt32")
field(OUT, "@asyn($(asynPort), $(address), 0) STATE_SETPT")
field(ZNAM, "OFF")
field(ONAM, "ON")
}
My first attempt would be to follow the asynReport (pasynManager->report) function which sets up a linked list and prints all addresses. Am I on the right track? Or is there something built-in that I missed?
Thanks,
Mike
Michael Dunning
SLAC National Accelerator Laboratory
2575 Sand Hill Road
Menlo Park, CA 94025
(650) 926-5200