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

Subject: Re: Waveform read problems
To: Eric Norum <>
Cc: "" <>
Date: Fri, 27 Jul 2012 19:22:46 -0700 (PDT)
Hey Eric,

Thanks for looking at this. Here is my startup script:

## You may have to change DrvTest to something else
## everywhere it appears in this file
< envPaths
epicsEnvSet(EPICS_CA_MAX_ARRAY_BYTES, 100000)
cd /home/admx/admxepics/iocs/DrvTest
## Register all support components
dbLoadDatabase "dbd/DrvTest.dbd"
DrvTest_registerRecordDeviceDriver pdbbase
##Load Prologix Driver
##prologixGPIBConfigure("L0", "",0,1)
##asynOctetSetInputEos("L0", -1, "\n")
##asynSetTraceIOMask("L0_TCP", -1, 0x2)
##asynSetTraceMask("L0_TCP", -1, 0x9)
##asynSetTraceIOMask("L0", 5, 0x2)
##asynAutoConnect "L0" -1 1 ##epicsThreadSleep 2
prologixGPIBConfigure("L0", "")
asynSetTraceIOMask("L1", -1, 0x2)
asynSetTraceMask("L1", -1, 0x9)
asynSetTraceIOTruncateSize("L1", -1, 16384)
## Load record instances
cd /home/admx/admxepics/devices/ag8648B
cd /home/admx/admxepics/devices/agE5071C
cd /home/admx/admxepics/iocs/DrvTest/iocBoot/iocDrvTest

Actually, I think I figured out some of what was confusing me earlier. By Setting the asynSetTraceIOTruncateSize sufficiently large I can at least see the entirety of what asyn is reading. When processing a wf record the behavior is, read 2048 characters at a time until message ends then Segmentation violation. When processing asynOctetWriteRead the behavior is read first 2048 characters then stop. If you can't guess what could cause the segfault (see first message in this thread) then I'll try updating to a stream device driver. Thanks again for all your help.



epics> asynOctetConnect("NW","L1")
epics> asynOctetWriteRead("NW",":SENS1:FREQ:DATA?")
2012/07/27 19:11:07.620 write 18
2012/07/27 19:11:07.622 read 2048
eomReason 0x1

On Fri, 27 Jul 2012, Eric Norum wrote:

An alternative question is why the interposeEOS layer is present.
What xxxxConfigure command are you using to create the asyn port?
What other asynXXXXX commands are in your startup script?
Please send the entire startup script for us to have a look at.

On Jul 27, 2012, at 6:10 PM, Andrew Wagner wrote:

Ah! Now the question why doesn't it seem to do this. In the example below I read 2048 characters then get an eomReason 0x1 then nothing. I don't think you need my network analyzer to debug this, just something that sends a long string of numbers.


On Jul 27, 2012, at 5:52 PM, Eric Norum wrote:

Yes, there is a 2048-character buffer -- it's in the interposeEOS layer.  That's why the read is returning with EOM=COUNT.
But the interposeEOS layer should then just issue another read until the incoming message really does end.

On Jul 27, 2012, at 5:45 PM, Mark Rivers wrote:

asyn reads as much data as the device sends.  There is no buffer size limit of 2048 anywhere in asyn.  I suspect your device is sending data in 2048 character chunks, and you need to do another "read" operation to get the next chunk of data.  Is this GPIB, Ethernet, or serial?


-----Original Message-----
From: []
Sent: Friday, July 27, 2012 7:24 PM
To: Mark Rivers
Subject: RE: Waveform read problems

Thanks for the advice. I'll definitely look into StreamDevice, it sounds really nice. Unfortunately, I've done a little more debugging and I'm pretty sure the problem is in asyn, not my driver. For instance when I try to connect directly with asynOctet, I get:

epics> asynOctetConnect("NW","L1")
epics> asynOctetWriteRead("NW","*IDN?")
2012/07/27 16:43:04.491 write 6
2012/07/27 16:43:04.492 read 47
Agilent Technologies,E5071C,MY46213997,A.10.06\n
eomReason 0x2
Agilent Technologies,E5071C,MY46213997,A.10.06
epics> asynOctetWriteRead("NW",":SENS1:FREQ:DATA?")
2012/07/27 16:43:17.503 write 18
2012/07/27 16:43:17.505 read 2048
eomReason 0x1

