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  <20122013  2014  2015  2016  2017  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017 
<== Date ==> <== Thread ==>

Subject: Re: [Scopes] BMP image record??
From: Rod Nussbaumer <bomr@triumf.ca>
To: Pavel Masloff <pavel.masloff@gmail.com>
Cc: EPICS Tech Talk <tech-talk@aps.anl.gov>
Date: Wed, 02 May 2012 13:43:30 -0700
The 'nnn' I wrote is the width field in the format converter. See
http://epics.web.psi.ch/software/streamdevice/doc/formats.html#syntax
It is just like the width field of a scanf() format converter. If you use it with a %c converter against a record of FTVL=UCHAR or CHAR, it says "grab 'nnn' bytes.

   ---   rod.




Pavel Masloff wrote:
Sorry, is nnn a number of expected bytes/characters? I haven't found any
explanation on the %c converter with this option on the official
StreamDevice web-site.
My incoming image has a variable length from 10kB up to 46kB. So in my
case how should I write the protocol? Maybe until the \n character?
Remember you proposed setting a big timeout and a "" separator? Will
that work?

I have also found the %#s converter. Perhaps, try this?

I am using RS232 rather than GPIB, but I wait ~ 10 seconds to get a
14-20kB file when getting the image by means of Python.

On Wed, May 2, 2012 at 7:32 PM, Rod Nussbaumer <bomr@triumf.ca
<mailto:bomr@triumf.ca>> wrote:

    The %c converter should do it, along with a 'width' number of
    expected characters (nnn in the example below). If this is to read
    an unknown number of bytes, then the 'nnn' quantity will result in a
    timeout to terminate the read. You would want to use @readtimeout to
    set some reasonable number for that timeout.
    I've used this method for reading binary formatted scope waveforms
    where the number of bytes in the waveform is known a priori, but
    never for reading a block of unknown size. There does seem to be an
    as yet unresolved performance issue in streamDevice when the asyn
    port driver is linuxGPIB, in case that is your architecture. I ended
    up using a bare asyn record with DTYP=asynOctetCommandResponse to
    solve it, coupled with a subroutine record to strip off an un-needed
    header and perform a converison to multi-byte words.


     > PrtScr {
     >      InTerminator = "";
     >      ReplyTimeout = 15000;
     >      out "HARDCOPY START";
     >      in "%nnnc";
                ^^^^

     > }

       ---   rod.



    Pavel Masloff wrote:

        Hey Rod,

        Which IN converter should I use in the protocol file of
        StreamDevice?
        I have tried %u and it didn't work:

        record(waveform, "$(P)$(R)file") {
             field(DTYP, "stream")
             field(SCAN, "Passive")
             field(INP, "@devTPS20xx.proto PrtScr $(PORT) $(A)")
             field(NELM, "500000")
             field(FTVL, "UCHAR")
        }

        PrtScr {
             InTerminator = "";
             ReplyTimeout = 15000;
             out "HARDCOPY START";
             in "%u";
        }

        L1 TPS2024B:file: Input
        "BM╩7<00><00><00><00><00><00>__6<04><00><00>(<00><00><00>@<__01>..."
        does
        not match format %u

        On Mon, Apr 30, 2012 at 12:24 AM, Rod Nussbaumer <bomr@triumf.ca
        <mailto:bomr@triumf.ca>
        <mailto:bomr@triumf.ca <mailto:bomr@triumf.ca>>> wrote:

            In principle, you should be able to read the binary data
        just as if
            you were receiving a binary formatted waveform. The EPICS
        waveform
            record will need to be set to an unsigned char data type.
        The trick
            will be to properly handle ending the transmission. Since your
            Python code seems to use a timeout to determine the end of
        the file,
            you could do that in streamDevice, too, by setting '
        InTerminator =
        "" ' & setting some reasonable number for the 'ReadTimeout' in the
            protocol for the image file reader. Perhaps Dirk can confirm
        this.

            You will need to set the NELM field to something large enough to
            hold the largest image file that can be transmitted. I do
        not know
            how you could automatically get the image data from the waveform
            record into a file without some assistance from a host-based
        tool.

            Rod Nussbaumer
            ISAC Controls, TRIUMF
            Vancouver, Canada.


            Pavel Masloff wrote:

                Why can't I?
                In Hyperterminal (as well as in Python) you simply send a
                command and
                receive bytes, which you forward to a binary file. Sth
        like this:

                |import sys
                import os
                import time
                import serial

                # create target file
                print os.getcwd()
                f = open('hardcopy.png', 'wb')

                # configure the serial connection
                ser = serial.Serial()
                ser.port = 0
                ser.timeout = 0
                ser.baudrate = 9600

                ser.open()

                # configure the hardcopy settings
                cmd = ':HARDCOPY:FORMAT PNG;PALETTE NORMAL;PORT RS232;LAYOUT
                PORTRAIT;\
                PREVIEW 0;INKSAVER 0;COMPRESSION 0\n'
                a = ser.write(cmd)
                print "bytes sent: {:d}".format(a)

                # start hardcopy
                a = ser.write("HARDCOPY START\n")
                print "bytes sent: {:d}".format(a)

                # begin receiving data and writing to file
                total_bytes = 0;
                a = ser.inWaiting()
                while a>0:
                     time.sleep(0.5)
                     data = ser.read(a)
                     total_bytes += a
                     f.write(data)
                     time.sleep(0.5)
                     a = ser.inWaiting()
                     sys.stdout.write(".")

                # close file and serial port
                sys.stdout.write("\n")
                f.close()
                ser.close()

                print "bytes read: {:d}".format(total_bytes)
                print "script completed"|


                Are you sure StreamDevice won't write the input to a
        waveform
                record?


                On Sun, Apr 29, 2012 at 7:47 PM, Mark Rivers
        <rivers@cars.uchicago.edu <mailto:rivers@cars.uchicago.edu>
        <mailto:rivers@cars.uchicago.__edu
        <mailto:rivers@cars.uchicago.edu>>
        <mailto:rivers@cars.uchicago. <mailto:rivers@cars.uchicago.>____edu

        <mailto:rivers@cars.uchicago.__edu
        <mailto:rivers@cars.uchicago.edu>>>> wrote:

                    I don't think you can get the image into a waveform
        record
                from the
                    scope with StreamDevice.  You would have to write
        another driver
                    that does what you were doing with Hyperterminal and
        Python.
                  You
                    could perhaps use an SNL program for this.

                    To display an image in BOY you use the Intensity Plot
                widget.  The
                    waveform record is 1-D, but you tell the BOY widget the
                actual X and
                    Y dimensions of the array.

                    Mark


                    ____________________________________

                    From: Pavel Masloff [pavel.masloff@gmail.com
        <mailto:pavel.masloff@gmail.com>
        <mailto:pavel.masloff@gmail.__com <mailto:pavel.masloff@gmail.com>>
        <mailto:pavel.masloff@gmail.
        <mailto:pavel.masloff@gmail.>____com
        <mailto:pavel.masloff@gmail.__com
        <mailto:pavel.masloff@gmail.com>>>]


                    Sent: Sunday, April 29, 2012 9:22 AM
                    To: Mark Rivers
                    Cc: EPICS Tech Talk
                    Subject: Re: [Scopes] BMP image record??

                    Is there any working example on how to get the image
        into a
                waveform
                    record using StreamDevice? I haven't used the waveform
                record yet,
                    reading up on this in the db reference manual, not that
                    comprehensible :(

                    Another question is how to read a waveform (image
        type) in BOY?

                    Pavel

                    On Sat, Apr 28, 2012 at 5:53 PM, Mark Rivers
        <rivers@cars.uchicago.edu <mailto:rivers@cars.uchicago.edu>
        <mailto:rivers@cars.uchicago.__edu
        <mailto:rivers@cars.uchicago.edu>>
        <mailto:rivers@cars.uchicago. <mailto:rivers@cars.uchicago.>____edu
        <mailto:rivers@cars.uchicago.__edu
        <mailto:rivers@cars.uchicago.edu>>><mailto:rivers@cars.
        <mailto:rivers@cars.>__uch__icago.edu <http://uchicago.edu>
        <mailto:rivers@cars.uchicago.__edu
        <mailto:rivers@cars.uchicago.edu>>

        <mailto:rivers@cars.uchicago. <mailto:rivers@cars.uchicago.>____edu

        <mailto:rivers@cars.uchicago.__edu
        <mailto:rivers@cars.uchicago.edu>>>>> wrote:
                    If you can get the image into a waveform record, using
                streamDevice
                    for example, then you can display that waveform as
        in image
                in EDM,
                    CSS BOY, ImageJ or other applications.  You need to
        create a few
                    other records that tell the client what the actual image
                dimensions are.

                    It may be just as easy to implement reading the
        actual waveforms
                    into waveform records, and display those with
        Cartesian plot
                widgets
                    in your display manager.

                    Mark

                    ____________________________________
                    From: tech-talk-bounces@aps.anl.gov
        <mailto:tech-talk-bounces@aps.anl.gov>
        <mailto:tech-talk-bounces@aps.__anl.gov
        <mailto:tech-talk-bounces@aps.anl.gov>>
        <mailto:tech-talk-bounces@aps.
        <mailto:tech-talk-bounces@aps.>____anl.gov <http://anl.gov>
        <mailto:tech-talk-bounces@aps.__anl.gov
        <mailto:tech-talk-bounces@aps.anl.gov>>><mailto:tech-talk-____bounces@aps.anl.gov
        <mailto:tech-talk-__bounces@aps.anl.gov>
        <mailto:tech-talk-bounces@aps.__anl.gov
        <mailto:tech-talk-bounces@aps.anl.gov>>
        <mailto:tech-talk-bounces@aps.
        <mailto:tech-talk-bounces@aps.>____anl.gov <http://anl.gov>

        <mailto:tech-talk-bounces@aps.__anl.gov
        <mailto:tech-talk-bounces@aps.anl.gov>>>>
                    [tech-talk-bounces@aps.anl.gov
        <mailto:tech-talk-bounces@aps.anl.gov>
        <mailto:tech-talk-bounces@aps.__anl.gov
        <mailto:tech-talk-bounces@aps.anl.gov>>
        <mailto:tech-talk-bounces@aps.
        <mailto:tech-talk-bounces@aps.>____anl.gov <http://anl.gov>
        <mailto:tech-talk-bounces@aps.__anl.gov
        <mailto:tech-talk-bounces@aps.anl.gov>>><mailto:tech-talk-____bounces@aps.anl.gov
        <mailto:tech-talk-__bounces@aps.anl.gov>
        <mailto:tech-talk-bounces@aps.__anl.gov
        <mailto:tech-talk-bounces@aps.anl.gov>>

        <mailto:tech-talk-bounces@aps.
        <mailto:tech-talk-bounces@aps.>____anl.gov <http://anl.gov>

        <mailto:tech-talk-bounces@aps.__anl.gov
        <mailto:tech-talk-bounces@aps.anl.gov>>>>] on behalf of Pavel
        Masloff
                    [pavel.masloff@gmail.com
        <mailto:pavel.masloff@gmail.com>
        <mailto:pavel.masloff@gmail.__com <mailto:pavel.masloff@gmail.com>>
        <mailto:pavel.masloff@gmail. <mailto:pavel.masloff@gmail.>____com
        <mailto:pavel.masloff@gmail.__com
        <mailto:pavel.masloff@gmail.com>>><mailto:pavel.masloff@
        <mailto:pavel.masloff@>__g__mail.com <http://gmail.com>
        <mailto:pavel.masloff@gmail.__com <mailto:pavel.masloff@gmail.com>>

        <mailto:pavel.masloff@gmail. <mailto:pavel.masloff@gmail.>____com

        <mailto:pavel.masloff@gmail.__com
        <mailto:pavel.masloff@gmail.com>>>>]
                    Sent: Saturday, April 28, 2012 2:17 AM
                    To: EPICS Tech Talk
                    Subject: [Scopes] BMP image record??

                    Hello again,


                    As I mentioned earlier we are running a series of
                experiments with
                    our high current switches. I have written simple support
                ("...with a
                    little help from my friend" Dirk Zimoch) for the
        Tektronix
                TPS2000
                    over RS232 using StreamDevice and ASYN, so now I can
                remotely arm
                    the scopes, set its properties, save waveforms on to
        the CF
                card,
                    etc. But...

                    In order to not run back and forth and see if
        everything went OK
                    (which is rather tiresome and time consuming), we need a
                    confirmation from the scopes. I don't want to deal
        with the
                    implementation of the waveform records for now, all
        I have
                got so
                    far is that I save them on the flash card.
                    As such a confirmation I see transferring the BMP
        (or PNG) image
                    from the scope (sort of Print screen) on to the
        operator PC
                somehow.

                    There is a special SCPI command "Hardcopy start". Which
                mimics the
                    Print button on the scope's front panel. I have tried to
                transfer a
                    BMP file via Hyperterminal (and Python script) and
        it worked out
                    well (more or less).
                    How could this be ported to the EPICS database from
        the IOC and
                    client standpoint, so an operator could see the
        oscillogram
                on the
                    screen and decide whether the experiment went well,
        so she
                will save
                    the waveforms and move on to the next experiment?

                    The image file is maximum ~ 46Kb (20Kb on average).
                    Any thoughts?


                    --
                    Best regards,


                    Pavel Maslov, MS
                    Controls Engineer at Pulsed power Lab
                    Efremov Institute for Electro-Physical Apparatus
                    St. Petersburg, Russia

                    Mobile: +7 (951) 672 22 19
                    Landline: +7 (812) 461 01 01



                    --
                    Best regards,


                    Pavel Maslov, MS
                    Controls Engineer at Pulsed power Lab
                    Efremov Institute for Electro-Physical Apparatus
                    St. Petersburg, Russia

                    Mobile: +7 (951) 672 22 19
                    Landline: +7 (812) 461 01 01




                --
                Best regards,


                Pavel Maslov, MS
                Controls Engineer at Pulsed power Lab
                Efremov Institute for Electro-Physical Apparatus
                St. Petersburg, Russia

                Mobile: +7 (951) 672 22 19
                Landline: +7 (812) 461 01 01





        --
        Best regards,


        Pavel Maslov, MS
        Controls Engineer at Pulsed power Lab
        Efremov Institute for Electro-Physical Apparatus
        St. Petersburg, Russia

        Mobile: +7 (951) 672 22 19
        Landline: +7 (812) 461 01 01





--
Best regards,


Pavel Maslov, MS
Controls Engineer at Pulsed power Lab
Efremov Institute for Electro-Physical Apparatus
St. Petersburg, Russia

Mobile: +7 (951) 672 22 19
Landline: +7 (812) 461 01 01


References:
[Scopes] BMP image record?? Pavel Masloff
RE: [Scopes] BMP image record?? Mark Rivers
Re: [Scopes] BMP image record?? Pavel Masloff
RE: [Scopes] BMP image record?? Mark Rivers
Re: [Scopes] BMP image record?? Pavel Masloff
Re: [Scopes] BMP image record?? Rod Nussbaumer
Re: [Scopes] BMP image record?? Pavel Masloff
Re: [Scopes] BMP image record?? Rod Nussbaumer
Re: [Scopes] BMP image record?? Pavel Masloff

Navigate by Date:
Prev: Re: [Scopes] BMP image record?? Pavel Masloff
Next: Re: [Scopes] BMP image record?? Rod Nussbaumer
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017 
Navigate by Thread:
Prev: Re: [Scopes] BMP image record?? Pavel Masloff
Next: Re: [Scopes] BMP image record?? Rod Nussbaumer
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017 
ANJ, 18 Nov 2013 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·