/* devSkidiv.c */
/*
 *      Author: Makoto Tobiyama
 *      Date:   12/Apr/2017
 */
#include <epicsStdio.h>
#include <devCommonGpib.h>
#include <string.h>
#include <strings.h>
/***********************************************************************
* asynDriver is distributed subject to a Software License Agreement
* found in file LICENSE that is included with this distribution.
***********************************************************************/
#defineDSET_AIdevAiSKIDIV
#defineDSET_AOdevAoSKIDIV
#defineDSET_BIdevBiSKIDIV
#defineDSET_BOdevBoSKIDIV
#defineDSET_LIdevLiSKIDIV
#defineDSET_LOdevLoSKIDIV
#defineDSET_MBBOdevMbboSKIDIV
#defineDSET_MBBIdevMbbiSKIDIV
#defineDSET_MBBODdevMbbodSKIDIV
#defineDSET_MBBIDdevMbbidSKIDIV
#defineDSET_SIdevSiSKIDIV
#defineDSET_SOdevSoSKIDIV
#include <devGpib.h> /* must be included after DSET defines */ #define TIMEOUT 0.5 /* I/O must complete within this time */ #define TIMEWINDOW 0.01 /* Wait this long after device timeout */ /* * Define end-of-string character(s) here to allow * easier changes when testing the driver. */ #define EOSNL 0 static struct gpibCmd gpibCmds[] = { /* Command 0 ch1 freq div set */ {&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "CH1:DIV %ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL }, /* Command 1 ch2 freq div set */ {&DSET_LO, GPIBWRITE, IB_Q_LOW,NULL,"CH2:DIV %ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL }, /* Command 2 ch1 freq div read */ {&DSET_LI, GPIBREAD, IB_Q_LOW,"CH1:DIV?\n","%ld\n",0, 2047, NULL, 0, 0, NULL, NULL, EOSNL}, /* Command 3 ch2 freq div read */ {&DSET_LI, GPIBREAD, IB_Q_LOW,"CH2:DIV?\n","%ld\n",0, 2047, NULL, 0, 0, NULL, NULL, EOSNL}, /* Command 4 ch1 freq delay set */ {&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "CH1:DEL %ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL }, /* Command 5 ch2 delay set */ {&DSET_LO, GPIBWRITE, IB_Q_LOW,NULL,"CH2:DEL %ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL }, /* Command 6 ch1 delay read */ {&DSET_LI, GPIBREAD, IB_Q_LOW,"CH1:DEL?\n","%ld\n",0, 2047, NULL, 0, 0, NULL, NULL, EOSNL}, /* Command 7 ch2 delay read */ {&DSET_LI, GPIBREAD, IB_Q_LOW,"CH2:DEL?\n","%ld\n",0, 2047, NULL, 0, 0, NULL, NULL, EOSNL}, /* Command 8 ch1 width set */ {&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "CH1:WID %ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL }, /* Command 9 ch2 width set */ {&DSET_LO, GPIBWRITE, IB_Q_LOW,NULL,"CH2:WID %ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL }, /* Command 10 ch1 width read */ {&DSET_LI, GPIBREAD, IB_Q_LOW,"CH1:WID?\n","%ld\n",0, 2047, NULL, 0, 0, NULL, NULL, EOSNL}, /* Command 11 ch2 width read */ {&DSET_LI, GPIBREAD, IB_Q_LOW,"CH2:WID?\n","%ld\n",0, 2047, NULL, 0, 0, NULL, NULL, EOSNL}, /* Command 12 EP195 set */ {&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "IF %ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL}, /* Command 13 EP195 read */ {&DSET_LI, GPIBREAD, IB_Q_LOW, "IF?\n","%ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL }, /* Command 14 external sync set */ {&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "SY %ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL }, /* Command 15 external sync read */ {&DSET_LI, GPIBREAD, IB_Q_LOW, "SY?\n", "%ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL }, /* Command 16 save config */ {&DSET_BO, GPIBWRITE, IB_Q_LOW, NULL, "SAV\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL} }; /* The following is the number of elements in the command array above. */
#define NUMPARAMSsizeof(gpibCmds)/sizeof(struct gpibCmd)
/****************************************************************************** * * Initialization for device support * This is called one time before any records are initialized with a parm * value of 0. And then again AFTER all record-level init is complete * with a param value of 1. * ******************************************************************************/ static long init_ai(int parm) { if(parm==0) { devSupParms.name = "devSKIDIV"; devSupParms.gpibCmds = gpibCmds; devSupParms.numparams = NUMPARAMS; devSupParms.timeout = TIMEOUT; devSupParms.timeWindow = TIMEWINDOW; devSupParms.respond2Writes = -1.0; } return(0); }