ctypes

luca72 lucaberto at libero.it
Wed Apr 29 04:05:52 EDT 2009


can you explain how to use this function :
this is the api documentation :
PREF0 short usb_tc08_get_single (
  short   handle,
  float * temp,
  short * overflow_flags,
  short   units);

This is the sample made in c:
int 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 */

usb_tc08_get_single(handle, temp, NULL, USBTC08_UNITS_CENTIGRADE);
i do
strumento = ctypes.cdll.LoadLibrary('/home/luca/Desktop/luca/
progetti_eric/Pico/libusbtc08-1.7.2/src/.libs/libusbtc08.so')
strumento.usb_tc08_get_single.argtypes = [ctypes.c_short,
ctypes.c_float, ctypes.c_short, ctypes.c_short] is this correct?
strumento.usb_tc08_get_single.restype = ctypes.c_short is this
correct?
now how i can use the function?
leggo = strumento.usb_tc08_get_single(0, temp,
'NULL','USBTC08_UNITS_CENTIGRADE')
how i can define ad pas the value temp, null,USBTC08_UNITS_CENTIGRADE

thanks luca



More information about the Python-list mailing list