Problem with a c structure
Ion Padilla <[email protected]> Wed, 16 May 2012 11:01:47 +0100
| Newsgroups | gmane.comp.python.ctypes |
|---|---|
| Message-ID | <CAHtv6bOpSiP6j3Qx+SGbisLEKpVFyvqy1v9edBo2VqSkLzkq2g@mail.gmail.com> |
Hello,
I am trying to create an application that uses this structure:
*class ISD_STATION_INFO_TYPE (ctypes.Structure):
_fields_=[('ID',ctypes.c_ulong)
,('State',ctypes.c_long)
,('Compass',ctypes.c_long)
,('InertiaCube',ctypes.c_long)
,('Enhancement',ctypes.c_ulong)
,('Sensitivity',ctypes.c_ulong)
,('Prediction',ctypes.c_ulong)
,('AngleFormat',ctypes.c_ulong)
,('TimeStamped',ctypes.c_long)
,('GetInputs',ctypes.c_long)
,('GetEncoderData',ctypes.c_long)
,('CompassCompensation',ctypes.c_byte)
,('ImuShockSuppression',ctypes.c_byte)
,('UrmRejectionFactor',ctypes.c_byte)
,('bReserved2',ctypes.c_byte)
,('CoordFrame',ctypes.c_ulong)
,('AccelSensitivity',ctypes.c_ulong)
,('fReserved1',ctypes.c_float)
,('fReserved2',ctypes.c_float)
,('TipOffset',ctypes.c_float*3)
,('fReserved3',ctypes.c_float)
,('GetCameraData',ctypes.c_long)
,('GetAuxInputs',ctypes.c_long)
,('GetCovarianceData',ctypes.c_long)
,('GetExtendedData',ctypes.c_long)]*
that comes from this structure in c:
*typedef struct
{
DWORD ID;
Bool State;
Bool Compass;
LONG InertiaCube;
DWORD Enhancement;
DWORD Sensitivity;
DWORD Prediction;
DWORD AngleFormat;
Bool TimeStamped;
Bool GetInputs;
Bool GetEncoderData;
BYTE CompassCompensation;
BYTE ImuShockSuppression;
BYTE UrmRejectionFactor;
BYTE bReserved2;
DWORD CoordFrame;
DWORD AccelSensitivity;
float fReserved1;
float fReserved2;
float TipOffset[3];
float fReserved3;
Bool GetCameraData;
Bool GetAuxInputs;
Bool GetCovarianceData;
Bool GetExtendedData;
}
ISD_STATION_INFO_TYPE;*
Using this structure I want to call to a function to get the structure
using byref, change the field GetInputs to TRUE and set it again. The call
to the function is not working and the variable after the call returns
setted to FALSE. What I am doing wrong? Is there any compatibility problem
with the structure? Here is the code:
* config=ISD_STATION_INFO_TYPE()
isenseWrapper.ISD_GetStationConfig(handle,ctypes.byref(config),WAND_STATION,1)
config.GetInputs = not config.GetInputs
isenseWrapper.ISD_SetStationConfig(handle,ctypes.byref(config),WAND_STATION,1)
*
PS: The first call works and I get the structure correctly filled, is not
empty
Thanks in advantage
Regards
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
ctypes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ctypes-users