Closed pythcoiner closed 3 months ago
here:
{id: ModbusSlaveContext}
is passed to request.execute()
instead of ModbusSlaveContext
You re not using modbus server context correctly, please see our examples e.g. server_async.py
Closing as it is a usage problem, not a bug.
You re not using modbus server context correctly, please see our examples e.g. server_async.py humm if you have time, i'm interested you point to me where is the issue here(as i cannot run
server_async.py
because crashing i guess due to some breaking changes inhelper
package:
from pymodbus.server import StartSerialServer
from pymodbus.datastore import ModbusServerContext, ModbusSlaveContext, ModbusSequentialDataBlock
from pymodbus.transaction import ModbusRtuFramer
store = ModbusSequentialDataBlock(0x6500, [0x00] * 10)
context = ModbusServerContext({10: ModbusSlaveContext(di=None, co=None, hr=store, ir=None, zero_mode=True)})
StartSerialServer(context=context,
framer=ModbusRtuFramer,
port="/dev/ttyUSB2",
baudrate=115200,
ignore_missing_slaves=True
)
Look at example I pointed you to.
Look at example I pointed you to.
i've looked but do not see any difference in the method (i'm likely to be wrong) and tryed to run but as i told you in my last message i got some crash about helper
.
It seems you look very lightly at the example, there are clear differences.
The example is tested with every commit, so it should work.
It seems you look very lightly at the example, there are clear differences.
sorry if its not clear to me.
The example is tested with every commit, so it should work.
yeah maybe works on the test system.
My point is:
requirements.txt
nor comment related to the example.helper
but some other , who know? you certainly, after all its your repo.Thanks to have made this lib and continuing maintaining it, ill no bother you by trying contribute.
Have a good day Jan
If you read read our docs, it tells you that the examples named "simple*" ca; run standalone, while for the rest you need to download the complete example directory, which we even provide as a compressed file along with the documentation.
If you cannot see that you call modbusservercontext, differently than in our examples then I really cannot help you.
I did NOT close your PR I never do that !! you closed it yourself! I merely added review comments which is my duty.
Like many packages we do not use requirements.txt but pyproject, you can hardly blame us for that.
What you seem to be missing is reading the docs as published on https://pymodbus.readthedocs.io/en/latest/source/examples.html
When you decide to complain, then please get the facts right, I merge PR from multiple volunteers every month see https://github.com/pymodbus-dev/pymodbus/pulse so we are very open.....but we do expect people do their homework.
Closing as it is a usage problem, not a bug.
I did NOT close your PR I never do that !! you closed it yourself! I merely added review comments which is my duty.
well right, you close the issue instead(spoiler: its not usage problem, there is a bug)
If you read read our docs, it tells you that the examples named "simple*" ca; run standalone, while for the rest you need to download the complete example directory, which we even provide as a compressed file along with the documentation.
Well, i read the doc about server
, not the whole doc, right
If you cannot see that you call modbusservercontext, differently than in our examples then I really cannot help you.
yes still not see sorry ( but .....)
Like many packages we do not use requirements.txt but pyproject, you can hardly blame us for that.
well i dont read the whole doc nor the whole repo, you right
so now i'm comming to the most important, there is a bug:
~/python/pymodbus/examples dev !2 ❯ python3 server_async.py --comm serial --framer rtu --log debug --port "/dev/ttyUSB1" --store sequential --slaves 3 --baudrate 115200
2024-04-05 13:32:20,568 DEBUG logging:103 Awaiting connections server_listener
2024-04-05 13:32:20,570 INFO logging:97 Server listening.
2024-04-05 13:32:20,570 DEBUG logging:103 Connected to server
2024-04-05 13:32:26,174 DEBUG logging:103 recv: 0x1 0x3 0x0 0x1 0x0 0x1 0xd5 0xca old_data: addr=None
2024-04-05 13:32:26,175 DEBUG logging:103 Handling data: 0x1 0x3 0x0 0x1 0x0 0x1 0xd5 0xca
2024-04-05 13:32:26,175 DEBUG logging:103 Processing: 0x1 0x3 0x0 0x1 0x0 0x1 0xd5 0xca
2024-04-05 13:32:26,175 DEBUG logging:103 Getting Frame - 0x3 0x0 0x1 0x0 0x1
2024-04-05 13:32:26,177 DEBUG logging:103 Factory Request[ReadHoldingRegistersRequest': 3]
2024-04-05 13:32:26,177 DEBUG logging:103 Frame advanced, resetting header!!
2024-04-05 13:32:26,179 ERROR logging:115 Datastore unable to fulfill request: 'ModbusSlaveContext' object has no attribute 'keys'; Traceback (most recent call last):
File "/home/pyth/Git/faure/axis_server/python/venv/lib/python3.11/site-packages/pymodbus/server/async_io.py", line 192, in _async_execute
if request.slave_id in self.server.context[request.slave_id].keys():
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'ModbusSlaveContext' object has no attribute 'keys'
this bug looks a bit different than the one i hit but still about context.
but maybe its just about the guy that write example don't read correctly the doc? oh, let looks who write this example??? :smiling_face_with_tear:
i guess you have enough to find out as you look far more clever than me!
have a good day Jan
(ps: in this doc, some args are not documented in the header, i let you fin out wich one)
well right, you close the issue instead(spoiler: its not usage problem, there is a bug)
And what I did was correct, because the code you showed was faulty !
Well, i read the doc about
server
, not the whole doc, right
hmmm when you complain about that an example does not work, it sounds like a good idea to read the documentation about examples....it is not hidden it is right in the side panel.
yes still not see sorry ( but .....)
Well that is really not my problem, I have now several times told you that what you do is wrong.
well i dont read the whole doc nor the whole repo, you right
Experienced people know there are 3 popular ways to define required packages.
so now i'm comming to the most important, there is a bug:
~/python/pymodbus/examples dev !2 ❯ python3 server_async.py --comm serial --framer rtu --log debug --port "/dev/ttyUSB1" --store sequential --slaves 3 --baudrate 115200 2024-04-05 13:32:20,568 DEBUG logging:103 Awaiting connections server_listener 2024-04-05 13:32:20,570 INFO logging:97 Server listening. 2024-04-05 13:32:20,570 DEBUG logging:103 Connected to server 2024-04-05 13:32:26,174 DEBUG logging:103 recv: 0x1 0x3 0x0 0x1 0x0 0x1 0xd5 0xca old_data: addr=None 2024-04-05 13:32:26,175 DEBUG logging:103 Handling data: 0x1 0x3 0x0 0x1 0x0 0x1 0xd5 0xca 2024-04-05 13:32:26,175 DEBUG logging:103 Processing: 0x1 0x3 0x0 0x1 0x0 0x1 0xd5 0xca 2024-04-05 13:32:26,175 DEBUG logging:103 Getting Frame - 0x3 0x0 0x1 0x0 0x1 2024-04-05 13:32:26,177 DEBUG logging:103 Factory Request[ReadHoldingRegistersRequest': 3] 2024-04-05 13:32:26,177 DEBUG logging:103 Frame advanced, resetting header!! 2024-04-05 13:32:26,179 ERROR logging:115 Datastore unable to fulfill request: 'ModbusSlaveContext' object has no attribute 'keys'; Traceback (most recent call last): File "/home/pyth/Git/faure/axis_server/python/venv/lib/python3.11/site-packages/pymodbus/server/async_io.py", line 192, in _async_execute if request.slave_id in self.server.context[request.slave_id].keys(): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'ModbusSlaveContext' object has no attribute 'keys'
I can see your client does a read_holding registers of slave 1 address 1 count 1, so I ran a test with that:
examples % ./server_async.py --comm serial --framer rtu --log debug --port socket://127.0.0.1:5020 --store sequential --slaves=3
2024-04-05 14:28:46,762 DEBUG logging:103 Awaiting connections server_listener
2024-04-05 14:28:46,762 INFO logging:97 Server listening.
2024-04-05 14:28:53,864 DEBUG logging:103 Connected to server
2024-04-05 14:28:53,865 DEBUG logging:103 recv: 0x1 0x3 0x0 0x1 0x0 0x1 0xd5 0xca old_data: addr=None
2024-04-05 14:28:53,866 DEBUG logging:103 Handling data: 0x1 0x3 0x0 0x1 0x0 0x1 0xd5 0xca
2024-04-05 14:28:53,866 DEBUG logging:103 Processing: 0x1 0x3 0x0 0x1 0x0 0x1 0xd5 0xca
2024-04-05 14:28:53,866 DEBUG logging:103 Getting Frame - 0x3 0x0 0x1 0x0 0x1
2024-04-05 14:28:53,866 DEBUG logging:103 Factory Request[ReadHoldingRegistersRequest': 3]
2024-04-05 14:28:53,866 DEBUG logging:103 Frame advanced, resetting header!!
2024-04-05 14:28:53,866 DEBUG logging:103 validate: fc-[3] address-2: count-1
2024-04-05 14:28:53,866 DEBUG logging:103 getValues: fc-[3] address-2: count-1
2024-04-05 14:28:53,866 DEBUG logging:103 send: 0x1 0x3 0x2 0x0 0x11 0x78 0x48
2024-04-05 14:28:56,802 DEBUG logging:103 -> transport: received eof
2024-04-05 14:28:56,803 DEBUG logging:103 Connection lost server due to None
2024-04-05 14:28:56,803 DEBUG logging:103 Handler for stream [server] has been canceled
As you can I run with the same parameters as you, and there are NO problem. I suspect you have tested with a modified example.
but maybe its just about the guy that write example don't read correctly the doc? oh, let looks who write this example???
Or maybe it is more about a guy who do not want to listen !
(ps: in this doc, some args are not documented in the header, i let you fin out wich one)
You have really misunderstood what open source is about, if you find a bug, you submit a pull request, this is not a game !
Do you seriously think I will waste time searching.... a polite warning, your attitude is not what we like to see, and is a sure reason you will not get any help, we help people who wants to be helped.
Versions
Pymodbus Specific
Description
raise this exception if an modbus id is defined in the ModbusServerContext
Code and Logs
log: