Skip to content

Commit

Permalink
Merge pull request #91 from jancumps/develop
Browse files Browse the repository at this point in the history
merge for release 7.1
  • Loading branch information
jancumps authored Nov 1, 2023
2 parents c5fa279 + 66e1b81 commit 2f596b4
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pico_scpi_usbtmc_lablib
2 changes: 1 addition & 1 deletion source/scpi/scpi-def.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// model
#define SCPI_IDN2 "LABTOOL"
// serial number
#define SCPI_IDN3 NULL
// pico unique id
// version
#define SCPI_IDN4 "01.00"

Expand Down
9 changes: 9 additions & 0 deletions source/scpi/scpi_user_config.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
#ifndef _SCPI_USER_CONFIG_H
#define _SCPI_USER_CONFIG_H

// here you can override the SCPI lib default response terminator
/* set the termination character(s) */
#ifndef SCPI_LINE_ENDING
#define LINE_ENDING_CR "\r" /* use a <CR> carriage return as termination charcter */
#define LINE_ENDING_LF "\n" /* use a <LF> line feed as termination charcter */
#define LINE_ENDING_CRLF "\r\n" /* use <CR><LF> carriage return + line feed as termination charcters */
#define SCPI_LINE_ENDING LINE_ENDING_LF
#endif

// define instrument specific registers
#define USE_CUSTOM_REGISTERS 1

Expand Down
6 changes: 3 additions & 3 deletions source/usb/usb_descriptors.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ char serial[2 * PICO_UNIQUE_BOARD_ID_SIZE_BYTES + 1];
char const* string_desc_arr [] =
{
(const char[]) { 0x09, 0x04 }, // 0: is supported language is English (0x0409)
"TinyUSB", // 1: Manufacturer
"TinyUSB Device", // 2: Product
"element14community", // 1: Manufacturer
"Pico SCPI labTool", // 2: Product
serial, // 3: Serials, uses the flash ID
"TinyUSB USBTMC", // 4: USBTMC
"PST USBTMC", // 4: USBTMC
};

static uint16_t _desc_str[32];
Expand Down
31 changes: 23 additions & 8 deletions test/visaQuery.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_idn():
print(idn)

# check if the IDN string matches the expected pattern. Allow for different serial number
if(re.search("PICO-PI,LABTOOL,\d+,01.00\r\n", idn) != None):
if(re.search("PICO-PI,LABTOOL,([0-9a-fA-F]+),01.00\n", idn) != None):
isPico = (inst.is_4882_compliant)


Expand All @@ -40,9 +40,10 @@ def test_pin(pin):

def handle_event(resource, event, user_handle):
print(f"Handled event {event.event_type} on {resource}")
resource.called = True
stb = inst.read_stb()
print("status read finished")
inst.write("*CLS")
resource.called = True


rm = visa.ResourceManager()
Expand Down Expand Up @@ -70,7 +71,7 @@ def handle_event(resource, event, user_handle):
while j < 3:
test_pin(j)
j += 1
print("SCPI errors during test: "+ inst.query("SYST:ERR:COUNT?"))
print("SCPI errors after test: "+ inst.query("SYST:ERR:COUNT?"))
print("Basis test complete")

print("Service Request test")
Expand All @@ -88,26 +89,40 @@ def handle_event(resource, event, user_handle):
inst.write("*CLS")
inst.write("*SRE 128") #leaving Bit6 MSS - off

print('Done setting up. Drive DIGI:INP0 low (push button connected to GP27)')
maxloops = 500
sleeptime = 0.01
print("Done setting up. Drive DIGI:INP0 low (push button connected to GP27) within {} s".format(sleeptime * maxloops))


try:
while not inst.called:
time.sleep(0.01)
loops = 0
while (not inst.called) and (loops < maxloops):
time.sleep(sleeptime)
loops += 1
if (loops >= maxloops):
print("Service request not called after {} s".format(sleeptime * loops))
except:
inst.close()
# logging.exception("While looping")

try:
print("disabling event")
inst.disable_event(event_type, event_mech)
print("disabled event")
except:
print('err while disabling event')
print("err while disabling event")
try:
print("uninstalling handler")
inst.uninstall_handler(event_type, wrapped, user_handle)
print("uninstalled handler")
except:
print('err while disabling event')
print("err while uninstalling handler")

print("SCPI errors after test: "+ inst.query("SYST:ERR:COUNT?"))
print("Service Request test complete")

inst.close()
i += 1


print("All Test complete")

0 comments on commit 2f596b4

Please sign in to comment.