I am not very used to python ctypes, so sorry if this is a naive question. I am trying to copy a struct, this is my code:
from ctypes import *
class Group(Structure):
_fields_ = [
("ChSize", c_uint32*9),
("DataChannel", POINTER(c_float)*9),
("TriggerTimeLag", c_uint32),
("StartIndexCell", c_uint16)]
def deepcopy(self):
copy = Group()
for n_channel in range(9):
data_buffer = c_float*self.ChSize[n_channel]
memmove(
addressof(data_buffer),
self.DataChannel[n_channel],
self.ChSize[n_channel]*sizeof(c_float),
)
copy.ChSize[n_channel] = self.ChSize[n_channel]
copy.DataChannel[n_channel] = addressof(data_buffer)
copy.TriggerTimeLag = self.TriggerTimeLag
copy.StartIndexCell = self.StartIndexCell
return copy
However, when I try to use it, I get
TypeError: invalid type
What would be the correct way of creating a complete new copy of a Group object?
Assuming the nine sizes represent the length of each float array pointed to by each of the nine DataChannel pointers:
Output: