Closed albertzfg closed 1 month ago
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?
this is how to prepare for self.cmd please help check is that OK for read_write()parameter when i want to execute sumupread function
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 'int' has no attribute of size
. Are you just trying to read multiple variables? Have you tried using the read_list_by_name
method?
so in pyads what kind of format need to receive as value argument in read_write()function?
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
'int' has no attribute of size
. Are you just trying to read multiple variables? Have you tried using theread_list_by_name
method?
actually the self.cmd is bytearray , but inside pyads_ex.py
if index_group == ADSIGRP_SUMUP_READ:
response_size = 4 * len(value)
print(value)
for _ in value:
response_size +=_.size
here is the _.size
function reports the error "int has no attribute of size".
so i am wondering what kind of format i need to provide to the read_write()function
our own test is here: https://github.com/stlehmann/pyads/blob/8086c9f723be6dc088a613098c1b535d771a9f89/tests/test_connection_class.py#L397 however this doesn't use the sumup_read If i'm honest i'm not sure what input this requires. We do have a function that uses it https://github.com/stlehmann/pyads/blob/8086c9f723be6dc088a613098c1b535d771a9f89/pyads/pyads_ex.py#L925 so this may help you out, it uses this:
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.
closing as this is a support, not an issue, planning on pening discussions in Github
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.