Skip to content

Commit b6da97c

Browse files
committed
fix GPIB transport casting to SCPIDevice
1 parent 18630e3 commit b6da97c

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/scpi/scpi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def error_available(self) -> int:
140140
class SCPIProtocol:
141141
"""Implements the SCPI protocol talks over the given transport"""
142142

143-
transport: BaseTransport = field()
143+
transport: Union[BaseTransport, GPIBDeviceTransport, GPIBTransport] = field()
144144
lock: asyncio.Lock = field(default_factory=asyncio.Lock)
145145
_checking_error: bool = field(default=False)
146146

@@ -249,7 +249,7 @@ def __post_init__(self) -> None:
249249
protocol: Optional[SCPIProtocol] = None
250250
if isinstance(self.instancefrom, SCPIProtocol):
251251
protocol = self.instancefrom
252-
if isinstance(self.instancefrom, BaseTransport):
252+
if isinstance(self.instancefrom, (BaseTransport, GPIBDeviceTransport, GPIBTransport)):
253253
protocol = SCPIProtocol(self.instancefrom)
254254
if isinstance(self.instancefrom, SCPIDevice):
255255
protocol = self.instancefrom.protocol

src/scpi/transports/gpib/base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ async def send_loc(self) -> None:
5959
await self._set_ll_address()
6060
await self.lltransport.send_loc()
6161

62+
async def quit(self) -> None:
63+
"""Nop for devices"""
64+
LOGGER.debug("quit should not be called on device level but we must have the method for type compatibility")
65+
6266

6367
class GPIBTransport(BaseTransport, ABC):
6468
"""Baseclass for GPIB transports"""

src/scpi/transports/gpib/prologix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ async def scan_devices(self) -> Sequence[Tuple[int, str]]:
159159
found_addresses: List[int] = []
160160
# We do not lock on this level since the commands we use need to manipulate the lock
161161
prev_addr = await self.query_address()
162-
prev_read_tmo_ms = await self.send_and_read("++read_tmo_ms")
162+
prev_read_tmo_ms = int(await self.send_and_read("++read_tmo_ms"))
163163
new_read_tmo_ms = int((SCAN_DEVICE_TIMEOUT / 2) * 1000)
164164
self._serialhandler.protocol.write_line(f"++read_tmo_ms {new_read_tmo_ms:d}")
165165
for addr in range(0, 31): # 0-30 inclusive

0 commit comments

Comments
 (0)