00001 """autogenerated by genmsg_py from BZ2Packet.msg. Do not edit."""
00002 import roslib.message
00003 import struct
00004
00005
00006 class BZ2Packet(roslib.message.Message):
00007 _md5sum = "37a209db6e0c11cc6c12601cdd2e4aef"
00008 _type = "bz2_transport/BZ2Packet"
00009 _has_header = False
00010 _full_text = """uint32 original_length
00011 uint8[] buffer
00012
00013 """
00014 __slots__ = ['original_length','buffer']
00015 _slot_types = ['uint32','uint8[]']
00016
00017 def __init__(self, *args, **kwds):
00018 """
00019 Constructor. Any message fields that are implicitly/explicitly
00020 set to None will be assigned a default value. The recommend
00021 use is keyword arguments as this is more robust to future message
00022 changes. You cannot mix in-order arguments and keyword arguments.
00023
00024 The available fields are:
00025 original_length,buffer
00026
00027 @param args: complete set of field values, in .msg order
00028 @param kwds: use keyword arguments corresponding to message field names
00029 to set specific fields.
00030 """
00031 if args or kwds:
00032 super(BZ2Packet, self).__init__(*args, **kwds)
00033
00034 if self.original_length is None:
00035 self.original_length = 0
00036 if self.buffer is None:
00037 self.buffer = ''
00038 else:
00039 self.original_length = 0
00040 self.buffer = ''
00041
00042 def _get_types(self):
00043 """
00044 internal API method
00045 """
00046 return self._slot_types
00047
00048 def serialize(self, buff):
00049 """
00050 serialize message into buffer
00051 @param buff: buffer
00052 @type buff: StringIO
00053 """
00054 try:
00055 buff.write(_struct_I.pack(self.original_length))
00056 _x = self.buffer
00057 length = len(_x)
00058
00059 if type(_x) in [list, tuple]:
00060 buff.write(struct.pack('<I%sB'%length, length, *_x))
00061 else:
00062 buff.write(struct.pack('<I%ss'%length, length, _x))
00063 except struct.error as se: self._check_types(se)
00064 except TypeError as te: self._check_types(te)
00065
00066 def deserialize(self, str):
00067 """
00068 unpack serialized message in str into this message instance
00069 @param str: byte array of serialized message
00070 @type str: str
00071 """
00072 try:
00073 end = 0
00074 start = end
00075 end += 4
00076 (self.original_length,) = _struct_I.unpack(str[start:end])
00077 start = end
00078 end += 4
00079 (length,) = _struct_I.unpack(str[start:end])
00080 start = end
00081 end += length
00082 self.buffer = str[start:end]
00083 return self
00084 except struct.error as e:
00085 raise roslib.message.DeserializationError(e)
00086
00087
00088 def serialize_numpy(self, buff, numpy):
00089 """
00090 serialize message with numpy array types into buffer
00091 @param buff: buffer
00092 @type buff: StringIO
00093 @param numpy: numpy python module
00094 @type numpy module
00095 """
00096 try:
00097 buff.write(_struct_I.pack(self.original_length))
00098 _x = self.buffer
00099 length = len(_x)
00100
00101 if type(_x) in [list, tuple]:
00102 buff.write(struct.pack('<I%sB'%length, length, *_x))
00103 else:
00104 buff.write(struct.pack('<I%ss'%length, length, _x))
00105 except struct.error as se: self._check_types(se)
00106 except TypeError as te: self._check_types(te)
00107
00108 def deserialize_numpy(self, str, numpy):
00109 """
00110 unpack serialized message in str into this message instance using numpy for array types
00111 @param str: byte array of serialized message
00112 @type str: str
00113 @param numpy: numpy python module
00114 @type numpy: module
00115 """
00116 try:
00117 end = 0
00118 start = end
00119 end += 4
00120 (self.original_length,) = _struct_I.unpack(str[start:end])
00121 start = end
00122 end += 4
00123 (length,) = _struct_I.unpack(str[start:end])
00124 start = end
00125 end += length
00126 self.buffer = str[start:end]
00127 return self
00128 except struct.error as e:
00129 raise roslib.message.DeserializationError(e)
00130
00131 _struct_I = roslib.message.struct_I