_AudioData.py
Go to the documentation of this file.
00001 """autogenerated by genpy from audio_common_msgs/AudioData.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 AudioData(genpy.Message):
00009   _md5sum = "f43a8e1b362b75baa741461b46adc7e0"
00010   _type = "audio_common_msgs/AudioData"
00011   _has_header = False #flag to mark the presence of a Header object
00012   _full_text = """uint8[] data
00013 
00014 """
00015   __slots__ = ['data']
00016   _slot_types = ['uint8[]']
00017 
00018   def __init__(self, *args, **kwds):
00019     """
00020     Constructor. Any message fields that are implicitly/explicitly
00021     set to None will be assigned a default value. The recommend
00022     use is keyword arguments as this is more robust to future message
00023     changes.  You cannot mix in-order arguments and keyword arguments.
00024 
00025     The available fields are:
00026        data
00027 
00028     :param args: complete set of field values, in .msg order
00029     :param kwds: use keyword arguments corresponding to message field names
00030     to set specific fields.
00031     """
00032     if args or kwds:
00033       super(AudioData, self).__init__(*args, **kwds)
00034       #message fields cannot be None, assign default values for those that are
00035       if self.data is None:
00036         self.data = ''
00037     else:
00038       self.data = ''
00039 
00040   def _get_types(self):
00041     """
00042     internal API method
00043     """
00044     return self._slot_types
00045 
00046   def serialize(self, buff):
00047     """
00048     serialize message into buffer
00049     :param buff: buffer, ``StringIO``
00050     """
00051     try:
00052       _x = self.data
00053       length = len(_x)
00054       # - if encoded as a list instead, serialize as bytes instead of string
00055       if type(_x) in [list, tuple]:
00056         buff.write(struct.pack('<I%sB'%length, length, *_x))
00057       else:
00058         buff.write(struct.pack('<I%ss'%length, length, _x))
00059     except struct.error as se: self._check_types(se)
00060     except TypeError as te: self._check_types(te)
00061 
00062   def deserialize(self, str):
00063     """
00064     unpack serialized message in str into this message instance
00065     :param str: byte array of serialized message, ``str``
00066     """
00067     try:
00068       end = 0
00069       start = end
00070       end += 4
00071       (length,) = _struct_I.unpack(str[start:end])
00072       start = end
00073       end += length
00074       if python3:
00075         self.data = str[start:end].decode('utf-8')
00076       else:
00077         self.data = str[start:end]
00078       return self
00079     except struct.error as e:
00080       raise genpy.DeserializationError(e) #most likely buffer underfill
00081 
00082 
00083   def serialize_numpy(self, buff, numpy):
00084     """
00085     serialize message with numpy array types into buffer
00086     :param buff: buffer, ``StringIO``
00087     :param numpy: numpy python module
00088     """
00089     try:
00090       _x = self.data
00091       length = len(_x)
00092       # - if encoded as a list instead, serialize as bytes instead of string
00093       if type(_x) in [list, tuple]:
00094         buff.write(struct.pack('<I%sB'%length, length, *_x))
00095       else:
00096         buff.write(struct.pack('<I%ss'%length, length, _x))
00097     except struct.error as se: self._check_types(se)
00098     except TypeError as te: self._check_types(te)
00099 
00100   def deserialize_numpy(self, str, numpy):
00101     """
00102     unpack serialized message in str into this message instance using numpy for array types
00103     :param str: byte array of serialized message, ``str``
00104     :param numpy: numpy python module
00105     """
00106     try:
00107       end = 0
00108       start = end
00109       end += 4
00110       (length,) = _struct_I.unpack(str[start:end])
00111       start = end
00112       end += length
00113       if python3:
00114         self.data = str[start:end].decode('utf-8')
00115       else:
00116         self.data = str[start:end]
00117       return self
00118     except struct.error as e:
00119       raise genpy.DeserializationError(e) #most likely buffer underfill
00120 
00121 _struct_I = genpy.struct_I
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends


audio_common_msgs
Author(s): Nate Koenig
autogenerated on Thu Aug 29 2013 00:17:03