counsyl / counsyl-pyads

A Python implementation of the Twincat ADS protocol for Beckhoff PLCs
MIT License
20 stars 3 forks source link

read_ny_name problem #2

Open twoway opened 4 years ago

twoway commented 4 years ago

Hi I hope to get some help with this problem.

I have a working connection to PLC and can read info. When i do this i get correct answer: pprint.pprint(device.read_by_name('METERS._EM01_I_MAX_PV', REAL)) ##This works when i do this i get fault below: pprint.pprint(device.read_by_name(tag_names[4], tag_types[4])) if i replace tag_types[4] with REAL i get no error...

[2020-07-24 16:29:38,285][3988:MainThread][adsclient.py/exit][WARNING] AdsClient exiting with exception: <type 'exceptions.AssertionError'>, . <traceback object at 0x76640918> Traceback (most recent call last): File "twincat_plc_info_m4.py", line 67, in main() File "twincat_plc_info_m4.py", line 54, in main pprint.pprint(device.read_by_name(tag_names[0], tag_types[0])) File "/usr/local/lib/python2.7/dist-packages/counsyl_pyads-1.0.0-py2.7.egg/counsyl_pyads/adsclient.py", line 273, in read_by_name assert(isinstance(ads_data_type, AdsDatatype)) AssertionError

jonemo commented 4 years ago

Hi @twoway, it looks like the value of your variable tag_types[4] is not equal to the value of your variable REAL. The error message suggests that tag_types[4] has a different data type than expected.

A good next step for debugging this might be to find out the exact content of tag_types[4], maybe using a debugger or using print:

print type(tag_types[4])
print tag_types[4]