Sent: Friday, May 11, 2012 9:07 AM
To: Mark Rivers
Cc: EPICS Tech Talk
Subject: Re: [CA][waveform] how to NELM?
Thanks, Mark! It works if I am reading just one PV. But when I
am reading 2 PVs - (waveform and NELM), my NELM value is
enormously big!!!
How can I read several PVs?
This is my code:
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "cadef.h"
int main(int argc,char **argv)
{
int data; /* NELM */
chid mychid;
chid chan; /* WAVEFORM - file*/
int status;
unsigned elementCount, nBytes, i;
struct dbr_time_char * pTD;
const dbr_char_t * pValue;
SEVCHK(ca_context_create(ca_
disable_preemptive_callback),"
ca_context_create");
SEVCHK(ca_create_channel("
file.NORD",NULL,NULL,10,&
mychid),"ca_create_channel failure");
SEVCHK(ca_pend_io(1.0),"ca_
pend_io failure");
SEVCHK(ca_get(DBR_INT,mychid,(
void *)&data),"ca_get failure");
SEVCHK(ca_pend_io(1.0),"ca_
pend_io failure");
printf("file.NORD: %d\n",data);
ca_clear_channel ( mychid );
ca_task_exit ();
SEVCHK(ca_context_create(ca_
disable_preemptive_callback),"
ca_context_create");
status = ca_create_channel ( argv[1], 0, 0, 0, & chan );
ca_search(argv[1], &chan);
SEVCHK ( status, "ca_create_channel()" );
status = ca_pend_io ( 1.0 );
if ( status != ECA_NORMAL ) {
fprintf ( stderr, "\"%s\" not found.\n", argv[1] );
return -1;
}
elementCount = ca_element_count ( chan );
nBytes = dbr_size_n ( DBR_TIME_CHAR, elementCount );
pTD = ( struct dbr_time_char * ) malloc ( nBytes );
if ( ! pTD ) {
fprintf ( stderr, "insufficient memory to complete
request\n" );
return -1;
}
status = ca_array_get (DBR_TIME_CHAR, elementCount, chan, pTD );
SEVCHK ( status, "ca_array_get()" );
status = ca_pend_io ( 1.0 );
if ( status != ECA_NORMAL ) {
fprintf ( stderr, "\"%s\" didnt return a value.\n",
argv[1] );
return -1;
}
pValue = & pTD->value;
for ( i = 0; i < 10; i++ ) printf("%d ", pValue[i]);
printf("\nTotal size: %d\n", elementCount);
printf("Timestamp: %d\n", pTD->stamp.nsec);
ca_clear_channel ( chan );
free ( pTD );
return(0);
}
On Fri, May 11, 2012 at 3:42 PM, Mark Rivers
<
[email protected]