wasdee / python-snap7

A Python wrapper for the snap7 PLC communication library
http://python-snap7.readthedocs.org/
MIT License
0 stars 0 forks source link

snap7.exceptions.Snap7Exception: b'CLI : function refused by CPU (Unknown error)' #2

Open wasdee opened 2 years ago

wasdee commented 2 years ago
import snap7

client = snap7.client.Client()

# client.connect("127.0.0.1", 0, 0, 1012)
import snap7.client as c
from snap7.util import *
def WriteOutput(device, byte, bit, cmd):
    data = device.read_area(0x82,0,byte,1)
    set_bool(data, byte, bit, cmd)
    device.write_area(0x82,0,byte, data)

client.connect("192.168.1.250", 0, 1)
client.get_connected()

# WriteOutput(client, 0,2, True)

data = client.db_read(1, 0, 4)

# print(data)
PS C:\pcl> & C:/Users/lifep/AppData/Local/Programs/Python/Python38/python.exe c:/pcl/init.py
b'CLI : function refused by CPU (Unknown error)'
Traceback (most recent call last):
  File "c:/pcl/init.py", line 18, in <module>
    data = client.db_read(1, 0, 4)
  File "C:\Users\lifep\AppData\Local\Programs\Python\Python38\lib\site-packages\snap7\client.py", line 228, in db_read
    check_error(result, context="client")
  File "C:\Users\lifep\AppData\Local\Programs\Python\Python38\lib\site-packages\snap7\common.py", line 92, in check_error
    raise Snap7Exception(error)
snap7.exceptions.Snap7Exception: b'CLI : function refused by CPU (Unknown error)'
wasdee commented 2 years ago

aleady try to https://sourceforge.net/p/snap7/discussion/general/thread/ef6aab94/ and http://snap7.sourceforge.net/snap7_client.html#1200_1500 , https://stackoverflow.com/questions/47979438/s7-1200-snap7-exception-cli-function-refused-by-cpu-unknown-error/48383015#48383015