Skip to content
Discussion options

You must be logged in to vote

Here is one way to use as function called polling :

client = snap7.client.Client()
client.connect("192.168.0.5", 0, 1)


while True:
    byte_length = 2
    datablock = 2001
    start_index_byte = 4

    data_buffer = (ctypes.c_uint8 * byte_length)()
    response_code = client.as_db_read(datablock, start_index_byte, byte_length, data_buffer)
    print(f"response_code {response_code}")
    if response_code != 0:
        print(f"not able to read DB to plc data .. prolly failed tcp")

    while client.check_as_completion(data_buffer) == 1:
        print("Doing something else")
    
    print("read DB done!")

    int_list = list(data_buffer)   
    int_list = [int(element) for element in int…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by gijzelaerr
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #481 on January 11, 2024 09:21.