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  <20152016  2017  2018  2019  2020  2021  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  <20152016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: using EPICS code with HTTP port
From: Rod Nussbaumer <[email protected]>
To: [email protected]
Date: Fri, 20 Feb 2015 10:35:44 -0800
Ana:

I doubt that your objective is do-able in StreamDevice alone. If it was my task, I would probably create an intermediate HTTP client using Python or Perl, and have it export the relevant data via a socket connection. The intermediate client could be on any host, including the IOC host, and would expose some SCPI-like command & query interface that StreamDevice can deal with easily.

Rod Nussbaumer
TRIUMF,
Vancouver, Canada.

On 02/20/2015 09:40 AM, Ana Malagon wrote:
Hi all,

Thanks very much! Dirk, thanks for the tip about using regular
expressions - I am trying that now and hopefully can get it to work.

I realized however that if I wanted to include the functionality of a
json parser, such as https://github.com/json-c/json-c, that I would have
no idea where to start with the StreamDevice template, as it only has
the db and protocol file.
I think I could do this with the old devGpib template, as the commands
are defined in a C file, but does anyone know how I might get a JSON
parser to work with StreamDevice?

Thanks,

Ana

On Wed, Feb 18, 2015 at 4:37 PM, Mark Rivers <[email protected]
<mailto:[email protected]>> wrote:

    Hi Ana,____

    __ __

    I notice you have set the NELM field of the waveform record to
    32000.  That is larger than the default value of
    EPICS_CA_MAX_ARRAY_BYTES, which is 16K.  You need to set the value
    of the environment variable EPICS_CA_MAX_ARRAY_BYTES to a value
    larger than 32000 on both the IOC process and any EPICS channel
    access client process.____

    __ __

    If that does not fix your problem then I would suggest the
    following:____

    __ __

    - Create the drvAsynIPPort driver____

    - Open an asyn record to the driver____

    - Use the medm asynRecord.adl and asynOctet.adl screens____

    - Turn on ASYN_TRACEIO_ESCAPE and ASYN_TRACEIO_DRIVER____

    - Using the asynRecord send the command “GET /data”____

    - Look at the asynTrace output to see what was sent and what was
    received.____

    __ __

    Mark____

    __ __

    __ __

    *From:* [email protected]
    <mailto:[email protected]>
    [mailto:[email protected]
    <mailto:[email protected]>] *On Behalf Of *Ana Malagon
    *Sent:* Wednesday, February 18, 2015 12:05 PM
    *To:* Kasemir, Kay
    *Cc:* [email protected] <mailto:[email protected]>
    *Subject:* Re: using EPICS code with HTTP port____

    __ __

    Hi Kay, Mark,____

    Thanks for the help - so I've tried both approaches (using pcaspy to
    set up an IOC, and alternatively using HTTP in IPPortConfigure for
    my streamDevice application) and am running into a stumbling block
    with both.____

    The problem is that when I request the data I always get an array of
    0's back. Here's the syntax I'm using in the streamDevice IOC (and I
    know the HTTP commands are correct because they work in a telnet
    session):____

    /===device.proto file===/____

    /getData {
         out "GET /data";
         in "%\$1[^\r\n]";
         ExtraInput = Ignore;
    }/____

    /====device.db file===
    record(waveform, "$(P)$(R)Data")
    {
         field(DESC, "Data array")
         field(DTYP, "stream")
         field(INP, "@devREDPITAYASTREAM.proto getData(20000) $(PORT) $(A)")
         field(PINI, "YES")
         field(FTVL, "CHAR")
         field(NELM, "32000")
    }/____

    For the pcaspy version, I have taken the tutorial file pysh.py,
    which creates an IOC that processes shell commands
    (https://code.google.com/p/pcaspy/source/browse/example/pysh.py) and
    modified the OUTPUT to be of datatype "char" with a large count. I
    have httpie installed, which is a library allowing me to run the
    command 'http 10.95.101.75/data <http://10.95.101.75/data>' on the
    command line to retrieve the data. However, when I do 'caput
    MTEST:COMMMAND "http 10.95.101.75/data <http://10.95.101.75/data>"
    and then 'caget MTEST:OUTPUT', I get an array of zeroes back.____

    Does anything pop out as immediately suspicious?____

    Thanks,____

    Ana____



    ____

    __ __

    On Mon, Feb 9, 2015 at 12:58 PM, Kasemir, Kay <[email protected]
    <mailto:[email protected]>> wrote:____

    What Mark suggests could work, but the HTTP protocol is somewhat
    verbose and the exact response of the server could vary.

    To emulate

     > curl http://10.95.101.75/bazaar?start=spectrum

    you could try to send

    GET bazaar?start=spectrum HTTP/1.1\n\n

    .. and then ignore the response.

    To emulate

     > curl http://10.95.101.75/data

    you could try to send

    GET data HTTP/1.1\n\n

    and then you need to be prepared to parse a response that looks like

    HTTP/1.1 200 OK
    Content-Type: text/html
    Server: Whatever
    Cache-Control: no-cache
    Pragma: no-cache
    Content-Length: 97

    .. the actual data..


    You should try those GET commands from a plain telnet session to the
    server to see the exact response.

    It might be easier to use for example python with urllib2 to
    communicate with the device, and then see the recent tech-talk
    discussion on how to get from python to EPICS:
    * Use CA client library to write values from Python to a "real IOC"
    * Use CA server library to serve the values from Python, i.e. it's
    like an IOC
    * Serve data from python via a simpler TCP socket protocol, read
    into IOC via stream device.

    Thanks,
    Kay




    On Feb 9, 2015, at 3:02 PM, Mark Rivers <[email protected]
    <mailto:[email protected]>>____

      wrote:

     > This command should be:
     > drvAsynIPPortConfigure("L0","10.95.101.75:80
    <http://10.95.101.75:80> HTTP",0,0,0)
     > The HTTP means that drvAsynIPPort will handle the fact that the
    server will disconnect after each transaction.
     >
     > You can’t use the “curl” command in your protocol.  You need to
    send the actual commands that the HTTP server requires.
     >
     > It might be something like
     > getData {
     >     out "get data";
     >     in "%\$1[^\r\n]";
     >     ExtraInput = Ignore;
     > }
     > Mark
     >
     >
     >
     > From: [email protected]
    <mailto:[email protected]>
    [mailto:[email protected]
    <mailto:[email protected]>] On Behalf Of Ana Malagon
     > Sent: Monday, February 09, 2015 1:53 PM
     > To: [email protected] <mailto:[email protected]>
     > Subject: using EPICS code with HTTP port
     >
     > Hi,
     >
     > I'm trying to use EPICs with a digitizer (www.redpitaya.com
    <http://www.redpitaya.com>) which has a web interface - I can get
    the information using curl to download the website information:
     >
     > curl http://10.95.101.75/bazaar?start=spectrum
     >
     > curl http://10.95.101.75/data
     >
     > but I'm a little confused about how to integrate these commands
    in an ioc. I've set up a StreamDevice template, and I thought I
    might be able to just send the curl commands by putting them in a
    record:
     >
     > record(bo, "$(P)$(R)Start")
     > {
     >     field(DESC, "Start App")
     >     field(DTYP, "stream")
     >     field(OUT, "@devREDPITAYASTREAM.proto startApp $(PORT) $(A)")
     >     field(ZNAM, "spectrum")
     >     #field(PINI, "YES")
     >     #field(VAL, "1")
     > }
     >
     > record(waveform, "$(P)$(R)Data")
     > {
     >     field(DESC, "Data string")
     >     field(DTYP, "stream")
     >     field(INP, "@devREDPITAYASTREAM.proto getData(20000) $(PORT)
    $(A)")
     >     field(PINI, "YES")
     >     field(FTVL, "CHAR")
     >     field(NELM, "32000")
     > }
     > with the corresponding entries in the .proto file being:
     > startApp {
     >     out "curl http://10.95.101.75/bazaar?start=%{spectrum}
    <http://10.95.101.75/bazaar?start=%25%7bspectrum%7d>";
     > }
     > getData {
     >     out "curl http://10.95.101.75/data";;
     >     in "%\$1[^\r\n]";
     >     ExtraInput = Ignore;
     > }
     > When I run st.cmd, the host is configured to be the IP address of
    the red pitaya itself, using the HTTP port of 80:
     > drvAsynIPPortConfigure("L0","10.95.101.75:80
    <http://10.95.101.75:80>",0,0,0)
     > I'm not sure if this is the right thing to do? In any case, when
    running st.cmd with asynTraceMask enabled I get a continuous stream
    of "reads"
     > 2015/02/09 11:48:23.530 10.95.101.75:80 <http://10.95.101.75:80>
    read.
     > but it doesn't seem to respond to the commands I've made.
     > Does anyone have any feeling for using Epics with HTTP commands?
     > Thanks!
     > Ana Malagon____

    __ __




References:
using EPICS code with HTTP port Ana Malagon
RE: using EPICS code with HTTP port Mark Rivers
Re: using EPICS code with HTTP port Kasemir, Kay
Re: using EPICS code with HTTP port Ana Malagon
RE: using EPICS code with HTTP port Mark Rivers
Re: using EPICS code with HTTP port Ana Malagon

Navigate by Date:
Prev: EPICS Meeting, May 18-22, FRIB: Experiment control / data acquisition Kasemir, Kay
Next: 3.15.1 documentation... Dudley, David
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: using EPICS code with HTTP port Ana Malagon
Next: Re: using EPICS code with HTTP port Dirk Zimoch
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 16 Dec 2015 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·