Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/api/doxygen/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
# pylint: disable=missing-type-doc
"""Doxygen API Builder."""
import os
import shutil
Expand Down
1 change: 1 addition & 0 deletions examples/common/callback_server.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
# pylint: disable=missing-type-doc,missing-param-doc,differing-param-doc
"""Pymodbus Server With Callbacks.

This is an example of adding callbacks to a running modbus server
Expand Down
1 change: 1 addition & 0 deletions examples/common/custom_datablock.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
# pylint: disable=missing-type-doc,missing-param-doc,differing-param-doc
"""Pymodbus Server With Custom Datablock Side Effect.

This is an example of performing custom logic after a value has been
Expand Down
1 change: 1 addition & 0 deletions examples/common/custom_message.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
# pylint: disable=missing-type-doc
"""Pymodbus Synchronous Client Examples.

The following is an example of how to use the synchronous modbus client
Expand Down
3 changes: 1 addition & 2 deletions examples/common/custom_synchronous_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ def decode(self, data):
# --------------------------------------------------------------------------- #
# import the various server implementations
# --------------------------------------------------------------------------- #
from custom_message import CustomModbusRequest

from pymodbus.version import version
from pymodbus.server.sync import StartTcpServer
from pymodbus.device import ModbusDeviceIdentification
Expand All @@ -70,6 +68,7 @@ def decode(self, data):
ModbusSlaveContext,
ModbusServerContext,
)
from .custom_message import CustomModbusRequest # pylint: disable=relative-beyond-top-level

# --------------------------------------------------------------------------- #
# configure the service logging
Expand Down
1 change: 1 addition & 0 deletions examples/common/dbstore_update_server.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# pylint: disable=differing-param-doc,missing-any-param-doc
"""Pymodbus Server With Updating Thread.

This is an example of having a background thread updating the
Expand Down
5 changes: 3 additions & 2 deletions examples/common/performance.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
# pylint: disable=missing-type-doc
"""Pymodbus Performance Example.

The following is an quick performance check of the synchronous
Expand Down Expand Up @@ -52,8 +53,8 @@
def single_client_test(n_host, n_cycles):
"""Perform a single threaded test of a synchronous client against the specified host

:param host: The host to connect to
:param cycles: The number of iterations to perform
:param n_host: The host to connect to
:param n_cycles: The number of iterations to perform
"""
logger = log_to_stderr()
logger.setLevel(logging.WARNING)
Expand Down
1 change: 1 addition & 0 deletions examples/common/updating_server.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
# pylint: disable=missing-any-param-doc,differing-param-doc
"""Pymodbus Server With Updating Thread.

This is an example of having a background thread updating the
Expand Down
1 change: 1 addition & 0 deletions examples/contrib/bcd_payload.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# pylint: disable=missing-type-doc,missing-param-doc,differing-param-doc,missing-raises-doc,missing-any-param-doc
"""Modbus BCD Payload Builder.

This is an example of building a custom payload builder
Expand Down
1 change: 1 addition & 0 deletions examples/contrib/concurrent_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
# pylint: disable=missing-type-doc,missing-param-doc,differing-param-doc
"""Concurrent Modbus Client.

This is an example of writing a high performance modbus client that allows
Expand Down
1 change: 1 addition & 0 deletions examples/contrib/libmodbus_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
# pylint: disable=missing-type-doc,missing-param-doc,differing-param-doc,missing-raises-doc
"""Libmodbus Protocol Wrapper.

What follows is an example wrapper of the libmodbus library
Expand Down
1 change: 1 addition & 0 deletions examples/contrib/message_generator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
# pylint: disable=missing-type-doc
"""Modbus Message Generator.

The following is an example of how to generate example encoded messages
Expand Down
3 changes: 2 additions & 1 deletion examples/contrib/message_parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
# pylint: disable=missing-type-doc,missing-param-doc,differing-param-doc,missing-any-param-doc
"""Modbus Message Parser.

The following is an example of how to parse modbus messages
Expand Down Expand Up @@ -105,7 +106,7 @@ def report(self, message): # pylint: disable=no-self-use
" %-12s => %s" % (k_item, v_item) # pylint: disable=consider-using-f-string
)

elif isinstance(v_dict, collections.Iterable):
elif isinstance(v_dict, collections.Iterable): # pylint: disable=no-member
print("%-15s =" % k_dict) # pylint: disable=consider-using-f-string
value = str([int(x) for x in v_dict])
for line in textwrap.wrap(value, 60):
Expand Down
1 change: 1 addition & 0 deletions examples/contrib/modbus_mapper.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# pylint: disable=missing-type-doc,differing-param-doc
r"""This is used to generate decoder blocks.

