Skip to content

Commit

Permalink
🚸 http_ttl.py: add cedrus and lpt tests
Browse files Browse the repository at this point in the history
  • Loading branch information
WillForan committed Nov 29, 2023
1 parent ed78112 commit 7908c33
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
34 changes: 30 additions & 4 deletions http_ttl.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,23 +338,41 @@ async def seeg(verbose=False):


async def test_DAQ(verbose=False):
"only test DAQ. loop forever: send high and auto reset"
"only test DAQ. loop forever: send high and auto reset (seeg)"
hw = DAQ(verbose=verbose)
while True:
await asyncio.sleep(1)
print("sending high and zeroing")
hw.send(250) # 250 just has to be non-zero


async def test_LPT(verbose=False, address=0xD010):
"only test LPT. loop forever: send high and auto reset (loef eeg)"
hw = LPT(address=address, verbose=verbose)
while True:
await asyncio.sleep(1)
print("sending high and zeroing")
hw.send(250)


async def rtbox_test(verbose=False):
"no http server, no DAQ. just RTBox with generic hardware class"
"no http server, no DAQ. just RTBox with generic hardware class (seeg)"
hw = Hardware(verbose=verbose)
kb = KB()
rb = RTBox(hw, kb, verbose)
print("push button box keys. should see events here")
await asyncio.create_task(rb.watch())


async def cedrus_test(verbose=False):
"test cedrus response button box (loef eeg)"
hw = Hardware(verbose=verbose)
kb = KB()
rb = Cedrus(hw, kb)
http_run(hw)
await asyncio.create_task(rb.watch())


async def fakeeeg(usekeyboard=False, verbose=False):
"listen on port, but don't interface with DAQ or RTBox"
hw = Hardware(verbose=verbose)
Expand All @@ -374,7 +392,10 @@ async def fakeeeg(usekeyboard=False, verbose=False):
def parser(args):
import argparse
p = argparse.ArgumentParser(description="Intercept http queries and watch ButtonBox/PhotoDiode")
p.add_argument('place', choices=["loeff", "seeg", "test_http", "test_rtbox", "test_DAQ"], help='where (also how) to use button and ttl')
p.add_argument('place', choices=["loeff", "seeg", "test_http",
"test_rtbox", "test_DAQ",
"test_cedrus", "test_lpt"],
help='where (also how) to use button and ttl')
p.add_argument('-k','--keyboard', help='use keyboard (only for "test_http")', action='store_true', dest="usekeyboard")
p.add_argument('-v','--verbose', help='additonal printing', action='store_true', dest="verbose")
return p.parse_args(args)
Expand All @@ -389,10 +410,15 @@ def parser(args):
asyncio.run(seeg(verbose=args.verbose))
elif args.place == "test_http":
asyncio.run(fakeeeg(args.usekeyboard, verbose=args.verbose))

elif args.place == "test_DAQ":
asyncio.run(test_DAQ(verbose=args.verbose))

elif args.place == "test_rtbox":
asyncio.run(rtbox_test(verbose=args.verbose))

elif args.place == "test_cedrus":
asyncio.run(cedrus_test(verbose=args.verbose))
elif args.place == "test_lpt":
asyncio.run(test_LPT(verbose=args.verbose))
else:
print(f"unkown place '{args.place}'! -- argparse should have caught this")
7 changes: 7 additions & 0 deletions loeffeeg_test.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Rem test python bridge for ltp and cedrus box hardware
set PYTHON=C:\Program Files\PsychoPy\python.exe
echo ctrl-c to stop each test
echo TESTING CEDRUS BOX
"%PYTHON%" http_ttl.py test_cedrus
echo TESTING LPT
"%PYTHON%" http_ttl.py test_lpt

0 comments on commit 7908c33

Please sign in to comment.