Exopy / exopy_hqc_legacy

Transition package to smooth transition from HQCMeas to Exopy.
BSD 3-Clause "New" or "Revised" License
0 stars 9 forks source link

Tiny bilt #54

Closed tcubaynes closed 5 years ago

tcubaynes commented 5 years ago

The travis test was not ok in the previous version (see the last commit). This version of the code works with the two types of modules we have, so there is no need to review it again.

lcontami commented 5 years ago

The tinybilt driver really should be put on master. Since I didn't work of the sp device card and didn't edit the driver tools reload (was it buggy ??) I don't know if the changes made were necessary so I will move them to the second pull request I created with all the random stuff that was on the free computer.

I left the hard coded path for the sp device card for now.

lcontami commented 5 years ago

@MatthieuDartiailh I hope you don't regret giving me admin privilege ;)

MatthieuDartiailh commented 5 years ago

You cleaned up before merging so it sounds good. Sorry to not have more time for exopy.

lcontami commented 5 years ago

I'll just leave this here for future me:

So on the current version of the branch master the Tinybilt driver does not work. Not clear to me what changed to cause it to break. Reverting to commit "TinyBilt: Improve resilience to connection losses" seems to work.

ERROR: The following unhandled exception occured in Vg3 :
Traceback (most recent call last):
File "c:\users\hqc\documents\tino\exopy_hqc_legacy\exopy_hqc_legacy\instruments\drivers\driver_tools.py", line 126, in wrapper
return method(self, *args, **kwargs)
File "c:\users\hqc\documents\tino\exopy_hqc_legacy\exopy_hqc_legacy\instruments\drivers\visa\tinybuilt.py", line 205, in voltage
outp_val = self._TB.ask_for_values(self._header + 'Volt?')[0]
File "c:\users\hqc\documents\tino\exopy_hqc_legacy\exopy_hqc_legacy\instruments\drivers\visa_tools.py", line 174, in ask_for_values
return self._driver.ask_for_values(message, format)
File "C:\Anaconda3\envs\TinyBilt\lib\site-packages\pyvisa-1.9.0-py3.6.egg\pyvisa\resources\messagebased.py", line 668, in ask_for_values
self.write(message)
File "C:\Anaconda3\envs\TinyBilt\lib\site-packages\pyvisa-1.9.0-py3.6.egg\pyvisa\resources\messagebased.py", line 223, in write
count = self.write_raw(message.encode(enco))
File "C:\Anaconda3\envs\TinyBilt\lib\site-packages\pyvisa-1.9.0-py3.6.egg\pyvisa\resources\messagebased.py", line 201, in write_raw
return self.visalib.write(self.session, message)
File "C:\Anaconda3\envs\TinyBilt\lib\site-packages\pyvisa-1.9.0-py3.6.egg\pyvisa\ctwrapper\functions.py", line 1866, in write
ret = library.viWrite(session, data, len(data), byref(return_count))
File "C:\Anaconda3\envs\TinyBilt\lib\site-packages\pyvisa-1.9.0-py3.6.egg\pyvisa\ctwrapper\highlevel.py", line 188, in _return_handler
raise errors.VisaIOError(ret_value)
pyvisa.errors.VisaIOError: VI_ERROR_TMO (-1073807339): Timeout expired before operation completed.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\users\hqc\documents\tino\exopy\exopy\tasks\tasks\decorators.py", line 105, in decorator
return function_to_decorate(*args, **kwargs)
File "c:\users\hqc\documents\tino\exopy\exopy\tasks\tasks\task_interface.py", line 84, in perform
return self.interface.perform(*args, **kwargs)
File "c:\users\hqc\documents\tino\exopy_hqc_legacy\exopy_hqc_legacy\tasks\tasks\instr\dc_tasks.py", line 142, in perform
current_value = getattr(self.channel_driver, 'voltage')
File "c:\users\hqc\documents\tino\exopy_hqc_legacy\exopy_hqc_legacy\instruments\drivers\driver_tools.py", line 86, in __get__
return super(instrument_property, self).__get__(obj, objtype)
File "c:\users\hqc\documents\tino\exopy_hqc_legacy\exopy_hqc_legacy\instruments\drivers\driver_tools.py", line 137, in wrapper
self.reopen_connection()
File "c:\users\hqc\documents\tino\exopy_hqc_legacy\exopy_hqc_legacy\instruments\drivers\visa\tinybuilt.py", line 45, in reopen_connection
self._TB.reopen_connection()
File "c:\users\hqc\documents\tino\exopy_hqc_legacy\exopy_hqc_legacy\instruments\drivers\visa_tools.py", line 119, in reopen_connection
para = {'timeout': self._driver.timeout,
File "C:\Anaconda3\envs\TinyBilt\lib\site-packages\pyvisa-1.9.0-py3.6.egg\pyvisa\resources\resource.py", line 160, in timeout
timeout = self.get_visa_attribute(constants.VI_ATTR_TMO_VALUE)
File "C:\Anaconda3\envs\TinyBilt\lib\site-packages\pyvisa-1.9.0-py3.6.egg\pyvisa\resources\resource.py", line 263, in get_visa_attribute
return self.visalib.get_attribute(self.session, name)[0]
File "C:\Anaconda3\envs\TinyBilt\lib\site-packages\pyvisa-1.9.0-py3.6.egg\pyvisa\ctwrapper\functions.py", line 530, in get_attribute
ret = library.viGetAttribute(session, attribute, byref(attribute_state))
File "C:\Anaconda3\envs\TinyBilt\lib\site-packages\pyvisa-1.9.0-py3.6.egg\pyvisa\ctwrapper\highlevel.py", line 188, in _return_handler
raise errors.VisaIOError(ret_value)
pyvisa.errors.VisaIOError: VI_ERROR_INV_OBJECT (-1073807346): The given session or object reference is invalid.
Iterating connection 0/2 for instrument TinyBiltChannel
ERROR: The following unhandled exception occured in Vg1 :
Traceback (most recent call last):
File "c:\users\hqc\documents\tino\exopy_hqc_legacy\exopy_hqc_legacy\instruments\drivers\driver_tools.py", line 126, in wrapper
return method(self, *args, **kwargs)
File "c:\users\hqc\documents\tino\exopy_hqc_legacy\exopy_hqc_legacy\instruments\drivers\visa\tinybuilt.py", line 205, in voltage
outp_val = self._TB.ask_for_values(self._header + 'Volt?')[0]
File "c:\users\hqc\documents\tino\exopy_hqc_legacy\exopy_hqc_legacy\instruments\drivers\visa_tools.py", line 174, in ask_for_values
return self._driver.ask_for_values(message, format)
File "C:\Anaconda3\envs\TinyBilt\lib\site-packages\pyvisa-1.9.0-py3.6.egg\pyvisa\resources\messagebased.py", line 668, in ask_for_values
self.write(message)
File "C:\Anaconda3\envs\TinyBilt\lib\site-packages\pyvisa-1.9.0-py3.6.egg\pyvisa\resources\messagebased.py", line 223, in write
count = self.write_raw(message.encode(enco))
File "C:\Anaconda3\envs\TinyBilt\lib\site-packages\pyvisa-1.9.0-py3.6.egg\pyvisa\resources\messagebased.py", line 201, in write_raw
return self.visalib.write(self.session, message)
File "C:\Anaconda3\envs\TinyBilt\lib\site-packages\pyvisa-1.9.0-py3.6.egg\pyvisa\ctwrapper\functions.py", line 1866, in write
ret = library.viWrite(session, data, len(data), byref(return_count))
File "C:\Anaconda3\envs\TinyBilt\lib\site-packages\pyvisa-1.9.0-py3.6.egg\pyvisa\ctwrapper\highlevel.py", line 188, in _return_handler
raise errors.VisaIOError(ret_value)
pyvisa.errors.VisaIOError: VI_ERROR_INV_OBJECT (-1073807346): The given session or object reference is invalid.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\users\hqc\documents\tino\exopy\exopy\tasks\tasks\decorators.py", line 105, in decorator
return function_to_decorate(*args, **kwargs)
File "c:\users\hqc\documents\tino\exopy\exopy\tasks\tasks\task_interface.py", line 84, in perform
return self.interface.perform(*args, **kwargs)
File "c:\users\hqc\documents\tino\exopy_hqc_legacy\exopy_hqc_legacy\tasks\tasks\instr\dc_tasks.py", line 142, in perform
current_value = getattr(self.channel_driver, 'voltage')
File "c:\users\hqc\documents\tino\exopy_hqc_legacy\exopy_hqc_legacy\instruments\drivers\driver_tools.py", line 86, in __get__
return super(instrument_property, self).__get__(obj, objtype)
File "c:\users\hqc\documents\tino\exopy_hqc_legacy\exopy_hqc_legacy\instruments\drivers\driver_tools.py", line 137, in wrapper
self.reopen_connection()
File "c:\users\hqc\documents\tino\exopy_hqc_legacy\exopy_hqc_legacy\instruments\drivers\visa\tinybuilt.py", line 45, in reopen_connection
self._TB.reopen_connection()
File "c:\users\hqc\documents\tino\exopy_hqc_legacy\exopy_hqc_legacy\instruments\drivers\visa_tools.py", line 119, in reopen_connection
para = {'timeout': self._driver.timeout,
File "C:\Anaconda3\envs\TinyBilt\lib\site-packages\pyvisa-1.9.0-py3.6.egg\pyvisa\resources\resource.py", line 160, in timeout
timeout = self.get_visa_attribute(constants.VI_ATTR_TMO_VALUE)
File "C:\Anaconda3\envs\TinyBilt\lib\site-packages\pyvisa-1.9.0-py3.6.egg\pyvisa\resources\resource.py", line 263, in get_visa_attribute
return self.visalib.get_attribute(self.session, name)[0]
File "C:\Anaconda3\envs\TinyBilt\lib\site-packages\pyvisa-1.9.0-py3.6.egg\pyvisa\resources\resource.py", line 100, in session
raise errors.InvalidSession()
pyvisa.errors.InvalidSession: Invalid session handle. The resource might be closed.
MatthieuDartiailh commented 5 years ago

WOW this is one is weird !

lcontami commented 5 years ago

I think it has to do with how the instrument accepts multiple queries at the same time ? For a measurement with only one output queried it does not fail.

MatthieuDartiailh commented 5 years ago

In general you should have a lock around access to the visa resource to avoid accessing it from multiple for the same instrument otherwise you can interrupt the queries which is a very bad idea. I will try to have a look at the driver and see if I can suggest changes to make it safer.

lcontami commented 5 years ago

Update : I was wrong in my diagnostic, actually what makes the measurement fail is when a tinybilt task was renamed in the measurement editor. So reverting didnt help. Although it did change something, the measurement that failed before reverting then worked, and I did not run into the error again until I tried renaming a task in a new measurement...

MatthieuDartiailh commented 5 years ago

Can you be more specific about the renamed task ? How does it relate to the Tiny ?

lcontami commented 5 years ago

I must admit I'm still not completely clear about the source of the error. For now what I noticed is that :

When I get this error, I can get the measurement to run by renaming all the tinybilt tasks to a different name.

If I change the names of the tinybilt task, it can cause this error (I must admit I was renaming task 1 task 2 and task 2 task 1)

I think it is not 100% reproducible : I also had one measurement failing to this error while the previous one did not fail (the only change was me incrementing the id and changing a few values)

I will try to see if I can find the simplest task that causes this error.

Oh and also the traceback is not always the same, I will try and put the second version.

MatthieuDartiailh commented 5 years ago

Indeed I will need more data to crack this one down ! Thanks for taking the time to investigate.