Experimental Physics and
| |||||||||||||||
|
Hello,
I have created following device support. Now what I want is to write values of a array(as per following code c2 array) to a waveform record(PV name: optoRead) in VDCT #include <stdio.h> #include <string.h> #include <stddef.h> #include <math.h> #include <stdlib.h> #include "alarm.h" #include "cvtTable.h" #include "dbDefs.h" #include "dbAccess.h" #include "recGbl.h" #include "recSup.h" #include "devSup.h" #include "link.h" #include "aiRecord.h" #include "waveformRecord.h" #include "epicsExport.h" int i; unsigned short c1[50],c2[10]; static long read_waveform(); static long read_wafopto(); //------------STRUCTURE FOR WAVEFORM--------- struct { long number; DEVSUPFUN report; DEVSUPFUN init; DEVSUPFUN init_record; DEVSUPFUN get_ioint_info; DEVSUPFUN read_waveform; } devmywaveform = { 5, NULL, NULL, NULL, NULL, read_waveform}; epicsExportAddress(dset,devmywaveform); //------------STRUCTURE FOR WAVEFORM to get opto-reading--------- struct { long number; DEVSUPFUN report; DEVSUPFUN init; DEVSUPFUN init_record; DEVSUPFUN get_ioint_info; DEVSUPFUN read_wafopto; } devwafopto = { 5, NULL, NULL, NULL, NULL, read_wafopto}; epicsExportAddress(dset,devwafopto); //-----------------CODE-----------------// static long read_waveform(pwaf) struct waveformRecord *pwaf; { //int i; long int n; unsigned short myptr[100]; struct dbAddr *paddr; //unsigned short c1[50],c2[10]; n = pwaf->nelm; paddr = dbGetPdbAddrFromLink(&pwaf->inp); dbGet(paddr,pwaf->ftvl,(void *)myptr,0,&n,NULL); for(i=0;i<=71;i++) { printf("\ndata=%x\n",myptr[i]); } for(i=0;i<36;i++) { if(myptr[i+36]==143) { c1[i]=myptr[i]-50; } else c1[i]=myptr[i]; } for(i=0;i<36;i++) { printf("\ndata1=%u %x\n",c1[i],c1[i]); } for(i=0;i<=4;i++) { c2[i]=c1[i+4]; } for(i=0;i<=4;i++) { printf("\ndata2=%u",c2[i]); } return(2); } //---DEVICE SUPPORT TO VDCT--- static long read_wafopto(popto) struct waveformRecord *popto; { //char *optoRead[10]; long int n; struct dbAddr *paddr; //paddr = dbGetPdbAddrFromLink(&inp->popto); //dbPut(paddr,popto->ftvl,(void *)c2,&n); n = popto->nelm; dbNameToAddr("optoRead.VAL",paddr); dbPut(paddr,popto->ftvl,(void *)c2,n); //popto->val=c2; return(2); } DB FILE: record(waveform, optoRead) { field(SCAN, "Passive") field(NELM, "4") field(FTVL, "USHORT") field(DTYP, "wafoptosupport") } I want to write value of c2 array in waveform record in VDCT. On doing "caget" I get following output: caget optoRead optoRead 4 3 0 0 0 Output should be: optoRead 4 127 255 0 0 When I do "make" i do not get any error but on doing "make clean install" I get following warning: ../aiDevsup.c: In function ‘read_wafopto’: ../aiDevsup.c:274:14: warning: ‘paddr’ is used uninitialized in this function [-Wuninitialized] dbNameToAddr("optoRead.VAL",paddr); Please suggest how to resolve this warning .Also suggest is there any other way to write this data in VDCT or is it possible to use any other record other than waveform. My ultimate aim is to get this data in VDCT and convert it in binary.
| ||||||||||||||
ANJ, 16 Dec 2015 |
·
Home
·
News
·
About
·
Base
·
Modules
·
Extensions
·
Distributions
·
Download
·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing · |