本文整理汇总了Python中constants.Constants.deserialize_packet方法的典型用法代码示例。如果您正苦于以下问题:Python Constants.deserialize_packet方法的具体用法?Python Constants.deserialize_packet怎么用?Python Constants.deserialize_packet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类constants.Constants
的用法示例。
在下文中一共展示了Constants.deserialize_packet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_response
# 需要导入模块: from constants import Constants [as 别名]
# 或者: from constants.Constants import deserialize_packet [as 别名]
def _get_response(self):
data = self.ser.read(2)
if len(data) != 2:
raise PnuematicActuatorTimeoutError()
response = Constants.deserialize_packet(data)
data = response[0]
chksum = response[1]
self._verify_checksum(data, chksum)
return data
示例2: write
# 需要导入模块: from constants import Constants [as 别名]
# 或者: from constants.Constants import deserialize_packet [as 别名]
def write(self, data):
request = Constants.deserialize_packet(data)
request = request[0]
if request == Constants.PING_REQUEST:
rospy.loginfo('Ping received')
byte = Constants.PING_RESPONSE
elif request > 0x20 and request < 0x30:
rospy.loginfo('Open port {}'.format(request - 0x20))
byte = Constants.OPEN_RESPONSE
elif request > 0x30 and request < 0x40:
rospy.loginfo('Close port {}'.format(request - 0x30))
byte = Constants.CLOSE_RESPONSE
else:
rospy.loginfo('Default')
byte = 0x00
self.buffer += Constants.serialize_packet(byte)
return len(data)