edmundsj / scippy

SCPI device library for python
MIT License
4 stars 0 forks source link

Error when trying to connect to COM1 using pyvisa-py on windows computer #3

Open edmundsj opened 3 years ago

edmundsj commented 3 years ago

C:\Users\Jordan>python Python 3.9.4 (tags/v3.9.4:1f2e308, Apr 4 2021, 13:27:16) [MSC v.1928 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

from scippy import Keithley keith = Keithley() Attempting connection to ASRL1::INSTR... Communication timeout error. Attempting to reconnect to device ASRL1::INSTR Attempting connection to ASRL1::INSTR... Traceback (most recent call last): File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\scippy\source\SCPIDevice.py", line 101, in get_visa_device device_name_actual = self.identify() File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\scippy\source\SCPIDevice.py", line 220, in identify return self.read_line() File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\scippy\source\SCPIDevice.py", line 176, in read_line return self.device.read() File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\pyvisa\resources\messagebased.py", line 486, in read message = self._read_raw().decode(enco) File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\pyvisa\resources\messagebased.py", line 442, in _read_raw chunk, status = self.visalib.read(self.session, size) File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\pyvisa_py\highlevel.py", line 519, in read return data, self.handle_return_value(session, status_code) File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\pyvisa\highlevel.py", line 251, in handle_return_value raise errors.VisaIOError(rv) 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 "", line 1, in File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\scippy\source\Keithley2400.py", line 24, in init super().init( File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\scippy\source\SCPIDevice.py", line 23, in init self.get_visa_device(device_name=device_name, File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\scippy\source\SCPIDevice.py", line 124, in get_visa_device self.get_visa_device( File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\scippy\source\SCPIDevice.py", line 92, in get_visa_device self.device = rm.open_resource( File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\pyvisa\highlevel.py", line 3304, in open_resource res.open(access_mode, open_timeout) File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\pyvisa\resources\resource.py", line 297, in open self.session, status = self._resource_manager.open_bare_resource( File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\pyvisa\highlevel.py", line 3232, in open_bare_resource return self.visalib.open(self.session, resource_name, access_mode, open_timeout) File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\pyvisa_py\highlevel.py", line 167, in open sess = cls(session, resource_name, parsed, open_timeout) File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\pyvisa_py\sessions.py", line 323, in init self.after_parsing() File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\pyvisa_py\serial.py", line 89, in after_parsing self.interface = cls( File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\serial\serialwin32.py", line 33, in init super(Serial, self).init(*args, **kwargs) File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\serial\serialutil.py", line 244, in init self.open() File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\serial\serialwin32.py", line 64, in open raise SerialException("could not open port {!r}: {!r}".format(self.portstr, ctypes.WinError())) serial.serialutil.SerialException: could not open port 'COM1': PermissionError(13, 'Access is denied.', None, 5)

edmundsj commented 3 years ago

I suspect this is due to the thing not being closed properly, because I definitely did that, I got it to work after closing all the other windows that might still be opening the port. This error type appears to be windows-specific and should be added to the exception handler.