Skip to content

Commit 5abd56c

Browse files
fix: Attempt to grab the ip_address for all connection types (#471)
* fix: Attempt to get an ip_address even if USBTMC is the connection type * chore: Changelog update * chore: move changelog entry to more appropriate section
1 parent acbc879 commit 5abd56c

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Things to be included in the next release go here.
2525
### Changed
2626

2727
- Updated the `PIControl.query_binary()` method to include PyVISA-compatible arguments, enabling users to fully utilize the complete functionality of the PyVISA method.
28+
- Updated the `Device.ip_address` property to remove the USB connection type exclusion.
2829

2930
### Fixed
3031

src/tm_devices/drivers/device.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,10 @@ def hostname(self) -> str:
255255
@cached_property
256256
def ip_address(self) -> str:
257257
"""Return the IPv4 address of the device or an empty string if unable to fetch that."""
258-
if self._config_entry.connection_type not in {ConnectionTypes.USB}:
259-
try:
260-
return socket.gethostbyname(self.address)
261-
except (socket.gaierror, socket.herror):
262-
pass
258+
try:
259+
return socket.gethostbyname(self.address)
260+
except (socket.gaierror, socket.herror):
261+
pass
263262
return ""
264263

265264
################################################################################################

0 commit comments

Comments
 (0)