Skip to content

Commit

Permalink
Merge pull request #8 from empkins/7-implement-board-connection-for-m…
Browse files Browse the repository at this point in the history
…acos

7 implement board connection for macos
  • Loading branch information
a-mosquito authored Oct 12, 2023
2 parents b865624 + 528371b commit 5435f55
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion empkins_sync_board_gui/start_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

if __name__ == "__main__":
# switch to mock mode to test without a board here
start_gui(mock_mode=True)
start_gui(mock_mode=False)
8 changes: 7 additions & 1 deletion empkins_sync_board_gui/utils/board_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ def setup(self, progress: QProgressBar):
try:
self._port = self._get_port_from_list(BoardConnector._get_port_list(), progress)
self._ser = Serial(self._port, timeout=self._timeout)
except BoardConnectionError as e:
raise BoardConnectionError(e.message) from e
except (OSError, SerialException) as e:
raise BoardConnectionError("No suitable device found!") from e
else:
Expand Down Expand Up @@ -139,6 +141,10 @@ def _get_port_list() -> List[str]:
import glob

ports = glob.glob("/dev/tty[A-Za-z]*")
elif sys.platform.startswith("darwin"):
import glob

ports = glob.glob("/dev/tty*")
else:
raise BoardConnectionError(f"Sorry, your OS {sys.platform} is currently not supported!")
return ports
Expand Down Expand Up @@ -167,7 +173,7 @@ def _get_port_from_list(self, port_list: List[str], progress: QProgressBar) -> s
def send_command(self, cmd: bytes):
"""Send a command to the board."""
print(f"Sending: {cmd}")
if not self._mock:
if not self._mock and self._ser:
self._ser.flush()
self._ser.write(bytearray(cmd))

Expand Down
4 changes: 2 additions & 2 deletions empkins_sync_board_gui/windows/main_window.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Main Window of the GUI."""

import sys
from datetime import datetime
from pathlib import Path
from time import sleep
Expand Down Expand Up @@ -173,7 +173,7 @@ def connector_setup(self):
msg.setIcon(QMessageBox.Warning)
ret = msg.exec_()
if ret:
self.close()
sys.exit(1)

def init_start_stop_source(self):
"""Set initial start and stop source for board."""
Expand Down

0 comments on commit 5435f55

Please sign in to comment.