本文整理匯總了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)