diff options
| author | hathach <[email protected]> | 2023-03-17 23:53:38 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2023-03-17 23:53:38 +0700 |
| commit | bdfcd50b1b601f85389a09cdaf183b2f27c1d470 (patch) | |
| tree | 0ed9312b74a74c875fd17b86353ac02559ac7081 /examples/device/usbtmc | |
| parent | 73f22e31c7a31e9b974e27407b906bbc8cb05a7a (diff) | |
| parent | 65ee11ff630169c01a33860fbf8507d2d8f29a71 (diff) | |
Merge branch 'master' into portability
Diffstat (limited to 'examples/device/usbtmc')
| -rw-r--r-- | examples/device/usbtmc/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | examples/device/usbtmc/Makefile | 1 | ||||
| -rw-r--r-- | examples/device/usbtmc/src/main.c | 2 | ||||
| -rw-r--r-- | examples/device/usbtmc/src/usbtmc_app.c | 12 | ||||
| -rw-r--r-- | examples/device/usbtmc/visaQuery.py | 26 |
5 files changed, 21 insertions, 22 deletions
diff --git a/examples/device/usbtmc/CMakeLists.txt b/examples/device/usbtmc/CMakeLists.txt index c49603c26..b4678dc5e 100644 --- a/examples/device/usbtmc/CMakeLists.txt +++ b/examples/device/usbtmc/CMakeLists.txt @@ -26,4 +26,4 @@ target_include_directories(${PROJECT} PUBLIC # Configure compilation flags and libraries for the example... see the corresponding function # in hw/bsp/FAMILY/family.cmake for details. -family_configure_device_example(${PROJECT})
\ No newline at end of file +family_configure_device_example(${PROJECT}) diff --git a/examples/device/usbtmc/Makefile b/examples/device/usbtmc/Makefile index 69b633fea..da088ea6b 100644 --- a/examples/device/usbtmc/Makefile +++ b/examples/device/usbtmc/Makefile @@ -1,4 +1,3 @@ -include ../../../tools/top.mk include ../../make.mk INC += \ diff --git a/examples/device/usbtmc/src/main.c b/examples/device/usbtmc/src/main.c index 8fc06b56c..2bba336f1 100644 --- a/examples/device/usbtmc/src/main.c +++ b/examples/device/usbtmc/src/main.c @@ -1,4 +1,4 @@ -/* +/* * The MIT License (MIT) * * Copyright (c) 2019 Ha Thach (tinyusb.org) diff --git a/examples/device/usbtmc/src/usbtmc_app.c b/examples/device/usbtmc/src/usbtmc_app.c index 0057a429f..f1596f6d0 100644 --- a/examples/device/usbtmc/src/usbtmc_app.c +++ b/examples/device/usbtmc/src/usbtmc_app.c @@ -23,11 +23,7 @@ * */ -#ifdef __ICCARM__ #include <string.h> -#else -#include <strings.h> -#endif #include <stdlib.h> /* atoi */ #include "tusb.h" #include "bsp/board.h" @@ -144,11 +140,14 @@ bool tud_usbtmc_msg_data_cb(void *data, size_t len, bool transfer_complete) queryState = transfer_complete; idnQuery = 0; - if(transfer_complete && (len >=4) && !strncasecmp("*idn?",data,4)) + if ( transfer_complete && (len >= 4) && + (!strncmp("*idn?", data, 4) || !strncmp("*IDN?", data, 4)) ) { idnQuery = 1; } - if(transfer_complete && !strncasecmp("delay ",data,5)) + + if ( transfer_complete && + (!strncmp("delay ", data, 5) || !strncmp("DELAY ", data, 5)) ) { queryState = 0; int d = atoi((char*)data + 5); @@ -243,6 +242,7 @@ void usbtmc_app_task_iter(void) { break; default: TU_ASSERT(false,); + return; } } diff --git a/examples/device/usbtmc/visaQuery.py b/examples/device/usbtmc/visaQuery.py index c4e5ad2b9..ca65daf97 100644 --- a/examples/device/usbtmc/visaQuery.py +++ b/examples/device/usbtmc/visaQuery.py @@ -36,8 +36,8 @@ def test_trig(): time.sleep(0.3) # SRQ may have some delay assert (inst.read_stb() & 0x40), "SRQ not set after 0.3 seconds" assert (inst.read_stb() == 0) - - + + def test_mav(): inst.write("delay 50") inst.read_stb() # clear STB @@ -45,15 +45,15 @@ def test_mav(): inst.write("123") time.sleep(0.3) assert (inst.read_stb() & 0x10), "MAV not set after 0.5 seconds" - + rsp = inst.read() assert(rsp == "123\r\n") - - + + def test_srq(): assert (inst.read_stb() == 0) inst.write("123") - + #inst.enable_event(pyvisa.constants.VI_EVENT_SERVICE_REQ, pyvisa.constants.VI_QUEUE) #waitrsp = inst.wait_on_event(pyvisa.constants.VI_EVENT_SERVICE_REQ, 5000) #inst.discard_events(pyvisa.constants.VI_EVENT_SERVICE_REQ, pyvisa.constants.VI_QUEUE) @@ -64,7 +64,7 @@ def test_srq(): assert (stb == 0x50),msg assert (inst.read_stb() == 0x10), "SRQ set at second read!" - + rsp = inst.read() assert(rsp == "123\r\n") @@ -110,7 +110,7 @@ def test_abort_in(): inst.timeout = 800 y = inst.read() assert(y == "xxx\r\n") - + def test_indicate(): # perform indicator pulse usb_iface = inst.get_visa_attribute(pyvisa.constants.VI_ATTR_USB_INTFC_NUM) @@ -120,8 +120,8 @@ def test_indicate(): assert(retv == b'\x01') else: assert((retv[1] == pyvisa.constants.StatusCode(0)) and (retv[0] == b'\x01')), f"indicator pulse failed: retv={retv}" - - + + def test_multi_read(): old_chunk_size = inst.chunk_size longstr = "0123456789abcdefghijklmnopqrstuvwxyz" * 10 @@ -133,7 +133,7 @@ def test_multi_read(): y = inst.read() assert (x + "\r\n" == y) #inst.chunk_size = old_chunk_size - + def test_stall_ep0(): usb_iface = inst.get_visa_attribute(pyvisa.constants.VI_ATTR_USB_INTFC_NUM) inst.read_stb() @@ -143,7 +143,7 @@ def test_stall_ep0(): assert(False) except pyvisa.VisaIOError: pass - + assert (inst.read_stb() == 0) @@ -153,7 +153,7 @@ print(reslist) if (len(reslist) == 0): sys.exit() - + inst = rm.open_resource(reslist[0]); inst.timeout = 3000 |
