<commit_before>import serial
from xbee import XBee
from .messages import Message


class Link(object):
	"""Link

	Link between the queen and the swarm. It maintains state information and
	implements messaging functionality.

	"""

	drone_addrs = [
		'\x00\x00',
		'\x00\x01',
		'\x00\x02',
		'\x00\x03',
		'\x00\x04',
		'\x00\x05',
		'\x00\x06',
		'\x00\x07',
		'\x00\x08',
		'\x00\x09'
	]

	def __init__(self, callback=None, read_timeout=None, write_timeout=None):
		self.port = serial.Serial('/dev/ttyUSB0', 9600, timeout=read_timeout, writeTimeout=write_timeout)
		if callback:
			self.xbee = XBee(self.port, callback=callback, escaped=True)
			self.api = True
		else:
			self.api = False

	def set_callback(self, callback):
		if self.api:
			self._close_xbee()
			self.xbee = XBee(self.port, callback=callback)

	def send_message(self, msg):
		"""Send message

		Transmit a message with given parameters through the link.

		"""
		# Convert message
		string = str(msg)
		# Write serial
		if self.api:<commit_msg>Don't escape link.<commit_after>import serial
from xbee import XBee
from .messages import Message


class Link(object):
	"""Link

	Link between the queen and the swarm. It maintains state information and
	implements messaging functionality.

	"""

	drone_addrs = [
		'\x00\x00',
		'\x00\x01',
		'\x00\x02',
		'\x00\x03',
		'\x00\x04',
		'\x00\x05',
		'\x00\x06',
		'\x00\x07',
		'\x00\x08',
		'\x00\x09'
	]

	def __init__(self, callback=None, read_timeout=None, write_timeout=None):
		self.port = serial.Serial('/dev/ttyUSB0', 9600, timeout=read_timeout, writeTimeout=write_timeout)
		if callback:
			self.xbee = XBee(self.port, callback=callback, escaped=False)
			self.api = True
		else:
			self.api = False

	def set_callback(self, callback):
		if self.api:
			self._close_xbee()
			self.xbee = XBee(self.port, callback=callback)

	def send_message(self, msg):
		"""Send message

		Transmit a message with given parameters through the link.

		"""
		# Convert message
		string = str(msg)
		# Write serial
		if self.api:
{'fraction_non_alphanumeric': 0.13738959764474976, 'fraction_numerical': 0.04416094210009813, 'mean_word_length': 3.676605504587156, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4198679', 'n_tokens_mistral': 871, 'n_tokens_neox': 737, 'n_words': 183}