diff --git a/bus/m_epics_ca.tpp b/bus/m_epics_ca.tpp index 37e9c38..b2bd5ec 100644 --- a/bus/m_epics_ca.tpp +++ b/bus/m_epics_ca.tpp @@ -122,21 +122,6 @@ mEpicsCa::mEpicsCa(const char *pChanName, bool subscribe, dbfFromType(); int status = CM_SUCCESS; - /* - ca_disable_preemptive_callback: No callback thread is created and CA context - has to be "polled" (e.g. via ca_pend_event or ca_pend_io). All callbacks - happen in the main thread. - ca_enable_preemptive_callback: EPICS creates a dedicated callback thread - where the callback is run. - - Obviously, ca_enable_preemptive_callback is the variant we want for - subscription. - */ - auto choice = ca_preemptive_callback_select::ca_disable_preemptive_callback; - if (subscribe) { - choice = ca_preemptive_callback_select::ca_enable_preemptive_callback; - } - /* Try to create the Channel access context explicitly: https://docs.epics-controls.org/projects/base/en/latest/cadef_h.html#_CPPv417ca_context_create29ca_preemptive_callback_select @@ -146,7 +131,8 @@ mEpicsCa::mEpicsCa(const char *pChanName, bool subscribe, convertAndHandleEcaCode. Preemptive callbacks are disabled by default for this driver. */ - status = ca_context_create(choice); + status = ca_context_create( + ca_preemptive_callback_select::ca_enable_preemptive_callback); if (status != ECA_NOTTHREADED) { status = convertAndHandleEcaCode(status, this->_chanName.c_str()); } @@ -490,7 +476,7 @@ template int mEpicsCa::putRaw(int *value) { template void mEpicsCa::connStateCallback(struct connection_handler_args args) { - mEpicsCa *self = static_cast(ca_puser(args.chid)); + mEpicsCa *self = static_cast *>(ca_puser(args.chid)); if (args.op == CA_OP_CONN_UP) { struct ChInfo info; diff --git a/test/ioc/record.db b/test/ioc/record.db index 11f6ff3..741d891 100644 --- a/test/ioc/record.db +++ b/test/ioc/record.db @@ -5,6 +5,10 @@ record(longin, "MEPICSCA:TEST:LONGIN") { field(PINI, "YES") } +record(longout, "MEPICSCA:TEST:LONGOUT") { + field(VAL, 256) +} + record(ai, "MEPICSCA:TEST:AI") { field(VAL, 84) } diff --git a/test/m_epics_ca_test.cxx b/test/m_epics_ca_test.cxx index 7641563..2da9eae 100644 --- a/test/m_epics_ca_test.cxx +++ b/test/m_epics_ca_test.cxx @@ -102,6 +102,7 @@ int main() { // interact with the spawned IOC. auto int_ca = mEpicsCa("MEPICSCA:TEST:LONGIN", false); auto int_hopr_ca = mEpicsCa("MEPICSCA:TEST:LONGIN.HOPR", false); + auto int_longout_ca = mEpicsCa("MEPICSCA:TEST:LONGOUT", false); auto double_ca = mEpicsCa("MEPICSCA:TEST:AI", false); auto string_ca = mEpicsCa("MEPICSCA:TEST:STRINGIN", false); auto waveform_ca = mEpicsCa("MEPICSCA:TEST:WAVEFORM", false); @@ -198,6 +199,12 @@ int main() { EQUAL(status, CM_SUCCESS); EQUAL(int_val, 100); + // Read an integer from a longout + int_val = 0; + status = int_longout_ca.get(&int_val); + EQUAL(status, CM_SUCCESS); + EQUAL(int_val, 256); + // Read a double from a record double double_val = 0.0; status = double_ca.get(&double_val);