|
10 | 10 | from pymodbus.datastore import ModbusServerContext
|
11 | 11 | from pymodbus.device import ModbusControlBlock, ModbusDeviceIdentification
|
12 | 12 | from pymodbus.exceptions import NoSuchSlaveException
|
13 |
| -from pymodbus.framer import FRAMER_NAME_TO_CLASS, FramerType, FramerBase |
| 13 | +from pymodbus.framer import FRAMER_NAME_TO_CLASS, FramerBase, FramerType |
14 | 14 | from pymodbus.logging import Log
|
15 | 15 | from pymodbus.pdu import DecodePDU, ModbusPDU
|
16 | 16 | from pymodbus.pdu.pdu import ExceptionResponse
|
@@ -224,7 +224,9 @@ def __init__(
|
224 | 224 | if isinstance(identity, ModbusDeviceIdentification):
|
225 | 225 | self.control.Identity.update(identity)
|
226 | 226 | # Support mapping of FramerType to a Framer class, or a Framer class
|
227 |
| - self.framer = FRAMER_NAME_TO_CLASS.get(framer, framer) |
| 227 | + if isinstance(framer, FramerType): |
| 228 | + framer = FRAMER_NAME_TO_CLASS[framer] |
| 229 | + self.framer = framer |
228 | 230 | self.serving: asyncio.Future = asyncio.Future()
|
229 | 231 |
|
230 | 232 | def callback_new_connection(self):
|
@@ -273,7 +275,7 @@ def __init__(
|
273 | 275 | self,
|
274 | 276 | context: ModbusServerContext,
|
275 | 277 | *,
|
276 |
| - framer=FramerType.SOCKET, |
| 278 | + framer: FramerType | type[FramerBase] = FramerType.SOCKET, |
277 | 279 | identity: ModbusDeviceIdentification | None = None,
|
278 | 280 | address: tuple[str, int] = ("", 502),
|
279 | 281 | ignore_missing_slaves: bool = False,
|
@@ -336,7 +338,7 @@ def __init__( # pylint: disable=too-many-arguments
|
336 | 338 | self,
|
337 | 339 | context: ModbusServerContext,
|
338 | 340 | *,
|
339 |
| - framer=FramerType.TLS, |
| 341 | + framer: FramerType | type[FramerBase] = FramerType.TLS, |
340 | 342 | identity: ModbusDeviceIdentification | None = None,
|
341 | 343 | address: tuple[str, int] = ("", 502),
|
342 | 344 | sslctx=None,
|
@@ -403,7 +405,7 @@ def __init__(
|
403 | 405 | self,
|
404 | 406 | context: ModbusServerContext,
|
405 | 407 | *,
|
406 |
| - framer=FramerType.SOCKET, |
| 408 | + framer: FramerType | type[FramerBase] = FramerType.SOCKET, |
407 | 409 | identity: ModbusDeviceIdentification | None = None,
|
408 | 410 | address: tuple[str, int] = ("", 502),
|
409 | 411 | ignore_missing_slaves: bool = False,
|
@@ -463,7 +465,7 @@ def __init__(
|
463 | 465 | self,
|
464 | 466 | context: ModbusServerContext,
|
465 | 467 | *,
|
466 |
| - framer: FramerType = FramerType.RTU, |
| 468 | + framer: FramerType | type[FramerBase] = FramerType.RTU, |
467 | 469 | ignore_missing_slaves: bool = False,
|
468 | 470 | identity: ModbusDeviceIdentification | None = None,
|
469 | 471 | broadcast_enable: bool = False,
|
|
0 commit comments