gijzelaerr / python-snap7

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

Unable to read Datablock information with client.get_block_info() #301

Closed tom-schulte-wpk closed 3 years ago

tom-schulte-wpk commented 3 years ago

Hi, I am trying to use the function get_block_info() of the class client. However I am getting following error message:

File "C:\Users\thomas.schulte\Anaconda3\lib\site-packages\snap7\common.py", line 92, in check_error raise Snap7Exception(error)

Snap7Exception: b'CPU : Function not available'

I wanted to get Information of the DB without knowing the number of variables and their length especially, because somehow it could be possible that someone changes the layout of the DB.

My hardware config is a Siemens IPC 427E 3xPN/IE with a soft-SPS (1507 S).

Could there be a problem with the usage of this part of the function in combination with a 1500 CPU result = self._library.Cli_GetAgBlockInfo(self._pointer, blocktype_, db_number, byref(data)) check_error(result, context="client")

My example code is: `` import sys import time import pandas as pd import numpy as np import datetime

import snap7 from snap7.types import from snap7.util import from snap7 import types,util from snap7.util import get_bool,get_int import ctypes from snap7.types import TS7BlockInfo from snap7.exceptions import Snap7Exception import logging from ctypes import c_int, c_char_p, byref, sizeof, c_uint16, c_int32, c_byte, c_ulong, Array from snap7.common import check_error, load_library, ipv4 from snap7.util import *

client = snap7.client.Client()

ip_adress = "192.167.10.1" rack = 0 slot = 1 tcp_port = 4840

client.connect(ip_adress,rack,slot)

db_number = 41

test = client.get_block_info("DB",41)``

The DB layout is shown in the attached image.

DB_Block_Info

I hope someone has a hint or advice for me

for me. Otherwise I have to use some kind of work around with a defined db layout with some sort of code from this site -> https://gist.github.com/remceTkedaR/db9bc5218aedb900900f7e4f719a91a6#file-s7-1200_client_snap7-py