本文整理匯總了Python中constants.Constants.serialize_packet方法的典型用法代碼示例。如果您正苦於以下問題:Python Constants.serialize_packet方法的具體用法?Python Constants.serialize_packet怎麽用?Python Constants.serialize_packet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類constants.Constants
的用法示例。
在下文中一共展示了Constants.serialize_packet方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _send_request
# 需要導入模塊: from constants import Constants [as 別名]
# 或者: from constants.Constants import serialize_packet [as 別名]
def _send_request(self, byte, expected_response=None):
data = Constants.serialize_packet(byte)
self.ser.write(data)
response = self._get_response()
if expected_response is not None and expected_response != response:
raise PnuematicActuatorDriverResponseError(response, expected_response)
return response
示例2: write
# 需要導入模塊: from constants import Constants [as 別名]
# 或者: from constants.Constants import serialize_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)