Skip to content

Commit

Permalink
required updates for mpp-installer
Browse files Browse the repository at this point in the history
These updates make it easier to handle the udev rule created by the mpp-installer script

• installer creates device name based on connection type (mpp-solar-serial/mpp-solar-direct)
• convert the udev symlink to real full path
  • Loading branch information
mholgatem committed Aug 8, 2020
1 parent 759e6d7 commit 3068836
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion mppsolar/mppinverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ def isDirectUsbDevice(serial_device):
"""
if not serial_device:
return False
if "mpp-solar-serial" in serial_device:
log.debug("Device matches mpp-solar-serial")
return False
if "mpp-solar-direct" in serial_device:
log.debug("Device matches mpp-solar-direct")
return True
match = re.search("^.*hidraw\\d$", serial_device)
if match:
log.debug("Device matches hidraw regex")
Expand All @@ -138,7 +144,7 @@ def __init__(self, serial_device=None, baud_rate=2400, inverter_model='standard'
if not serial_device:
raise NoDeviceError("A device to communicate by must be supplied, e.g. /dev/ttyUSB0")
self._baud_rate = baud_rate
self._serial_device = serial_device
self._serial_device = os.path.realpath(serial_device)
self._inverter_model = inverter_model
self._serial_number = None
self._test_device = isTestDevice(serial_device)
Expand Down

0 comments on commit 3068836

Please sign in to comment.