以下Error Message:
File "app.py", line 624, in instrument_ready pickle.dump(visa_values_instruments_to_dump, f) AttributeError: Can't pickle local object 'CDLL.__init__.<locals>._FuncPtr'
可能原因在於DLL相關的東西,無法pickle.
解法:將__init__()中可能包到的DLL,在其它函式再呼叫。
class VisaInstrument(Instrument):
dll_32 = 'C:/Windows/System32/visa32.dll'
def __init__():
...
#將self.rm改成注解
#self.rm = visa.ResourceManager(self.dll_32)
...
...
def open(self):
try:
#self.dev = self.rm.open_resource(self.visa_addr)
import pyvisa as visa # Simon added 20211108
self.dev = visa.ResourceManager(self.dll_32).open_resource(self.visa_addr)
...
except Exception as ex:
return False
else:
return True
沒有留言:
張貼留言