Go to the documentation of this file.00001 """autogenerated by genpy from shared_serial/Send.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 Send(genpy.Message):
00009 _md5sum = "9488c54395f85f0662ca59801f32b45a"
00010 _type = "shared_serial/Send"
00011 _has_header = False
00012 _full_text = """# Send data to serial port.
00013
00014 # Eeither 0 (connectionless) or an unexpired socket identifier
00015 # from an earlier communication.
00016 uint32 socket
00017
00018 # Data to be sent.
00019 uint8[] data
00020
00021 # Number of seconds to keep the port locked after this communication.
00022 float32 timeout
00023
00024 """
00025 __slots__ = ['socket','data','timeout']
00026 _slot_types = ['uint32','uint8[]','float32']
00027
00028 def __init__(self, *args, **kwds):
00029 """
00030 Constructor. Any message fields that are implicitly/explicitly
00031 set to None will be assigned a default value. The recommend
00032 use is keyword arguments as this is more robust to future message
00033 changes. You cannot mix in-order arguments and keyword arguments.
00034
00035 The available fields are:
00036 socket,data,timeout
00037
00038 :param args: complete set of field values, in .msg order
00039 :param kwds: use keyword arguments corresponding to message field names
00040 to set specific fields.
00041 """
00042 if args or kwds:
00043 super(Send, self).__init__(*args, **kwds)
00044
00045 if self.socket is None:
00046 self.socket = 0
00047 if self.data is None:
00048 self.data = ''
00049 if self.timeout is None:
00050 self.timeout = 0.
00051 else:
00052 self.socket = 0
00053 self.data = ''
00054 self.timeout = 0.
00055
00056 def _get_types(self):
00057 """
00058 internal API method
00059 """
00060 return self._slot_types
00061
00062 def serialize(self, buff):
00063 """
00064 serialize message into buffer
00065 :param buff: buffer, ``StringIO``
00066 """
00067 try:
00068 buff.write(_struct_I.pack(self.socket))
00069 _x = self.data
00070 length = len(_x)
00071
00072 if type(_x) in [list, tuple]:
00073 buff.write(struct.pack('<I%sB'%length, length, *_x))
00074 else:
00075 buff.write(struct.pack('<I%ss'%length, length, _x))
00076 buff.write(_struct_f.pack(self.timeout))
00077 except struct.error as se: self._check_types(se)
00078 except TypeError as te: self._check_types(te)
00079
00080 def deserialize(self, str):
00081 """
00082 unpack serialized message in str into this message instance
00083 :param str: byte array of serialized message, ``str``
00084 """
00085 try:
00086 end = 0
00087 start = end
00088 end += 4
00089 (self.socket,) = _struct_I.unpack(str[start:end])
00090 start = end
00091 end += 4
00092 (length,) = _struct_I.unpack(str[start:end])
00093 start = end
00094 end += length
00095 if python3:
00096 self.data = str[start:end].decode('utf-8')
00097 else:
00098 self.data = str[start:end]
00099 start = end
00100 end += 4
00101 (self.timeout,) = _struct_f.unpack(str[start:end])
00102 return self
00103 except struct.error as e:
00104 raise genpy.DeserializationError(e)
00105
00106
00107 def serialize_numpy(self, buff, numpy):
00108 """
00109 serialize message with numpy array types into buffer
00110 :param buff: buffer, ``StringIO``
00111 :param numpy: numpy python module
00112 """
00113 try:
00114 buff.write(_struct_I.pack(self.socket))
00115 _x = self.data
00116 length = len(_x)
00117
00118 if type(_x) in [list, tuple]:
00119 buff.write(struct.pack('<I%sB'%length, length, *_x))
00120 else:
00121 buff.write(struct.pack('<I%ss'%length, length, _x))
00122 buff.write(_struct_f.pack(self.timeout))
00123 except struct.error as se: self._check_types(se)
00124 except TypeError as te: self._check_types(te)
00125
00126 def deserialize_numpy(self, str, numpy):
00127 """
00128 unpack serialized message in str into this message instance using numpy for array types
00129 :param str: byte array of serialized message, ``str``
00130 :param numpy: numpy python module
00131 """
00132 try:
00133 end = 0
00134 start = end
00135 end += 4
00136 (self.socket,) = _struct_I.unpack(str[start:end])
00137 start = end
00138 end += 4
00139 (length,) = _struct_I.unpack(str[start:end])
00140 start = end
00141 end += length
00142 if python3:
00143 self.data = str[start:end].decode('utf-8')
00144 else:
00145 self.data = str[start:end]
00146 start = end
00147 end += 4
00148 (self.timeout,) = _struct_f.unpack(str[start:end])
00149 return self
00150 except struct.error as e:
00151 raise genpy.DeserializationError(e)
00152
00153 _struct_I = genpy.struct_I
00154 _struct_f = struct.Struct("<f")