stlehmann / pyads

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

Read array values with offset #406

Closed dscran closed 1 month ago

dscran commented 1 month ago

Hi,

as documented, I can easily read parts of an array by multiplying the data type with the number of values I'd like to read:

plc.read_by_name("MAIN.large_array", N * pyads.PLCTYPE_REAL)

where N is the number of values I'd like. Is there also a way to specify at which index the read should start?

chrisbeardy commented 1 month ago

Unfortunately not using read_by_name. This may be possible by using a raw read if you could adjust the offset, although I don't know if this is even supported by ADS. Unless you have a very, very large array, this is unlikely to save you much time as the ADS layer is quite efficient at transferring the bytes, and the conversion to the type happens in the C layer in the pyADS side for arrays.