Skip to content
Snippets Groups Projects
Commit 72342e90 authored by Torben Petersen's avatar Torben Petersen
Browse files

Changed Hotplug.py - can now make difference between inga_blue and telosb

parent 4d1399a0
No related branches found
No related tags found
No related merge requests found
......@@ -44,6 +44,7 @@ class DefaultProtocol(LineReader):
#self.transport.send({'dst': {'logging': True}, 'type': 'serial_rx', 'line': line, 'ts': time()})
rx_topic = self.transport.hotplug_module.mqtt_topic_prefix + self.transport.serial_number + "/rx"
self.transport.hotplug_module.logger.debug("Publishing on topic {}".format(rx_topic))
self.transport.hotplug_module.logger.debug("Received: {}".format(line))
self.transport.hotplug_module.mqtt_client.publish(rx_topic, bytes(line, 'utf-8'), qos=2)
......@@ -233,6 +234,7 @@ class Hotplug(Module):
pattern1 = base_pattern+"*/ttyUSB*"
path_serial_number = base_pattern + "/serial"
path_manufacturer = base_pattern + "/manufacturer"
path_product = base_pattern + "/product"
# TODO replace glob?
result1 = glob.glob(pattern1)
......@@ -260,14 +262,26 @@ class Hotplug(Module):
with open(path_manufacturer, 'r') as fh:
device_manufacturer = fh.read().strip()
device_product = None
if os.path.exists(path_product):
with open(path_product, 'r') as fh:
device_product = fh.read().strip()
self.logger.debug("Found serial number: {}".format(serial_number))
self.logger.debug("Found serial port name: {}".format(serial_port_name))
self.logger.debug("Found manufacturer: {}".format(device_manufacturer))
self.logger.debug("Found product: {}".format(device_product))
if serial_config['type'] == 'USB':
if device_manufacturer == "IBR":
baud = 19200
print("Baud is 19200")
else:
baud = 9600
if device_product == "MTM-CM5000MSP":
baud = 9600
print("Baud is 9600")
else:
baud = 19200
print("Baud is 19200")
ser = serial.serial_for_url("/dev/" + serial_port_name, baudrate=baud, timeout=1)
else:
ser = serial.serial_for_url("/dev/" + serial_port_name, baudrate=serial_config['baud'], timeout=1)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment