423,822 Members | 1,356 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,822 IT Pros & Developers. It's quick & easy.

How to pass a reference of instance of a structure of structures in python using ctyp

P: 1
a wrapper is been written for a .dll file to use in python. a function has argument as reference of instance of structure of structures. like this
this is C#
settings(Int32 hObject, ref FSettings pSettings)

public struct FSettings
public UInt16 perf_en;
public CSETTINGS C1;
public CFSETTINGS Cf1;

public struct CSETTINGS
public byte Mod;
public byte SetB;
public struct CFSETTINGS
public byte FDMod;
public byte SetFDB;

I have written in python like this

class CSETTINGS(C.Structure):
_pack_ = 1
_fields_ = [

class CANFD_SETTINGS(C.Structure):
_pack_ = 1
_fields_ = [

class SFire2Settings(C.Structure):
_pack_ = 1
_fields_ = [

f =C.WinDLL ("port.dll")
f.setFSettings.restype = C.c_int32

settings =FSettings()
setFSettings(1,settings )

i am getting error like this :
: <type 'exceptions.TypeError'>: expected LP_FSettings instance instead of _ctypes.PyCStructType
May 16 '18 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.