11"""Framer start."""
22# pylint: disable=missing-type-doc
3+ from typing import Any , Dict , Union
4+
5+ from pymodbus .factory import ClientDecoder , ServerDecoder
36
47
58# Unit ID, Function Code
@@ -18,15 +21,20 @@ class ModbusFramer:
1821
1922 name = ""
2023
21- def __init__ (self , decoder , client = None ):
24+ def __init__ (
25+ self ,
26+ decoder : Union [ClientDecoder , ServerDecoder ],
27+ client = None ,
28+ ) -> None :
2229 """Initialize a new instance of the framer.
2330
2431 :param decoder: The decoder implementation to use
2532 """
2633 self .decoder = decoder
2734 self .client = client
35+ self ._header : Dict [str , Any ] = {}
2836
29- def _validate_slave_id (self , slaves , single ) :
37+ def _validate_slave_id (self , slaves : list , single : bool ) -> bool :
3038 """Validate if the received data is valid for the client.
3139
3240 :param slaves: list of slave id for which the transaction is valid
@@ -39,7 +47,7 @@ def _validate_slave_id(self, slaves, single):
3947 # Handle Modbus TCP slave identifier (0x00 0r 0xFF)
4048 # in asynchronous requests
4149 return True
42- return self ._header ["uid" ] in slaves # pylint: disable=no-member
50+ return self ._header ["uid" ] in slaves
4351
4452 def sendPacket (self , message ):
4553 """Send packets on the bus.
0 commit comments