TIA Portal Configuration
S7-1200 and S7-1500 PLCs require specific configuration in TIA Portal before
python-snap7 can communicate with them. Without these settings, you will get
CLI : function refused by CPU errors.
Step 1: Enable PUT/GET Communication
Open your project in TIA Portal.
In the project tree, double-click on the PLC device.
Go to Properties > Protection & Security > Connection mechanisms.
Check Permit access with PUT/GET communication from remote partner.
Compile and download to the PLC.
Warning
This setting allows any network client to read and write PLC memory without authentication. Only enable this on isolated industrial networks.
Step 2: Disable Optimized Block Access
This must be done for each data block you want to access:
In the project tree, right-click on the data block (e.g., DB1).
Select Properties.
Go to the Attributes tab.
Uncheck “Optimized block access”.
Click OK.
Compile and download to the PLC.
Warning
Changing the “Optimized block access” setting reinitializes the data block, which resets all values in that DB to their defaults. Do this before commissioning, or back up your data first.
Step 3: Compile and Download
After making both changes:
Compile the project (Build > Compile).
Download to the PLC (Online > Download to device).
The PLC may need to restart depending on the changes.