Skip to content

Commit

Permalink
step.
Browse files Browse the repository at this point in the history
  • Loading branch information
janiversen committed Oct 7, 2024
1 parent 23451c2 commit fd40acf
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 41 deletions.
5 changes: 0 additions & 5 deletions pymodbus/framer/old_framer_ascii.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,3 @@ def __init__(self, decoder, client=None):
self._start = b":"
self._end = b"\r\n"
self.message_handler = FramerAscii(decoder, [0])

def frameProcessIncomingPacket(self, _used_len, callback, _tid, result):
"""Process new packet pattern."""
callback(result) # defer this
return True
11 changes: 4 additions & 7 deletions pymodbus/framer/old_framer_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,10 @@ def processIncomingPacket(self, data: bytes, callback, slave, tid=None):
result.transaction_id = self.tid
Log.debug("Frame advanced, resetting header!!")
self._buffer = self._buffer[used_len:]
if not self.frameProcessIncomingPacket(used_len, callback, tid, result):
return

def frameProcessIncomingPacket(
self, _used_len, _callback, _tid, _result) -> bool:
"""Process new packet pattern."""
return True
if tid and result.transaction_id and tid != result.transaction_id:
self.resetFrame()
else:
callback(result) # defer or push to a thread?

def buildPacket(self, message: ModbusRequest | ModbusResponse) -> bytes:
"""Create a ready to send modbus packet.
Expand Down
5 changes: 0 additions & 5 deletions pymodbus/framer/old_framer_rtu.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ def __init__(self, decoder, client=None):
super().__init__(decoder, client)
self.message_handler: FramerRTU = FramerRTU(self.decoder, [0])

def frameProcessIncomingPacket(self, _used_len, callback, _tid, result):
"""Process new packet pattern."""
callback(result) # defer or push to a thread?
return True

def sendPacket(self, message: bytes) -> int:
"""Send packets on the bus with 3.5char delay between frames.
Expand Down
18 changes: 0 additions & 18 deletions pymodbus/framer/old_framer_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,3 @@ def __init__(self, decoder, client=None):
super().__init__(decoder, client)
self._hsize = 0x07
self.message_handler = FramerSocket(decoder, [0])

def frameProcessIncomingPacket(self, _used_len, callback, tid, result):
"""Process new packet pattern.
This takes in a new request packet, adds it to the current
packet stream, and performs framing on it. That is, checks
for complete messages, and once found, will process all that
exist. This handles the case when we read N + 1 or 1 // N
messages at a time instead of 1.
The processed and decoded messages are pushed to the callback
function to process and send.
"""
if tid and tid != result.transaction_id:
self.resetFrame()
else:
callback(result) # defer or push to a thread?
return True
6 changes: 0 additions & 6 deletions pymodbus/framer/old_framer_tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,3 @@ def __init__(self, decoder, client=None):
super().__init__(decoder, client)
self._hsize = 0x0
self.message_handler = FramerTLS(decoder, [0])

def frameProcessIncomingPacket(self, _used_len, callback, _tid, result):
"""Process new packet pattern."""
# no slave id for Modbus Security Application Protocol
callback(result) # defer or push to a thread?
return True

0 comments on commit fd40acf

Please sign in to comment.