Closed Joy-2612 closed 2 weeks ago
You copied the examples.tgz/zip from "latest" and not from v3.6.8, that is causing the problem.
"latest" correspond to v3.7.0dev which is the newest but unreleased code.
I have also the same problem. Even if I get the example code from github or wiki, none of these works.
pi@raspberry:~/pymodbus/examples $ python3.12 ./simple_async_client.py
Traceback (most recent call last):
File "/home/pi/pymodbus/examples/./simple_async_client.py", line 15, in <module>
from pymodbus import (
ImportError: cannot import name 'FramerType' from 'pymodbus' (/home/pi/.local/lib/python3.12/site-packages/pymodbus/__init__.py)
also this example also has some problem (helper.py is in the same folder)
pi@raspberry:~/pymodbus/examples $ python3 ./client_async.py -h
*** ERROR --> THIS EXAMPLE needs the example directory, please see
https://pymodbus.readthedocs.io/en/latest/source/examples.html
for more information.
Why do I see "latest" label on the 3.6.8?
You are mixing examples from dev with runtime from an earlier version, that will not work.
Ensure to download the examples from read the doc or github that matches your pymodbus version.
Closing as not being an issue.
!/usr/bin/env python3
"""Pymodbus synchronous client example.
An example of a single threaded synchronous client.
usage: simple_sync_client.py
All options must be adapted in the code The corresponding server must be started before e.g. as: python3 server_sync.py """
---------------------------------------------------------------------------
import the various client implementations
---------------------------------------------------------------------------
import pymodbus.client as ModbusClient from pymodbus import ( ExceptionResponse, FramerType, ModbusException, pymodbus_apply_logging_config, )
def run_sync_simple_client(comm, host, port, framer=FramerType.SOCKET): """Run sync client."""
activate debugging
if name == "main": run_sync_simple_client("tcp", "127.0.0.1", "5020")
The FramerType Module is not available for the pymodbus version 3.6.8. Instead we can use Framer module from the same version for implementing the same logic.