Skip to content

Commit d5df74c

Browse files
authored
Provide the ability to specify the device name at initialization time (#46)
1 parent 64a8ecb commit d5df74c

3 files changed

Lines changed: 19 additions & 3 deletions

File tree

.pylintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ disable=
88
C0114, # missing-module-docstring
99
C0115, # missing-class-docstring
1010
C0116, # missing-function-docstring
11+
R0902, # too-many-instance-attributes
1112
R0904, # too-many-public-methods
1213
R0914, # too-many-locals
1314
R0913, # too-many-arguments -- perhaps we can increase this limit from 5???

HISTORY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# History
22

3+
## 0.11.1 (2025-07-18)
4+
5+
* Provide an ability to define the device name at initialization time.
6+
37
## 0.11.0 (2025-06-14)
48

59
* Try to automatically connect to devices with Manufacturer TeensyToAny. This

teensytoany/teensytoany.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ class TeensyToAny:
2828
(0x16C0, 0x0483),
2929
]
3030

31-
_device_name = "TeensyToAny"
32-
3331
@staticmethod
3432
def find(serial_numbers=None):
3533
"""Find all the serial ports that are associated with debuggers.
@@ -161,7 +159,7 @@ def device_serial_number_pairs(
161159
manufacturer="TeensyToAny",
162160
):
163161
if device_name is None:
164-
device_name = TeensyToAny._device_name
162+
device_name = "TeensyToAny"
165163
com = comports()
166164
pairs = [
167165
(c.device, c.serial_number)
@@ -348,6 +346,7 @@ def __init__(
348346
baudrate=115200,
349347
timeout=0.205,
350348
open=True, # pylint: disable=redefined-builtin
349+
device_name='TeensyToAny',
351350
):
352351
"""A class to control the TeensyToAny Debugger.
353352
@@ -356,11 +355,22 @@ def __init__(
356355
serial_number: optional
357356
If provided, will attempt to open the specified serial number
358357
358+
baudrate: int
359+
Baudrate to use for the serial connection.
360+
359361
timeout: float
360362
Timeout before reading a command fails. A default value of 0.205
361363
was chosen so that the Serial connection adequately waits for
362364
hardware timeouts that may be as long as 0.200 seconds.
363365
366+
open: bool
367+
If True, will automatically open the device upon initialization.
368+
If False, the device must be opened manually using the `open` method.
369+
370+
device_name: str
371+
The name of the device returned during certain error messages.
372+
373+
.. versionadded:: 0.11.1
364374
"""
365375

366376
self._requested_serial_number = serial_number
@@ -369,6 +379,7 @@ def __init__(
369379
self._serial = None
370380
self.serial_number = None
371381
self._version = None
382+
self._device_name = device_name
372383
if open:
373384
self.open()
374385

0 commit comments

Comments
 (0)