def get_property_name(self, to, requested_property_id):
"""
Sends a message down the serial line requesting the command name of a given command ID,
used in discovery protocol
:param to: destination item ID
:param requested_property_id: property ID that we want to know the name of
:return: name of the property from Embedded Core
"""
try:
response = yield self.send_command(to, command_id=GET_PROPERTY_NAME, params=["property_id"],
data=[requested_property_id])
except Exception as e:
logger.error("[PCOM] Unable to find property name for property {0} because of exception: {1}".format(
requested_property_id, e))
defer.returnValue(None)
# The data in the response message will be a list,
# the property name should be in the 0th position
# and strip the NULL byte.
try:
defer.returnValue(response.data[0])
except IndexError:
logger.error("Response from embedded board during discovery sequence did not return data in "
"expect format. Expected at least one data field, received: {0}".format(response.data))
defer.returnValue(None)
评论列表
文章目录