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:
http://cars.uchicago.edu/software/epics/HowToDoSerial_StreamDevice.html
Cheers,
Mark
________________________________________
From: [email protected] [[email protected]] on behalf of [email protected] [[email protected]]
Sent: Friday, July 27, 2012 4:53 PM
To: [email protected]
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
10.95.101.61:5025 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
\n
PUTF: 0 RARM: 0 RPRO: 0 SCAN: Passive
SDIS:CONSTANT SEVR: INVALID SIML:CONSTANT SIMM: NO
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 10.95.101.61:5025 read 2048
+5.00000000000E+008,+5.05000000000E+008,+5.10000000000E+008,+5.15000000000E+008,+5.20000000000E+008,+5.25000000000E+008,
2012/07/27 14:12:12.825 10.95.101.61:5025 read 1972
000000E+009,+1.01500000000E+009,+1.02000000000E+009,+1.02500000000E+009,+1.03000000000E+009,+1.03500000000E+009,+1.04000
Segmentation fault
I'm defining the gpibCMD as:
{&DSET_WF, GPIBREAD, IB_Q_HIGH, ":SENS1:FREQ:DATA?", NULL, 0, 32000, readWF, 0, 0, NULL, NULL, NULL},
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) {
printf("%s","TEST****************************************");
struct waveformRecord *pwf=(struct waveformRecord *)pdpvt->precord;
asynUser *pasynUser = pdpvt->pasynUser;
double* value = (double *)pwf->bptr;
double data;
int n;
char* buffer = "\0";
pwf->nord=0;
strcpy(buffer,pdpvt->msg);
while ((pwf->nord < pwf->nelm) && sscanf(buffer,"%lE,%n",&data,&n)==1) {
memcpy(value+pwf->nord,&data,sizeof(double));
pwf->nord++;
buffer+=n;
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.
Andrew