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