-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
Versions
- Python: 3.11.4
- OS: Windows
- Pymodbus: Works with 3.3.2 Stop working with 3.4.0
- Modbus Hardware (if used): FTDI Based RS485<->USB Adapter
Pymodbus Specific
- Server: rtu- async
Description
With the new Version it is not possible to start a server, because the Port String is not detected and the default Value of 127.0.0.1 is used.
Code and Log
Code
import asyncio
import logging
from pymodbus import __version__ as pymodbus_version
from pymodbus.datastore import (
ModbusSequentialDataBlock,
ModbusServerContext,
ModbusSlaveContext,
ModbusSparseDataBlock,
)
from pymodbus.device import ModbusDeviceIdentification
import argparse
import os
from pymodbus import pymodbus_apply_logging_config
from pymodbus.transaction import ModbusRtuFramer
from pymodbus.server import StartAsyncSerialServer
pymodbus_apply_logging_config()
logging.basicConfig()
_logger = logging.getLogger(__file__)
_logger.setLevel(logging.DEBUG)
async def run_async_server():
"""Run server."""
datablock = ModbusSequentialDataBlock.create()
server = await StartAsyncSerialServer(
context=ModbusServerContext(
slaves={
0x01: ModbusSlaveContext(
di=datablock,
co=datablock,
hr=datablock,
ir=datablock,
),
0x02: ModbusSlaveContext(
di=datablock,
co=datablock,
hr=datablock,
ir=datablock,
),
},
single=False
),
# Data storage
identity=ModbusDeviceIdentification(
info_name={
"VendorName": "Pymodbus",
"ProductCode": "PM",
"VendorUrl": "https://github.com/pymodbus-dev/pymodbus/",
"ProductName": "Pymodbus Server",
"ModelName": "Pymodbus Server",
"MajorMinorRevision": pymodbus_version,
}
), # server identify
port="COM11", # serial port
framer=ModbusRtuFramer, # The framer strategy to use
baudrate=19200, # The baud rate to use for the serial device
)
return server
async def async_helper():
_logger.info("Starting...")
await run_async_server()
if __name__ == "__main__":
asyncio.run(async_helper(), debug=True) # pragma: no coverLog
INFO:C:\Users\jannik.goebel\Documents\Projects\python\modbusServer\example.py:Starting...
2023-07-25 10:12:35,621 INFO logging:96 Server(Serial) listening.
INFO:pymodbus.logging:Server(Serial) listening.
2023-07-25 10:12:35,622 DEBUG logging:102 Awaiting connections server_listener
DEBUG:pymodbus.logging:Awaiting connections server_listener
2023-07-25 10:12:35,622 WARNING logging:108 Failed to start server could not open port '127.0.0.1': FileNotFoundError(2, 'Das System kann die angegebene Datei nicht finden.', None, 2)
WARNING:pymodbus.logging:Failed to start server could not open port '127.0.0.1': FileNotFoundError(2, 'Das System kann die angegebene Datei nicht finden.', None, 2)
2023-07-25 10:12:35,622 ERROR logging:114 Server unexpected exception 'NoneType' object has no attribute 'serve_forever'
ERROR:pymodbus.logging:Server unexpected exception 'NoneType' object has no attribute 'serve_forever'Metadata
Metadata
Assignees
Labels
No labels