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  <20202021  2022  2023  2024  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  <20202021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: How can I add multiple serial ports in a single IOC?
From: "Lang, Keenan C. via Tech-talk" <tech-talk at aps.anl.gov>
To: "yincx at ihep.ac.cn" <yincx at ihep.ac.cn>, "Rivers, Mark L." <rivers at cars.uchicago.edu>
Cc: tech-talk <tech-talk at aps.anl.gov>
Date: Tue, 17 Mar 2020 15:49:30 +0000
>Then you only need 3 lines per port rather than 7.

With epics base 3.15 or later, you can reduce it to 1. The command 'iocshLoad' runs a given script with a set of temporary environment variables that only exist for the duration of running said script. This has the added benefit of not polluting your global environment, so that if you accidentally forget to set a variable, you get an error message saying that the variable is undefined rather than the previous value bleeding through.

You could thus do

    iocshLoad("./addSerialPort.cmd", "PORT=PS1, DEVICE=/dev/ttyS1")
    iocshLoad("./addSerialPort.cmd", "PORT=PS2, DEVICE=/dev/ttyS2")


Keenan Lang

From: Tech-talk <tech-talk-bounces at aps.anl.gov> on behalf of Mark Rivers via Tech-talk <tech-talk at aps.anl.gov>
Sent: Tuesday, March 17, 2020 7:16 AM
To: yincx at ihep.ac.cn <yincx at ihep.ac.cn>
Cc: tech-talk <tech-talk at aps.anl.gov>
Subject: Re: How can I add multiple serial ports in a single IOC?
 


> if I want to add 10 serial ports, should I add them one by one and repeat the above statements 10 times? Is there any simple method?

> Can  I  add the serial ports as a group,which has the same configuration?  I didn't find any document about this.


You could make another script called, for example addSerialPort.  It would look like this:


        drvAsynSerialPortConfigure ("$(PORT)","$(DEVICE)")
        asynSetOption ("$(PORT)", 0, "baud", "9600")
        asynSetOption ("$(PORT)", 0, "bits", "8")
        asynSetOption ("$(PORT)", 0, "parity", "none")
        asynSetOption ("$(PORT)", 0, "stop", "1")
        asynSetOption ("$(PORT)", 0, "clocal", "Y")
        asynSetOption ("$(PORT)", 0, "crtscts", "N")


Then you would set 2 environment variables and call the script:


epicsEnvSet("PORT", "PS1")

epicsEnvSet("DEVICE", " /dev/ttyS1")

< addSerialPort

epicsEnvSet("PORT", "PS2")

epicsEnvSet("DEVICE", " /dev/ttyS2")

< addSerialPort

...



Then you only need 3 lines per port rather than 7.

Mark



________________________________
From: Tech-talk <tech-talk-bounces at aps.anl.gov> on behalf of yincx--- via Tech-talk <tech-talk at aps.anl.gov>
Sent: Monday, March 16, 2020 11:08 PM
To: tech-talk
Subject: How can I add multiple serial ports in a single IOC?

Hi everyone,
I want to add 10 or more serial ports in a single IOC. All the serial ports have the same configuration besides the serial port name.
The single port configuration is like this:
        drvAsynSerialPortConfigure ("PS1","/dev/ttyS1")
        asynSetOption ("PS1", 0, "baud", "9600")
        asynSetOption ("PS1", 0, "bits", "8")
        asynSetOption ("PS1", 0, "parity", "none")
        asynSetOption ("PS1", 0, "stop", "1")
        asynSetOption ("PS1", 0, "clocal", "Y")
        asynSetOption ("PS1", 0, "crtscts", "N")

if I want to add 10 serial ports, should I add them one by one and repeat the above statements 10 times? Is there any simple method? Can  I  add the serial ports as a group,which has the same configuration?  I didn't find any document about this.

Thank you very much for your help.
Best Regards
Chunxia  Yin
2020-3-17
________________________________
yincx at ihep.ac.cn

References:
How can I add multiple serial ports in a single IOC? yincx--- via Tech-talk
Re: How can I add multiple serial ports in a single IOC? Mark Rivers via Tech-talk

Navigate by Date:
Prev: caproto-monitor exits when IOC exits too Rute Mendes via Tech-talk
Next: Timestamp reset event in EVR Di Wang 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  <20202021  2022  2023  2024 
Navigate by Thread:
Prev: Re: How can I add multiple serial ports in a single IOC? Mark Rivers via Tech-talk
Next: caproto-monitor exits when IOC exits too Rute Mendes 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  <20202021  2022  2023  2024 
ANJ, 17 Mar 2020 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·