def send(self, data):
if not isinstance(data, C1218Packet):<EOL><INDENT>data = C1218Packet(data)<EOL><DEDENT>if self.toggle_control:  <EOL><INDENT>if self._toggle_bit:<EOL><INDENT>data.set_control(ord(data.control) | <NUM_LIT>)<EOL>self._toggle_bit = False<EOL><DEDENT>elif not self._toggle_bit:<EOL><INDENT>if ord(data.control) & <NUM_LIT>:<EOL><INDENT>data.set_control(ord(data.control) ^ <NUM_LIT>)<EOL><DEDENT>self._toggle_bit = True<EOL><DEDENT><DEDENT>elif self.toggle_control and not isinstance(data, C1218Packet):<EOL><INDENT>self.loggerio.warning('<STR_LIT>')<EOL><DEDENT>data = data.build()<EOL>self.loggerio.debug("<STR_LIT>".format(len(data), binascii.b2a_hex(data).decode('<STR_LIT:utf-8>')))<EOL>for pktcount in range(<NUM_LIT:0>, <NUM_LIT:3>):<EOL><INDENT>self.write(data)<EOL>response = self.serial_h.read(<NUM_LIT:1>)<EOL>if response == NACK:<EOL><INDENT>self.loggerio.warning('<STR_LIT>')<EOL>time.sleep(<NUM_LIT>)<EOL><DEDENT>elif len(response) == <NUM_LIT:0>:<EOL><INDENT>self.loggerio.error('<STR_LIT>')<EOL>time.sleep(<NUM_LIT>)<EOL><DEDENT>elif response != ACK:<EOL><INDENT>self.loggerio.error('<STR_LIT>' + hex(ord(response)) + '<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>return<EOL><DEDENT><DEDENT>self.loggerio.critical('<STR_LIT>')<EOL>raise C1218IOError('<STR_LIT>')<EOL>
This sends a raw C12.18 frame and waits checks for an ACK response.
In the event that a NACK is received, this function will attempt
to resend the frame up to 3 times.

:param data: the data to be transmitted
:type data: str, :py:class:`~c1218.data.C1218Packet`