Skip to content

Commit

Permalink
Patch - serial port already in use
Browse files Browse the repository at this point in the history
  • Loading branch information
LatentDream committed Jan 8, 2024
1 parent 2b60d1a commit 3e29f48
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions captain/services/hardware.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import subprocess
from sys import platform
import os
import logging

import cv2
import pyvisa
Expand Down Expand Up @@ -49,6 +50,7 @@ def get_serial_devices(self) -> list[SerialDevice]:

def get_visa_devices(self) -> list[VISADevice]:
"""Returns a list of VISA devices connected to the system."""
logging.info("Get devices")
rm = pyvisa.ResourceManager("@py")
devices = []
used_addrs = set()
Expand All @@ -67,8 +69,9 @@ def get_visa_devices(self) -> list[VISADevice]:
)
device.close()
used_addrs.add(addr)
except pyvisa.VisaIOError:
pass
except (pyvisa.VisaIOError, serial.serialutil.SerialException) as e:
# Warning for PermissionError(13, 'Access is denied.', None, 5) when CAN2USB is already use elsewhere
logging.warning(f"{e}")

return devices

Expand Down

0 comments on commit 3e29f48

Please sign in to comment.