#specify input arguments and types to the C clock_gettime() functionĬlock_gettime.argtypes = Librt = ctypes.CDLL('librt.so.1', use_errno=True) #Configure Python access to the clock_gettime C library, via ctypes: #-NB: use c_long (generally signed 32-bit) variables within the timespec C struct, per the definition here: "return a timestamp in milliseconds (ms)" of the internal ~2MHz QPC clockĬ(ref(freq)) #get ticks on the internal ~2MHz QPC clockĬ(ref(tics)) Tics = ctypes.c_int64() #use *signed* 64-bit variables see the "QuadPart" variable here: (v=vs.85).aspx "return a timestamp in microseconds (us)" click "Contact me" at the top of my website to find my email addressĢ0160907 - v0.2.1 created - updated delay functions to use modulus operator to guarantee proper C uint32_t-like underflow subtraction behavior when the timer rolls overĢ0160813 - v0.2.0 created - added Linux capabilityĢ0160711 - v0.1.0 created - functions for Windows *only* (via the QPC timer)ġ) Acquiring high-resolution time stamps (Windows)Ģ) QueryPerformanceCounter function (Windows)ģ) QueryPerformanceFrequency function (Windows) (microseconds) timing functions for Python create some low-level Arduino-like millis() (milliseconds) and micros() Update (): I have updated these functions to work with Python in Linux now too! See below.įunctions and code samples. If you decide to adapt them to Linux, please share how you did it in the comments section. Since these functions use the Windows API's QueryPerformanceCounter and QueryPerformanceFrequency functions, as-written, they work for Python in Windows only. I made these to resemble Arduino functions I am already familiar with.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |