Probelem while assigning property to attributes

Hi all,


DbDatum Speed("Speed"), min_speed("min_value"), max_speed("max_value"),min_alarm("min_alarm"), max_alarm("max_alarm");

	DbData db_data;

	Speed << 2;
	min_alarm << 20.0;
	max_speed << 100.0;

	db_data.push_back(Speed);
	db_data.push_back(min_alarm);
	db_data.push_back(max_speed);

	db->put_device_attribute_property("d/d/d", db_data);
I am trying to assign properties to attribute through code as above. It is working fine. But when I tried this,

DbData db_data;

	Speed << 2;
	min_alarm << 20.0;

	db_data.push_back(Speed);
	db_data.push_back(min_alarm);

	db->put_device_attribute_property("d/d/d", db_data);
It shows an error.It seems that DbData takes exactly three arguments. Is it so?

Regards,
TCS_GMRT
Hi,

without the error stack I don't know the problem but have you tried to use a new instance of DbData? Maybe the error is due to you reusing DbData.

Andy

Hi Andy,

I simply getting Segmentation Fault. Actually when I tried to assign two property, it is working fine as I described earlier. But instead, when I tried to assign one or three property, I am getting Segmentation fault.

Thanks & Regards,
TCS-GMRT
Regards,
TCS_GMRT
Hi,

There is a misunderstanding here. I agree the doc is not very clear on that point.
When you want to put/update device attribute property(ies), you need the following info:
  • The device name
  • The attribute name
  • The property name(s) and value(es)
The rule of the first DbDatum instance inserted in the DbData vector is to specify the attribute name and the number of
property to put/update. Its name is the attribute name and its value is the number of property to put/update.
In your first example, everything works fine because you specify 2 as the number of property to put/update and you insert
2 instances of DbDatum instance in the DbData vector (thus the vector has 3 elements).
In your second code snippet, you still specify that you want to put/update 2 properties but you provide
only one DbDatum instance!!

Hoping this help

Emmanuel
Hi Manu,

You are right. It worked.

Thanks for help to all.

Thanks & Regards,
TCS-GMRT
Regards,
TCS_GMRT
 
Register or login to create to post a reply.