Can't read coil(code 0x05) from PyModbus Simulator #2906
-
|
Hello! I'm really enjoying using your library(pymodbus[simulator] v3.8.6). The simulator is a big help in my work. But now I've encountered a problem: I can't write to or read coil(code 0x05) from the simulator. My simulator configuration: My code for writing to the coil: Log from simulator: Log from my code: Since I'm writing to the coil, I added it to the "write" section. Since it's a coil, I also duplicated it in "bits." Coils i used is: 20503, 20736, 20739. I've already tested this on a real device and everything works. So, I have no doubts about my code. What am I doing wrong? I have no problems reading or writing registers from simulator. I would be very grateful for your help. I hope I posted in the right place. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
|
your example do not include the read_coil ??? the exception response tells that you are not allowed to write, remark in shared memory you cannot write a single coil, since the address references 16 bits. What do you mean you cannot read coil, what happens ? I assume you get an exception response, which should tell you what went wrong. Did you try to set "type exception": false, Please add the pymodbus debug log, so we can see what happens (on both simulator and client side). |
Beta Was this translation helpful? Give feedback.
-
|
Did you note that the newest release when SimData/SimDevice making data configuration much easier. |
Beta Was this translation helpful? Give feedback.
I think the new SimData/SimDevice is better for most parts....it does not however offer the html interface (yet to come).
I found your problem, your address is wrong.
As Documented Read/Write_coils addresses a bit NOT a register, so in shared mode you need to do
address = register_address * 16 + bit_offset