I compiled a dll for a program in Python. Here is the code of the exported function:
#include "stdafx.h" #include "PollSensors.h" #ifdef __cplusplus extern "C" { #endif __declspec( dllexport ) double __GetLightSensor(); #ifdef __cplusplus } #endif double __GetLightSensor() { Sensor sensor; if (!sensor.is_available()) { return 1; } sensor.poll(); Sleep(250); return sensor.get()[0]; }
This is a library for receiving data from a light sensor in Windows. I think it is not necessary to give the Sensor class code, the program collected in exe works successfully and prints the data to the console. But in trouble with downloading this dll in Python:
from ctypes import * lib = windll.LoadLibrary("lightSensor.dll") while True: print lib.__GetLightSensor() Всегда выводит только одно значение.... Несмотря на то, что данные, выводимые данной функцией меняются в зависимости от степени освещения. Что я не правильно делаю?