Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ dependencies = [
[tool.ruff]
# Allow lines to be as long as 119 characters.
line-length = 119
# Ignore errors of unused module imports in __init__.py
ignore-init-module-imports = true

[tool.black]
# Allow lines to be as long as 119 characters.
Expand Down
13 changes: 4 additions & 9 deletions src/elliptec/controller.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""This module contains the Controller class, which is the base class for all devices."""

import sys
import serial
from .tools import parse

Expand All @@ -23,7 +22,8 @@ def __init__(self,
write_timeout=0.5,
debug=True):
self.debug = debug
if port == None:
self.port = port # Store the port parameter as an instance variable
if port is None:
self.__search_and_connect(baudrate,
bytesize,
parity,
Expand Down Expand Up @@ -79,7 +79,8 @@ def __search_and_connect(self,
write_timeout):
port_list = serial.tools.list_ports.comports()
for port in port_list:
self.__connect_to_port(port,
self.port = port
self.__connect_to_port(self.port,
baudrate,
bytesize,
parity,
Expand All @@ -88,12 +89,6 @@ def __search_and_connect(self,
write_timeout)
break

def __enter__(self):
return self

def __exit__(self, exc_type, exc_val, exc_tb):
self.close()

def read_response(self):
"""Reads the response from the controller."""
response = self.s.read_until(b"\r\n") # Waiting until response read
Expand Down