Sounds like you are making very robust error handling in your application.
Looks like, right now, the only way for you to know the error detail is to look at tail of the KXCILogifile.txt in the C:\S4200\sys\kxci
In KXCI window, be sure to enable logging.
Can your application somehow map that drive location and do some file IO?
From the KXCI command set, you can interrogate the state of a bit in the status byte to know if an error has occurred.
But not aware of any way to query the error detail on this API.
Python sample for interrogating status byte:
import time
import pyvisa
import socket
def main():
rm = pyvisa.ResourceManager()
dev_address = "TCPIP0::192.168.1.43::1225::SOCKET"
my_4200A = rm.open_resource(dev_address)
my_4200A.read_termination = "\0"
my_4200A.write_termination = "\0"
my_4200A.timeout = 1000
# No Error in *IDN?
print("Response to *IDN?: ", my_4200A.query("*IDN?"))
status = my_4200A.query("SP")
# Check bit B1 of status byte for previous command error
if (int(status) & 0x02) != 0: # Check bit B1 of SP response
print("Error Detected. Bit B1 value: ", (int(status) & 0x02))
else:
print("No Error Detected. Bit B1 value: ", (int(status) & 0x02))
# Error in *IDN?
print("Response to *ID?: ", my_4200A.query("*ID?"))
status = my_4200A.query("SP")
# Check bit B1 of status byte for previous command error.
if (int(status) & 0x02) != 0: # Check bit B1 of SP response
print("Error Detected. Bit B1 value: ", (int(status) & 0x02))
else:
print("No Error Detected. Bit B1 value: ", (int(status) & 0x02))
my_4200A.close()
if __name__ == "__main__":
main()