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

Subject: Accessing waveform record values in C
From: "Wang, Andrew via Tech-talk" <tech-talk at aps.anl.gov>
To: "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>
Date: Wed, 17 Feb 2021 18:09:59 +0000

All,

 

Basically I have a waveform record that contains ASCII values of chars shown below.

 

record(waveform, "waveform_record")

{

              field(DESC, "")

              field(SCAN, "Passive")

              field(FTVL, "CHAR")

              field(NELM, 250)

}

 

When I input caget waveform_record, I get:

 

waveform_record 250 72 101 108 108 111 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.

 

My goal is to access 72, 101, 108, 108, and 111 in a C code for an asub record.

 

record(aSub, "asub_record")

{

              field(DESC, "")

              field(SCAN, "Passive")

              field(SNAM, "c_code")

              field(INPA, "waveform_record")

              field(NOA, 250)

              …

}

 

In my C code, I attempt to access the waveform record.

 

char *waveform_record = (char *)prec->a;

printf("%s\n", waveform_record);

 

The terminal only prints out 72, the first element. But when I try to do

 

char *waveform_record = (char *)prec->a;

printf("%s\n", *(waveform_record + 4));

 

I get a segmentation fault rather than 111. Any advice on how I could potentially access the other elements in the waveform record? Feel like I am missing something very basic here.

 

Thanks,

Andy

 

 


Replies:
Re: Accessing waveform record values in C Andy Foster via Tech-talk

Navigate by Date:
Prev: RE: Issue with record processing and being able to process records after a certain amount of delay Wang, Andrew via Tech-talk
Next: Re: masarService on Ubuntu 20.04 python3 and Qt5 Shen, Guobao via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  <20212022  2023  2024 
Navigate by Thread:
Prev: Re: masarService on Ubuntu 20.04 python3 and Qt5 kunal shroff via Tech-talk
Next: Re: Accessing waveform record values in C Andy Foster via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  <20212022  2023  2024 
ANJ, 18 Feb 2021 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·