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
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ jobs:
run: |
pip install --upgrade pip setuptools wheel
pip install --upgrade tox
- uses: twisted/python-info-action@v1.0.1
- name: Add PyPy Externals
if: ${{ matrix.os.matrix == 'windows' && matrix.python.implementation == 'pypy'}}
env:
Expand Down Expand Up @@ -225,7 +224,6 @@ jobs:
run: |
pip install --upgrade pip setuptools wheel
pip install --upgrade tox
- uses: twisted/python-info-action@v1.0.1
- name: Test
continue-on-error: ${{ matrix.task.continue_on_error == true }}
run: |
Expand Down Expand Up @@ -272,7 +270,6 @@ jobs:
run: |
pip install --upgrade pip setuptools wheel
pip install --upgrade tox
- uses: twisted/python-info-action@v1.0.1
- name: Download Coverage
if: matrix.task.download_coverage
uses: actions/download-artifact@v2
Expand Down
7 changes: 2 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Remark: "Supports" means that we only test with those versions, lower versions (
Summary
------------------------------------------------------------

Pymodbus is a full Modbus protocol implementation using a synchronous or asynchronous core. The preferred mode for asynchronous communication is asyncio, however for the moment twisted are also supported (due to be removed or converted to a plugin in a later version).
Pymodbus is a full Modbus protocol implementation using a synchronous or asynchronous (using asyncio) core.

Supported modbus communication modes: tcp, rtu-over-tcp, udp, serial, tls

Expand All @@ -53,7 +53,7 @@ Client Features
* Full read/write protocol on discrete and register
* Most of the extended protocol (diagnostic/file/pipe/setting/information)
* TCP, RTU-OVER-TCP, UDP, TLS, Serial ASCII, Serial RTU, and Serial Binary
* asynchronous(powered by asyncio/twisted) and synchronous versions
* asynchronous(powered by asyncio) and synchronous versions
* Payload builder/decoder utilities
* Pymodbus REPL for quick tests
* Customable framer to allow for custom implementations
Expand Down Expand Up @@ -167,8 +167,6 @@ Available options are:

- **datastore**, installs databases (SQLAlchemy and Redit) for datastore.

- **twisted**, installs twisted as alternative to asyncio (will be removed in a future version).

- **documentation**, installs tools to generate documentation.

- **development**, installs development tools needed to enable test/check of pymodbus changes.
Expand Down Expand Up @@ -282,6 +280,5 @@ Pymodbus is built on top of code developed from/by:
* Copyright (c) 2001-2005 S.W.A.C. Bohemia s.r.o., Czech Republic.

* Hynek Petrak, https://github.com/HynekPetrak
* Twisted Matrix

Released under the `BSD License <LICENSE>`_
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
==================================================
Serial Forwarder Example
==================================================
.. literalinclude:: ../../../examples/contrib/serial_forwarder.py
.. literalinclude:: ../../../examples/modbus_forwarder.py
2 changes: 1 addition & 1 deletion doc/source/example/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Examples
custom_datablock
custom_message
modbus_logging
modbus_forwarder
payload_client
payload_server
performance
Expand All @@ -37,5 +38,4 @@ Examples
modbus_tls_client
modicon_payload
remote_server_context
serial_forwarder
thread_safe_datastore
4 changes: 1 addition & 3 deletions doc/source/library/pymodbus.server.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Submodules
pymodbus\.server\.asynchronous module
-------------------------------------

.. automodule:: pymodbus.server.asynchronous
.. automodule:: pymodbus.server.async_io
:members:
:undoc-members:
:show-inheritance:
Expand All @@ -24,5 +24,3 @@ pymodbus\.server\.sync module
:members:
:undoc-members:
:show-inheritance:


5 changes: 1 addition & 4 deletions examples/client_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,7 @@ def run_sync_client(modbus_calls=None):
"serial": ["rtu", "/dev/ptyp0"],
"tls": ["tls", 5020]
}
FORMAT = (
"%(asctime)-15s %(threadName)-15s "
"%(levelname)-8s %(module)-15s:%(lineno)-8s %(message)s"
)
FORMAT = "%(asctime)-15s %(levelname)-8s %(module)-15s:%(lineno)-8s %(message)s"
logging.basicConfig(format=FORMAT)
_logger = logging.getLogger()

Expand Down
2 changes: 1 addition & 1 deletion examples/client_sync_basic_calls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
"""Pymodbus Synchronous Client standard calls rxample.
"""Pymodbus Synchronous Client standard calls example.

This example uses client_sync.py to handle connection, and have the same options.

Expand Down
3 changes: 1 addition & 2 deletions examples/common/asyncio_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

The asyncio server is implemented in pure python without any third
party libraries (unless you need to use the serial protocols which require
asyncio-pyserial). This is helpful in constrained or old environments where using
twisted is just not feasible. What follows is an example of its use:
asyncio-pyserial). What follows is an example of its use:
"""
import asyncio

Expand Down
2 changes: 1 addition & 1 deletion examples/common/callback_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
ModbusSparseDataBlock,
)
from pymodbus.device import ModbusDeviceIdentification
from pymodbus.server.asynchronous import StartTcpServer
from pymodbus.server.async_io import StartTcpServer

# --------------------------------------------------------------------------- #
# import the modbus libraries we need
Expand Down
2 changes: 1 addition & 1 deletion examples/common/custom_datablock.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
ModbusSparseDataBlock,
)
from pymodbus.device import ModbusDeviceIdentification
from pymodbus.server.asynchronous import StartTcpServer
from pymodbus.server.async_io import StartTcpServer

# --------------------------------------------------------------------------- #
# import the modbus libraries we need
Expand Down
10 changes: 3 additions & 7 deletions examples/common/dbstore_update_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,12 @@
"""
import logging
import random

