Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve Issues with modbus interfacer and pymodbus #63

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/emonhub.py
Expand Up @@ -206,8 +206,6 @@ def _update_settings(self, settings):
if not 'Type' in I:
continue
self._log.info("Creating " + I['Type'] + " '%s' ", name)
if I['Type'] in ('EmonModbusTcpInterfacer','EmonFroniusModbusTcpInterfacer') and not pymodbus_found :
self._log.error("Python module pymodbus not installed. unable to load modbus interfacer")
# This gets the class from the 'Type' string
interfacer = getattr(ehi, I['Type'])(name,**I['init_settings'])
interfacer.set(**I['runtimesettings'])
Expand Down
Expand Up @@ -3,7 +3,7 @@
import logging
from pymodbus.constants import Endian
from pymodbus.payload import BinaryPayloadDecoder
import EmonModbusTcpInterfacer as EmonModbusTcpInterfacer
from EmonModbusTcpInterfacer import EmonModbusTcpInterfacer

"""class EmonModbusTcpInterfacer
Monitors Solar Inverter using modbus tcp
Expand Down
@@ -1,4 +1,17 @@
import time
+#!/usr/bin/python
+# EmonModbusTcpInterfacer released for use by OpenEnergyMonitor project
+# GNU GENERAL PUBLIC LICENSE - Version 2, June 1991
+# See LICENCE and README file for details
+
+__author__ = 'Chris Thuys'
+
+try:
+ import pymodbus
+ pymodbus_found = True
+except ImportError:
+ pymodbus_found = False
+
+import time
import Cargo
from pymodbus.constants import Endian
from pymodbus.payload import BinaryPayloadDecoder
Expand Down Expand Up @@ -45,7 +58,8 @@ def close(self):

def _open_modTCP(self,modbus_IP,modbus_port):
""" Open connection to modbus device """

if not pymodbus_found :
self._log.error("Python module pymodbus not installed or found. Unable to open modbus connection")
try:
c = ModbusClient(modbus_IP,modbus_port)
if c.connect():
Expand Down
6 changes: 3 additions & 3 deletions src/interfacers/__init__.py
Expand Up @@ -12,7 +12,7 @@
"EmonHubSMASolarInterfacer",
"EmonHubGraphiteInterfacer",
"EmonHubBMWInterfacer",
# "EmonModbusTcpInterfacer",
"EmonModbusTcpInterfacer",
"EmonFroniusModbusTcpInterfacer",
"EmonHubTemplateInterfacer"
#"EmonFroniusModbusTcpInterfacer"
]
]