Skip to content

Commit 15bb3b3

Browse files
rahulraghu94dhoomakethu
authored andcommitted
#250 fix scraper simulator (#259)
Fix scraper simulator example
1 parent ca5dfaf commit 15bb3b3

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

examples/contrib/message_parser.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,13 @@
2626
from pymodbus.transaction import ModbusAsciiFramer
2727
from pymodbus.transaction import ModbusRtuFramer
2828
from pymodbus.compat import IS_PYTHON3
29-
30-
3129
# -------------------------------------------------------------------------- #
32-
# Logging
3330
# -------------------------------------------------------------------------- #
3431
import logging
3532
modbus_log = logging.getLogger("pymodbus")
3633

3734

35+
3836
# -------------------------------------------------------------------------- #
3937
# build a quick wrapper around the framers
4038
# -------------------------------------------------------------------------- #
@@ -150,6 +148,10 @@ def get_options():
150148
help="If the incoming message is in hexadecimal format",
151149
action="store_true", dest="transaction", default=False)
152150

151+
parser.add_option("-t", "--transaction",
152+
help="If the incoming message is in hexadecimal format",
153+
action="store_true", dest="transaction", default=False)
154+
153155
(opt, arg) = parser.parse_args()
154156

155157
if not opt.message and len(arg) > 0:

examples/contrib/modbus_simulator.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ def __init__(self, config):
7676
:param config: The pickled datastore
7777
"""
7878
try:
79-
self.file = open(config, "r")
80-
except Exception:
79+
self.file = open(config, "rb")
80+
except Exception as e:
81+
_logger.critical(str(e))
8182
raise ConfigurationException("File not found %s" % config)
8283

8384
def parse(self):
@@ -134,5 +135,5 @@ def main():
134135
if __name__ == "__main__":
135136
if root_test():
136137
main()
137-
else:
138+
else:
138139
print("This script must be run as root!")

0 commit comments

Comments
 (0)