so that non-programmers can define the
Expand Down
1 change: 1 addition & 0 deletions examples/contrib/modbus_simulator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
# pylint: disable=missing-raises-doc
"""An example of creating a fully implemented modbus server.

with read/write data as well as user configurable base data
Expand Down
1 change: 1 addition & 0 deletions examples/contrib/modicon_payload.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# pylint: disable=missing-type-doc,missing-raises-doc
"""Modbus Modicon Payload Builder.

This is an example of building a custom payload builder
Expand Down
1 change: 1 addition & 0 deletions examples/contrib/remote_server_context.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# pylint: disable=missing-type-doc,missing-param-doc,differing-param-doc,missing-raises-doc
"""Although there is a remote server context already in the main library,

it works under the assumption that users would have a server context
Expand Down
1 change: 1 addition & 0 deletions examples/contrib/thread_safe_datastore.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# pylint: disable=missing-type-doc
"""Thread safe datastore."""
import threading
from contextlib import contextmanager
Expand Down
1 change: 1 addition & 0 deletions pymodbus/bit_read_message.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Bit Reading Request/Response messages."""
# pylint: disable=missing-type-doc
import struct
from pymodbus.pdu import ModbusRequest
from pymodbus.pdu import ModbusResponse
Expand Down
1 change: 1 addition & 0 deletions pymodbus/bit_write_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

TODO write mask request/response
"""
# pylint: disable=missing-type-doc
import struct
from pymodbus.constants import ModbusStatus
from pymodbus.pdu import ModbusRequest
Expand Down
28 changes: 6 additions & 22 deletions pymodbus/client/asynchronous/async_io/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Asynchronous framework adapter for asyncio."""
# pylint: disable=missing-type-doc
import logging
import socket
import asyncio
Expand Down Expand Up @@ -45,7 +46,6 @@ def connection_made(self, transport):
The transport argument is the transport representing the connection.

:param transport:
:return:
"""
self.transport = transport
self._connection_made()
Expand All @@ -59,7 +59,6 @@ def connection_lost(self, reason):
The argument is either an exception object or None

:param reason:
:return:
"""
self.transport = None
self._connection_lost(reason)
Expand All @@ -73,23 +72,18 @@ def data_received(self, data):
data is a non-empty bytes object containing the incoming data.

:param data:
:return:
"""
self._data_received(data)

def create_future(self): # pylint: disable=no-self-use
"""Help function to create asyncio Future object.

:return:
"""
"""Help function to create asyncio Future object."""
return asyncio.Future()

def resolve_future(self, my_future, result): # pylint: disable=no-self-use
"""Resolve the completed future and sets the result.

:param my_future:
:param result:
:return:
"""
if not my_future.done():
my_future.set_result(result)
Expand All @@ -99,7 +93,6 @@ def raise_future(self, my_future, exc): # pylint: disable=no-self-use

:param my_future:
:param exc:
:return:
"""
if not my_future.done():
my_future.set_exception(exc)
Expand Down Expand Up @@ -155,6 +148,7 @@ def _handle_response(self, reply, **kwargs): # pylint: disable=unused-argument
"""Handle the processed response and link to correct deferred

:param reply: The reply to process
:param kwargs: The rest
"""
if reply is not None:
tid = reply.transaction_id
Expand Down Expand Up @@ -196,7 +190,6 @@ def data_received(self, data):
data is a non-empty bytes object containing the incoming data.

:param data:
:return:
"""
self._data_received(data)

Expand Down Expand Up @@ -270,10 +263,7 @@ async def start(self, host, port=502):
return await self._connect()

def stop(self):
"""Stop client.

:return:
"""
"""Stop client."""
# prevent reconnect:
self.host = None

Expand Down Expand Up @@ -642,10 +632,7 @@ def __init__(self, host=None, port=502, protocol_class=None, loop=None, **kwargs
self._proto_args = kwargs

def stop(self):
"""Stop connection.

:return:
"""
"""Stop connection."""
# prevent reconnect:
# self.host = None

Expand Down Expand Up @@ -771,10 +758,7 @@ def _connected(self):
return self._connected_event.is_set()

async def connect(self):
"""Connect Async client.

