473,396 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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_ = [
("Mod",C.c_byte),
("SetB",C.c_byte)
]

class CANFD_SETTINGS(C.Structure):
_pack_ = 1
_fields_ = [
("FDMod",C.c_byte),
("SetFDB",C.c_byte)
}

class SFire2Settings(C.Structure):
_pack_ = 1
_fields_ = [
("perf_en",C.c_uint16),
("C1",C.POINTER(CSETTINGS)),
("Cf1",C.POINTER(CFSETTINGS))
]

f =C.WinDLL ("port.dll")
f.setFSettings.restype = C.c_int32
f.setFSettings.argtypes=[C.c_int32,C.POINTER(FSettings)]

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
0 996

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

Similar topics

1
by: Steve | last post by:
Hi, I've written a small cgi python script that collects feedback from a webform. I need to pass the values to another python script.. how do I do this? Is this even possible? Thanks Steve
0
by: Helmut Zeisel | last post by:
I want to build a static extension of Python using SWIG and VC++ 6.0 as described in http://www.swig.org/Doc1.3/Python.html#n8 for gcc. My file is testerl.i: ========================= %module...
4
by: Omar Llanos | last post by:
Recently, I posted a question on how to invoke a textbox control in Form1 (parent form) from within Form2 (which is inherited from Form1). Someone suggested to pass a reference of the Form1 to the...
2
by: prakashgkhaire | last post by:
i have two structure where first structure consists val and structure pointer(linklist), 2nd structure consists, val, a varialbe of first structure, pointer of structure. Now i found to pass the...
7
by: wardm | last post by:
I have created a Dict object in a C++ App that calls (embedded) Python functions. The Dict is to be used to pass variable data between the C++ App and the python functions. However I cannot get...
4
by: Tony Johansson | last post by:
Hello! I have a class definition called MyClass see below. I create an instance of this class MyClass I also want this instance to be able to modify the test instance that exist in this...
4
by: tony.ha | last post by:
Hello, I have open a Python program in the IDLE, but when I select the "run module" under "run" menu, it does not allow me to pass an argument to my Python program! How do you pass an argument...
0
by: Joe Strout | last post by:
On Nov 10, 2008, at 2:44 PM, Zane Selvans wrote: How are you creating your list? You need to make sure that each instance creates its very own list object, something like: self.foo = ...
0
by: cnivas | last post by:
Hi, I'm doing a small application in python using mac os x. Now, I want to insert an image in the web application. I have given the image path also... but it shows "?" this symbol.... If the...
1
by: sudan20089 | last post by:
How can i create gui in python using pyopengl? Or simply i want to create textbox in python using pyopengl which takes the value entered in text box and the calculation can be conducted. please help...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.