stlehmann / pyads

Python wrapper for TwinCAT ADS
MIT License
246 stars 93 forks source link

Feature - Reading multidimensional arrays #322

Open disgustingBot opened 2 years ago

disgustingBot commented 2 years ago

setup: TwinCat 3, pyads version: 3.3.7.

scenario: I have an array in PLC with the shape 4x12, trying to read from python reads as a flatten 1d array (that seems a wee bit odd, but is ok enough). The problem is, if I do conn.read_by_name('variable', data_type*48) I get an array where every other value (even indexes) is 0, and the rest (odd indexes) are the values expected to read (hence having half the array). So I have to actually try to read 96 values and ignore all the zeros.

Is not that bad, because there is a workaround (just read more values) but I still wanted to report, maybe it helps.

All in all, the library works like a charm and I am very grateful to all of the contributors. Thanks a lot

chrisbeardy commented 2 years ago

reading multidimensional arrays is not currently supported. I expected that it would come back as a 1d array but the every other values as a zero is an odd one.

Reading arrays of arrays (var : ARRAY [0..3] OF ARRAY [0..11] OF LREAL ) comes back slightly nicer but still isn't great.

Reading multidimensional arrays properly is on the wish list, but thanks for letting us know.