Hi,
i wrote a Device Server that subscribe to events with many device attributes and different data types… I implements only one callback method which is triggered when the events are received (push model).
I have an segmentation fault when receiving an event with data type different from the subscription one…
The problem comes from the allocation of the array in the cb.
i simply tried with tangotest and i have the same error ;(
extract of example subscribe event (data type of the attribute is DevDouble):
try
{
the_device = new Tango::DeviceProxy("sys/tg_test/1");
if (the_device->state() == Tango::FAULT)
{
set_state(Tango::FAULT);
}
else
{
cb = new DoubleEventCallBack();
if (cb!=NULL)
event_id=the_device->subscribe_event("long_scalar_w",Tango::CHANGE_EVENT,cb);
}
}
catch(Tango::DevFailed &e)
{
set_state(Tango::FAULT);
}
extract of the callback (array declaration in DevLong):
void DoubleEventCallBack::push_event(Tango::EventData *myevent)
{
Tango::DevVarLongArray *double_value;
try
{
if(!myevent->err)
{
*(myevent->attr_value) >> double_value;
delete double_value;
}
}
catch(int e)
{
cout << "DoubleEventCallBack::push_event(): could not extract data!\n";
}
}
Is it the good way to do this when i have to subsribe to events on dynamic attributes unknown in advance ?
Thanks for help