stlehmann / pyads

Python wrapper for TwinCAT ADS
MIT License
254 stars 94 forks source link

Incorrect type detection of string array in `parse_notification` #409

Open xiaoliu-heng opened 3 weeks ago

xiaoliu-heng commented 3 weeks ago

the type could be wrong when use auto_update for c_char_Array likeSTRING(28)

image
chrisbeardy commented 3 weeks ago

possibly related or same fix required for #356 and #405

RobertoRoos commented 1 day ago

The fix in PR #410 is nice, but I think AdsConnection shouldn't re-implement the type parsing that already exists in get_value_from_ctype_data() at all. I'm trying to squeeze it into PR #419 .

Issue can be reproduced with:

    with Connection(ams_net_id="127.0.0.1.1.1", ams_net_port=851) as plc:
        symbol_name = "GVL_Example.auto_string"

        plc.write_by_name(symbol_name, value="Hello")
        sleep(0.5)

        var = plc.get_symbol(symbol_name, auto_update=True)
        print(var.value)

        plc.write_by_name(symbol_name, value="Hello world!")

        sleep(0.5)

        print(var.value)