No Segfault this time however, the entire data stream is truncated after 2048 characters. I'm getting the impression there is something fundamental I'm not understanding about how asyn manages data. I looked over Eric's Stream device tutorial and could find no reason why converting my driver support to stream device would solve this problem since asyn is still handling the communication. My problem remains that I don't understand how to get asyn to read more than 2048 characters. The solution must be very simple otherwise asyn could never have been used with a wf record.



On Fri, 27 Jul 2012, Mark Rivers wrote:

You might want to consider using streamDevice rather than the asynGpib software.  asynGpib is rather obsolete; steamDevice is much nicer.  You don't need to write any C code if you use streamDevice.

Eric Norum has recently written a new version of his "HowToDoSerial" tutorial, explaining how to use asyn with streamDevice.  It will be in the next release of asyn, but meanwhile you can find it here:


From: [] on behalf of []
Sent: Friday, July 27, 2012 4:53 PM
Subject: Waveform read problems

Hey Everyone,

I'm using Asyn to create a driver for the Agilent E5071C Network analyzer and am trying to create a working waveform record to readout the analyzer traces. The output of the analyzer is a list of ASCII values separated by commas. For instance, :SENS1:FREQ:DATA? returns the frequency values where the power was measured in Hz. The output is:+5.00000000000E+008,+5.05000000000E+008,+5.10000000000E+008,+5.15000000000E+008,+5.20000000000E+008,+5.25000000000E+008, ... I'm able to communicate with the analyzer, however I create a Segmentation violation when processing waveform records to store this array.

epics> dbtr AGE5071C:FREQ
ACKS: NO_ALARM      ACKT: YES           APST: Always        ASG:
BKPT: 00            BUSY: 0             DESC: Frequency Series Hz
DISA: 0             DISP: 0             DISS: NO_ALARM      DISV: 1
2012/07/27 14:12:12.823 DTYP: AGE5071C      EGU: Hz             EVNT: 0             FLNK:CONSTANT 0 write 18
:SEFTVL: DOUBLE        HASH: 0             HOPR: 0
NS1INP:GPIB_IO #L1 A0 @9                   LCNT: 0             LOPR: 0
:FREMPST: Always        NAME: AGE5071C:FREQ NELM: 10000         NORD: 0
Q:DANSEV: NO_ALARM      NSTA: NO_ALARM      PACT: 1             PHAS: 0
TA?PINI: NO            PREC: 0             PRIO: LOW           PROC: 0
PUTF: 0             RARM: 0             RPRO: 0             SCAN: Passive
SIMS: NO_ALARM      SIOL:CONSTANT       STAT: UDF           TIME: <undefined>
TPRO: 0             TSE: 0              TSEL:CONSTANT       UDF: 1
VAL: (nil)
epics> 2012/07/27 14:12:12.825 read 2048
2012/07/27 14:12:12.825 read 1972
Segmentation fault

I'm defining the gpibCMD as:


and the custom convert routine I'm using is:

// WF read routine for AGE5071C
static int readWF(struct gpibDpvt *pdpvt,int P1, int P2, char**P3) {


struct waveformRecord *pwf=(struct waveformRecord *)pdpvt->precord;
asynUser *pasynUser = pdpvt->pasynUser;

double* value = (double *)pwf->bptr;
double data;
int n;
char* buffer = "\0";


while ((pwf->nord < pwf->nelm) && sscanf(buffer,"%lE,%n",&data,&n)==1) {


asynPrint(pasynUser,ASYN_TRACE_FLOW,"(NORD,VAL) : (%i,%E)\n",pwf->nord,data);


if (pwf->nord == 0) return -1;

return 0;


Since none of my error messages are printed I conclude the pdpvt->msg array is being overfilled somehow before my convert routine is even processed. I'm really not sure how to debug this since everything that I've written seems to work fine. The debug messages reveal no problems until the Segmentation violation occurs. I also don't understand why the reads can only handle a maximum of 2048 characters at a time. If anyone has experience writing device support for a waveform record your advice would be very helpful. Thanks.


Eric Norum

Eric Norum

RE: Waveform read problems Mark Rivers
Re: Waveform read problems Eric Norum
Re: Waveform read problems Eric Norum

Navigate by Date:
Prev: Re: Waveform read problems Eric Norum
Next: RE: Waveform read problems Mark Rivers
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  2020 
Navigate by Thread:
Prev: Re: Waveform read problems Eric Norum
Next: RE: Waveform read problems Mark Rivers
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  2020 
ANJ, 18 Nov 2013 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·