# --------------------------------------------------------------------------- #
# import the twisted libraries we need
# --------------------------------------------------------------------------- #
from twisted.internet.task import LoopingCall
import asyncio

from pymodbus.datastore import ModbusSequentialDataBlock, ModbusServerContext
from pymodbus.datastore.database import SqlSlaveContext
from pymodbus.device import ModbusDeviceIdentification
from pymodbus.server.asynchronous import StartTcpServer
from pymodbus.server.async_io import StartTcpServer

# --------------------------------------------------------------------------- #
# import the modbus libraries we need
Expand Down Expand Up @@ -100,7 +96,7 @@ def run_dbstore_update_server():
# run the server you want
# ----------------------------------------------------------------------- #
time = 5 # 5 seconds delay
loop = LoopingCall(f=updating_writer, a=(context,))
loop = asyncio.get_event_loop()
loop.start(time, now=False) # initially delay by time
loop.stop()
StartTcpServer(context, identity=identity, address=("", 5020))
Expand Down
16 changes: 3 additions & 13 deletions examples/common/updating_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,17 @@
Thread(target=updating_writer, args=(context,)).start()
"""
import logging

# --------------------------------------------------------------------------- #
# import the modbus libraries we need
# --------------------------------------------------------------------------- #
from twisted.internet.task import LoopingCall
import asyncio

from pymodbus.datastore import (
ModbusSequentialDataBlock,
ModbusServerContext,
ModbusSlaveContext,
)
from pymodbus.device import ModbusDeviceIdentification
from pymodbus.server.asynchronous import StartTcpServer
from pymodbus.server.async_io import StartTcpServer
from pymodbus.version import version

# from pymodbus.transaction import ModbusRtuFramer, ModbusAsciiFramer

# --------------------------------------------------------------------------- #
# import the twisted libraries we need
# --------------------------------------------------------------------------- #

# --------------------------------------------------------------------------- #
# configure the service logging
# --------------------------------------------------------------------------- #
Expand Down Expand Up @@ -94,7 +84,7 @@ def run_updating_server():
# run the server you want
# ----------------------------------------------------------------------- #
time = 5 # 5 seconds delay
loop = LoopingCall(f=updating_writer, a=(context,))
loop = asyncio.get_event_loop()
loop.start(time, now=False) # initially delay by time
StartTcpServer(context, identity=identity, address=("localhost", 5020))

Expand Down
2 changes: 1 addition & 1 deletion examples/contrib/libmodbus_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# -------------------------------------------------------------------------- #
# import system libraries
# -------------------------------------------------------------------------- #
from cffi import FFI
from cffi import FFI # pylint: disable=import-error

from pymodbus.bit_read_message import ReadCoilsResponse, ReadDiscreteInputsResponse
from pymodbus.bit_write_message import (
Expand Down
2 changes: 1 addition & 1 deletion examples/contrib/modbus_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import pickle # nosec

from pymodbus.datastore import ModbusServerContext, ModbusSlaveContext
from pymodbus.server.asynchronous import StartTcpServer
from pymodbus.server.async_io import StartTcpServer

# -------------------------------------------------------------------------- #
# Logging
Expand Down
49 changes: 0 additions & 49 deletions examples/contrib/serial_forwarder.py

This file was deleted.

10 changes: 5 additions & 5 deletions examples/contrib/tornado_twisted/modbus_scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from optparse import OptionParser
import pickle # nosec

from twisted.internet import reactor, serialport
from twisted.internet.protocol import ClientFactory
from twisted.internet import reactor, serialport # pylint: disable=import-error
from twisted.internet.protocol import ClientFactory # pylint: disable=import-error

from pymodbus.client.asynchronous.twisted import ModbusClientProtocol
from pymodbus.datastore import ModbusSequentialDataBlock, ModbusSlaveContext
Expand Down Expand Up @@ -140,7 +140,7 @@ def error_handler(self, failure):
#
# It also persists data between client instances (think protocol singleton).
# --------------------------------------------------------------------------- #
class ScraperFactory(ClientFactory):
class ScraperFactory(ClientFactory): # pylint: disable=too-few-public-methods
"""Scraper factory."""

protocol = ScraperProtocol
Expand All @@ -151,10 +151,10 @@ def __init__(self, framer, endpoint, query):
self.endpoint = endpoint
self.starting, self.ending = query

def buildProtocol(self, _):
def buildProtocol(self, _): # pylint: disable=invalid-name
"""Create a protocol and start the reading cycle"""
protocol = self.protocol(self.framer, self.endpoint)
protocol.factory = self
protocol.factory = self # pylint: disable=attribute-defined-outside-init
return protocol


Expand Down
2 changes: 1 addition & 1 deletion examples/contrib/tornado_twisted/sunspec_client.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Sunspec client."""
import logging

from twisted.internet.defer import Deferred
from twisted.internet.defer import Deferred # pylint: disable=import-error

from pymodbus.client.sync import ModbusTcpClient
from pymodbus.constants import Endian
Expand Down
Loading