Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
imbeacon committed Oct 27, 2022
2 parents bc0097f + dcd2c95 commit 25a8f12
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions thingsboard_gateway/connectors/modbus/modbus_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,20 @@
from thingsboard_gateway.tb_utility.tb_utility import TBUtility

# Try import Pymodbus library or install it and import
installation_required = False

try:
from pymodbus.constants import Defaults
from pymodbus import __version__ as pymodbus_version
if int(pymodbus_version.split('.')[0]) < 3:
installation_required = True
except ImportError:
installation_required = True

if installation_required:
print("Modbus library not found - installing...")
TBUtility.install_package("pymodbus", ">=3.0.0")
TBUtility.install_package('pyserial')
TBUtility.install_package('pyserial-asyncio')
from pymodbus.constants import Defaults

try:
from twisted.internet import reactor
Expand All @@ -37,6 +43,7 @@
from twisted.internet import reactor

from twisted.internet import reactor
from pymodbus.constants import Defaults
from pymodbus.bit_write_message import WriteSingleCoilResponse, WriteMultipleCoilsResponse
from pymodbus.register_write_message import WriteMultipleRegistersResponse, WriteSingleRegisterResponse
from pymodbus.register_read_message import ReadRegistersResponseBase
Expand Down

0 comments on commit 25a8f12

Please sign in to comment.