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