:return:
"""
"""Connect Async client."""
_logger.debug(TEXT_CONNECTING)
try:
await create_serial_connection(
Expand Down
1 change: 1 addition & 0 deletions pymodbus/client/asynchronous/deprecated/asynchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def process():
reactor.callLater(1, process)
reactor.run()
"""
# pylint: disable=missing-type-doc,differing-param-doc,missing-param-doc
import logging
from twisted.internet import defer, protocol
from twisted.python.failure import Failure
Expand Down
2 changes: 2 additions & 0 deletions pymodbus/client/asynchronous/factory/serial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Factory to create asynchronous serial clients based on twisted/tornado/asyncio."""
# pylint: disable=missing-type-doc
import logging
import asyncio

Expand Down Expand Up @@ -122,6 +123,7 @@ def get_factory(scheduler):

:param scheduler: REACTOR/IO_LOOP/ASYNC_IO
:return:
:raises Exception: Failure
"""
if scheduler == schedulers.REACTOR:
return reactor_factory
Expand Down
5 changes: 2 additions & 3 deletions pymodbus/client/asynchronous/factory/tcp.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Factory to create asynchronous tcp clients based on twisted/tornado/asyncio."""
# pylint: disable=missing-type-doc
import logging
import asyncio

Expand Down Expand Up @@ -107,9 +108,6 @@ def async_io_factory(host="127.0.0.1", port=Defaults.Port, **kwargs):

:param host: Host IP address
:param port: Port
:param framer: Modbus Framer
:param source_address: Bind address
:param timeout: Timeout in seconds
:param kwargs:
:return: asyncio event loop and tcp client
"""
Expand Down Expand Up @@ -141,6 +139,7 @@ def get_factory(scheduler):

:param scheduler: REACTOR/IO_LOOP/ASYNC_IO
:return: new factory
:raises Exception: Failure
"""
if scheduler == schedulers.REACTOR:
return reactor_factory
Expand Down
10 changes: 4 additions & 6 deletions pymodbus/client/asynchronous/factory/tls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Factory to create asynchronous tls clients based on asyncio."""
# pylint: disable=missing-type-doc
import logging
import asyncio

Expand All @@ -22,12 +23,8 @@ def async_io_factory(
:param host: Target server"s name, also matched for certificate
:param port: Port
:param sslctx: The SSLContext to use for TLS (default None and auto create)
:param certfile: The optional client"s cert file path for TLS server request
:param keyfile: The optional client"s key file path for TLS server request
:param password: The password for for decrypting client"s private key file
:param server_hostname: Bind address
:param framer: Modbus Framer
:param source_address: Bind address
:param timeout: Timeout in seconds
:param kwargs:
:return: asyncio event loop and tcp client
"""
Expand Down Expand Up @@ -61,7 +58,8 @@ def get_factory(scheduler):
"""Get protocol factory based on the backend scheduler being used.

:param scheduler: ASYNC_IO
:return
:return: protocol object
:raises Exception: Failure
"""
if scheduler == schedulers.ASYNC_IO:
return async_io_factory
Expand Down
5 changes: 2 additions & 3 deletions pymodbus/client/asynchronous/factory/udp.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""UDP implementation."""
# pylint: disable=missing-type-doc
import logging
import asyncio

Expand Down Expand Up @@ -74,9 +75,6 @@ def async_io_factory(host="127.0.0.1", port=Defaults.Port, **kwargs):

:param host: Host IP address
:param port: Port
:param framer: Modbus Framer
:param source_address: Bind address
:param timeout: Timeout in seconds
:param kwargs:
:return: asyncio event loop and udp client
"""
Expand Down Expand Up @@ -105,6 +103,7 @@ def get_factory(scheduler):

:param scheduler: REACTOR/IO_LOOP/ASYNC_IO
:return: new factory
:raises Exception: Failure
"""
if scheduler == schedulers.REACTOR:
return reactor_factory
Expand Down
1 change: 1 addition & 0 deletions pymodbus/client/asynchronous/serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def _framer(cls, method):

:method: The serial framer to instantiate
:returns: The requested serial framer
:raises Exception: Failure
"""
method = method.lower()
if method == "ascii":
Expand Down
15 changes: 3 additions & 12 deletions pymodbus/client/asynchronous/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,17 @@ def __init__(self, name, start, stop, *args, **kwargs):
self._event_loop.daemon = True

def _start(self):
"""Start the backend event loop

:return:
"""
"""Start the backend event loop."""
self._start_loop(*self._args, **self._kwargs)

def start(self):
"""Start the backend event loop

:return:
"""
"""Start the backend event loop."""
txt = f'Starting Event Loop: "PyModbus_{self._name}"'
_logger.info(txt)
self._event_loop.start()

def stop(self):
"""Stop the backend event loop

:return:
"""
"""Stop the backend event loop."""
txt = f'Stopping Event Loop: "PyModbus_{self._name}"'
_logger.info(txt)
self._stop_loop()
1 change: 1 addition & 0 deletions pymodbus/client/asynchronous/tornado/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Asynchronous framework adapter for tornado."""
# pylint: skip-file
import logging
import abc
import time
Expand Down
Loading