pymodbus-dev / pymodbus

A full modbus protocol written in python
Other
2.16k stars 889 forks source link

Add should_respond attribute to ModbusRequest #2223

Open jameshilliard opened 6 days ago

jameshilliard commented 6 days ago

Allows for custom ModbusRequest classes where responses may not be expected.

jameshilliard commented 5 days ago

However such a change really needs a number of specific test cases (the major problem seems to be if a custom class is added and then used with a sync client), also the possibility needs to be documented, with at least one example.

I added some test cases/examples, not sure if I'm doing that correctly but they seem to pass. By the way when I was testing this didn't seem to work well with say the socket framer(not sure if there's a way to make it compatible with that or if it should just be disabled for non-RTU framers.

janiversen commented 5 days ago

Either it should work with all framers, or the library should warn the user so we can avoid issues.

I will take a look at the code tomorrow.

jameshilliard commented 3 days ago

Either it should work with all framers, or the library should warn the user so we can avoid issues.

Yeah, so it's a bit unclear to me how this interacts with real socket framer hardware, we only use the RTU framer ourselves so I don't really have anything to test with.

janiversen commented 2 days ago

Either it should work with all framers, or the library should warn the user so we can avoid issues.

Yeah, so it's a bit unclear to me how this interacts with real socket framer hardware, we only use the RTU framer ourselves so I don't really have anything to test with.

That is a very normal case, and the reason we have a test harness. Actually I am not too sure why this PR depend on the type of framer, it tells me something might be wrong.