From e2a23995a12ea20cc4dc952afe433216d6fc4d25 Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Tue, 25 Sep 2018 18:44:37 +0200 Subject: [PATCH] [IMP] hw_scale: fix to avoid conflicts with other driver There are two scales that are supported, but the Adam scale possibly won't return any answer so there is no way to detect then if it is an Adam scale or something else. As we have not implemented a detection method for the caliper driver yet, we exclude it from the devices the scale can detect. (by comparing /dev/serial/by-id and by-path) --- addons/hw_scale/controllers/main.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/hw_scale/controllers/main.py b/addons/hw_scale/controllers/main.py index 162ab7a866d..8dc65392edb 100644 --- a/addons/hw_scale/controllers/main.py +++ b/addons/hw_scale/controllers/main.py @@ -125,6 +125,7 @@ class Scale(Thread): self.scalelock = Lock() self.status = {'status':'connecting', 'messages':[]} self.input_dir = '/dev/serial/by-path/' + self.forbidden_dir = '/dev/serial/by-id/' self.weight = 0 self.weight_info = 'ok' self.device = None @@ -212,15 +213,16 @@ class Scale(Thread): self.set_status('disconnected', 'No RS-232 device found') return None - devices = [device for device in listdir(self.input_dir)] - + forbidden_devices = [os.readlink(self.forbidden_dir + d) for d in listdir(self.forbidden_dir) if 'usb-Sylvac_Power_USB_A32DV5VM' in d] # Skip special usb link with Sylvac + devices = [device for device in listdir(self.input_dir) if os.readlink(self.input_dir + device) not in forbidden_devices] for device in devices: + path = self.input_dir + device driver = hw_proxy.rs232_devices.get(device) if driver and driver != DRIVER_NAME: # belongs to another driver _logger.info('Ignoring %s, belongs to %s', device, driver) continue - path = self.input_dir + device + for protocol in SCALE_PROTOCOLS: _logger.info('Probing %s with protocol %s', path, protocol) connection = serial.Serial(path,