caget returns wrong data when used with subArray record
Bug #1858829 reported by
Martin Konrad
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
EPICS Base |
Invalid
|
Undecided
|
Martin Konrad |
Bug Description
Asynchronous caget, camonitor and CS-Studio probe work correctly:
$ caget -c LS1_CA01:
LS1_CA01:
konrad@
LS1_CA01:
^C
However, synchronous caget prints the whole array rather than just the
element the subArray record extracts:
$ caget LS1_CA01:
LS1_CA01:
See the attached file for details about the record.
To post a comment you must log in.
This isn't actually a bug, it's a feature of doing a synchronous get and the fact that the subArray's VAL field *could* return up to MALM elements if the NELM field were set to that.
At connection time a CA channel provides the application with the maximum number of elements that could be transported through that channel. The synchronous ca_array_get() API provides no way for the CA library to tell the application code how many elements were actually returned (NORD) by the get operation — the application hands the library a buffer for a specific number of elements, but there is nowhere for the library to tell the application how many were actually retrieved. The library zero-fills the remainder of the buffer. The asynchronous ca_array_ get_callback( ) API tells the application how many elements were returned in the arguments it passes to the callback routine.
Unless you tell it otherwise the caget program has to assume that the channel will return the maximum number of elements, so that's the buffer size it prepares and prints. If you want it to only fetch and print one element, give it -#1 or use -c to have it do an asynchronous get.