本文整理汇总了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)