Skip to content

Commit

Permalink
fix some typing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
falkoschindler committed Aug 8, 2023
1 parent 9b42e93 commit 6ec04c6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions rosys/hardware/communication/serial_communication.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def __init__(self, baud_rate: int = 115200) -> None:
self.serial = serial.Serial(self.device_path, baud_rate)
self.buffer = ''
self.log_io: bool = False
self.undo_queue = deque(maxlen=100)
self.redo_queue = deque(maxlen=100)
self.undo_queue: deque[str] = deque(maxlen=100)
self.redo_queue: deque[str] = deque(maxlen=100)

@staticmethod
def is_possible() -> bool:
Expand All @@ -43,6 +43,7 @@ def get_device_path() -> Optional[str]:
for device_path in SerialCommunication.search_paths:
if os.path.exists(device_path) and os.stat(device_path).st_gid > 0:
return device_path
return None

def connect(self) -> None:
if not self.serial.isOpen():
Expand All @@ -56,7 +57,7 @@ def disconnect(self) -> None:

async def read(self) -> Optional[str]:
if not self.serial.isOpen():
return
return None
s = self.serial.read_all()
try:
s = s.decode()
Expand All @@ -68,6 +69,7 @@ async def read(self) -> Optional[str]:
return line
except Exception:
self.log.exception(f'Could not decode serial data: {s}')
return None

async def send(self, line: str) -> None:
if not self.serial.isOpen():
Expand Down

0 comments on commit 6ec04c6

Please sign in to comment.