0

In my project I need to write negative intager in a PLC 1200 siemens. Now I'm using Pymodbus to write and read my register but I can't find a way to write negative integers because the console show me always this error:

"struct.error: argument out of range"

In this project I'm use Flask

this is my code:

def writeIntRegister(postName, address):
    post = request.form.get(postName)
    post = int(post)
    client.write_registers(address, post)

How I can decode the intager?

Giuseppe
  • 39
  • 1
  • 9
  • `post & 0xFFFF` would produce a 16-bit integer that would at least avoid this error, I can't guarantee it's in the format your PLC wants. – jasonharper Jul 31 '20 at 16:37
  • Ok thanks it's works but I also need to visualize it in the right format not in PLC but in a web page, do you have any hint? – Giuseppe Aug 03 '20 at 11:03

0 Answers0