Replies: 7 comments
-
thanks for this, can you please post a minimal code snippet which can replicate this issue? In your example it is not clear what self.cmd, self.getReadSize() etc is doing? What are you trying to achieve overall? it is normally not required for the user to call read_write directly? |
Beta Was this translation helpful? Give feedback.
-
this is how to prepare for self.cmd |
Beta Was this translation helpful? Give feedback.
-
OK, I'm not 100% sure what could be causing your error but I suspect at some point, python thinks that your self.cmd is now an int and not a bytearray before you call the read_write function?. Hence the error |
Beta Was this translation helpful? Give feedback.
-
so in pyads what kind of format need to receive as value argument in read_write()function? |
Beta Was this translation helpful? Give feedback.
-
actually the self.cmd is bytearray , but inside pyads_ex.py
here is the |
Beta Was this translation helpful? Give feedback.
-
our own test is here: pyads/tests/test_connection_class.py Line 397 in 8086c9f Line 925 in 8086c9f sum_req_array_type = SAdsSumRequest * num_requests
sum_req_array = sum_req_array_type() I would also say take a look into the read list by name method and source code too. Line 550 in 8086c9f |
Beta Was this translation helpful? Give feedback.
-
closing as this is a support, not an issue, planning on pening discussions in Github |
Beta Was this translation helpful? Give feedback.
-
i am using python 3.12 and pyads 3.4
when call read_write() function, there is an error
'int' has no attribute if size
the code as below:
read_data_type = pyads.PLCTYPE_USINT * self.getReadSize()
write_data_type = lambda v: (pyads.PLCTYPE_USINT * len(self.cmd))(*v)
self.result = bytearray(self.conn.read_write(
self.ADSIGRP_SUMUP_READ, self.n_vars,
read_data_type,
self.cmd, write_data_type))
i print out the two variables
read_data_type
<class 'lib.gom_cx.c_ubyte_Array_260'>
write data type
<class 'lib.gom_cx.c_ubyte_Array_12'>
i debug into read_write()
looks like it comes from this line.
Beta Was this translation helpful? Give feedback.
All reactions