c array

luca72 lucaberto at libero.it
Wed Apr 29 16:43:38 CEST 2009

hello i'm using ctypes

i have this c function
PREF0 short usb_tc08_get_single (
  short   handle,
  float * temp,
  short * overflow_flags,
  short   units);
where :
nt main(void)
	short handle = 0;     /* The handle to a TC-08 returned by
usb_tc08_open_unit() */
	char selection = 0;   /* User selection from teh main menu */
	float temp[9];        /* Buffer to store temperature readings from
the TC-08 */
	int channel, reading; /* Loop counters */
	int retVal = 0;       /* Return value from driver calls indication
success / error */
	USBTC08_INFO unitInfo;/* Struct to hold unit information */

how i can pass the value using c types?
strumento = ctypes.cdll.LoadLibrary('libusbtc08.so') and here is ok
but when i call the function
strumento.short usb_tc08_get_single(arg1, arg2,arg3,arg4)
arg1 is 0 arg2 2 is a carray i dont know how to convert, arg3 is none
and arg 4 is a string here is the c example
usb_tc08_get_single(handle, temp, NULL, USBTC08_UNITS_CENTIGRADE)

More information about the Python-list mailing list