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