Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/build-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: "3.x"
- name: Install pypa/build/pylint/requirements.txt
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: "3.x"
- name: Install pypa/build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-to-test-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: "3.x"
- name: Install pypa/build
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,7 @@ Python 3.11 or higher
- Added getter for underlying serial object in SerialPortConnection

## 0.0.22
- Library specific exception classes
- Library specific exception classes

## 0.0.23
- Added timeout parameters to SerialPortConnection constructor
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "science_mode_4"
version = "0.0.22"
version = "0.0.23"
authors = [
{ name="Marc Hofmann", email="marc-hofmann@gmx.de" },
]
Expand Down
14 changes: 10 additions & 4 deletions src/science_mode_4/utils/serial_port_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,20 @@ def list_science_mode_device_ports() -> list[serial.tools.list_ports_common.List
return filtered_ports


def __init__(self, port: str, error_timeout: int = 3):
self._ser = serial.Serial(timeout = 0)
def __init__(self, port: str, read_timeout_ins_s: float = 0, write_timeout_ins_s: float = 1, error_timeout_in_s: float = 3):
self._ser = serial.Serial(timeout = read_timeout_ins_s, write_timeout=write_timeout_ins_s)
self._ser.port = port
self._error_timeout = error_timeout
self._error_timeout_in_s = error_timeout_in_s

self._last_written_data = bytes()


@property
def internal_serial(self) -> serial.Serial:
"""Getter for internal pySerial object"""
return self._ser


def open(self):
self._ser.open()

Expand Down Expand Up @@ -92,7 +98,7 @@ def _read_intern(self) -> bytes:
except Exception: # pylint:disable=broad-exception-caught
pass

time.sleep(self._error_timeout)
time.sleep(self._error_timeout_in_s)

try:
self.open()
Expand Down