diff options
| author | Nathan Conrad <[email protected]> | 2019-09-19 18:58:15 -0400 |
|---|---|---|
| committer | Nathan Conrad <[email protected]> | 2019-09-19 19:01:08 -0400 |
| commit | 346443118fa9f22611ca1382ff999e43b6a40b43 (patch) | |
| tree | fe95c8d4b720d4a895e90a13b577a24b93349d35 /examples | |
| parent | 0f1435177b15b739188d08d08563e02e1bf2edde (diff) | |
Add testcase for aborting bulk in with no data queued (and fix aborting bulk in)
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/device/usbtmc/src/usbtmc_app.c | 2 | ||||
| -rw-r--r-- | examples/device/usbtmc/visaQuery.py | 29 |
2 files changed, 28 insertions, 3 deletions
diff --git a/examples/device/usbtmc/src/usbtmc_app.c b/examples/device/usbtmc/src/usbtmc_app.c index ea6e6aa6f..0d03a5ef1 100644 --- a/examples/device/usbtmc/src/usbtmc_app.c +++ b/examples/device/usbtmc/src/usbtmc_app.c @@ -203,7 +203,7 @@ void usbtmc_app_task_iter(void) { if(idnQuery) { - usbtmcd_transmit_dev_msg_data(rhport, idn, tu_min32(sizeof(idn)-1,msgReqLen),false); + usbtmcd_transmit_dev_msg_data(rhport, idn, tu_min32(sizeof(idn)-1,msgReqLen),false); } else { diff --git a/examples/device/usbtmc/visaQuery.py b/examples/device/usbtmc/visaQuery.py index 9610cbc8f..368b66053 100644 --- a/examples/device/usbtmc/visaQuery.py +++ b/examples/device/usbtmc/visaQuery.py @@ -3,6 +3,7 @@ import time import sys + def test_idn(): idn = inst.query("*idn?"); assert idn == "TinyUSB,ModelNumber,SerialNumber,FirmwareVer123456\r\n" @@ -60,6 +61,24 @@ def test_srq(): rsp = inst.read() assert(rsp == "123\r\n") + + +def test_read_timeout(): + inst.timeout = 500 + # First read with no MAV + inst.read_stb() + assert (inst.read_stb() == 0) + inst.write("delay 500") + t0 = time.time() + try: + rsp = inst.read() + assert(false), "Read should have resulted in timeout" + except visa.VisaIOError: + print("Got expected exception") + t = time.time() - t0 + assert ((t*1000.0) > (inst.timeout - 300)) + assert ((t*1000.0) < (inst.timeout + 300)) + print(f"Delay was {t}") rm = visa.ResourceManager("/c/Windows/system32/visa64.dll") reslist = rm.list_resources("USB?::?*::INSTR") @@ -72,8 +91,11 @@ inst = rm.open_resource(reslist[0]); inst.timeout = 3000 inst.clear() -#print("+ IDN") -#test_idn() +print("+ IDN") +test_idn() + +inst.timeout = 3000 + print("+ echo delay=0") inst.write("delay 0") @@ -88,6 +110,9 @@ inst.write("delay 150") test_echo(53,76) test_echo(165,170) +print("+ Read timeout (no MAV") +test_read_timeout() + print("+ MAV") test_mav() |
