Skip to content

Commit 668612e

Browse files
committed
Fix ModbusSingleRequestHandler
1 parent 2e65023 commit 668612e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

pymodbus/server/sync.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,13 @@ def handle(self):
102102
if data:
103103
if _logger.isEnabledFor(logging.DEBUG):
104104
_logger.debug("recv: " + " ".join([hex(byte2int(x)) for x in data]))
105-
if isinstance(self.framer, ModbusRtuFramer):
106-
unit_address = byte2int(data[0])
107-
elif isinstance(self.framer, ModbusAsciiFramer):
105+
if isinstance(self.framer, ModbusAsciiFramer):
108106
unit_address = int(data[1:3], 16)
109-
if isinstance(self.framer, ModbusBinaryFramer):
107+
elif isinstance(self.framer, ModbusBinaryFramer):
110108
unit_address = byte2int(data[1])
109+
else:
110+
unit_address = byte2int(data[0])
111+
111112
if unit_address in self.server.context:
112113
self.framer.processIncomingPacket(data, self.execute)
113114
except Exception as msg:
@@ -116,7 +117,6 @@ def handle(self):
116117
self.framer.resetFrame()
117118
_logger.error("Socket error occurred %s" % msg)
118119

119-
120120
def send(self, message):
121121
''' Send a request (string) to the network
122122

0 commit comments

Comments
 (0)