# Load the timer and TSA libraries import threading import tsa currentTime = time.time(); def checkForPulses(): #checks every 1 seconds threading.Timer(1, checkForPulses).startCheck() return tsa.check(); #Logfile to capture the timestamps logFile = open('log.txt, a); if tsa.connect() #Check every second to see if the TSA sent a TTL pulse. If the pulse is sent, this will return true and we can capture the timestamp of when it returns if checkForPulses() pulseTime = time.time(); logFile.write(pulseTime); #if you wanted to capture the time between the start and the pulse logFile.write(pulseTime - currentTime); tsa.disconnect(); else: print "TSA failed to connect";
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question