Skip to content

Commit d5410a4

Browse files
committed
Updated example for new contextmanager syntax
1 parent 88a9c02 commit d5410a4

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

async_gpib/async_gpib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ async def write(self, command: bytes) -> None:
220220
self.__logger.debug("Writing data: %s", command)
221221
await self.__wrapper(self.__device.write, command)
222222

223-
async def read(self, length: int = 512) -> bytes:
223+
async def read(self, length: int = 512, character: str = None) -> bytes:
224224
"""
225225
Read a number of data bytes by calling ibread.
226226

examples/example.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,8 @@
2929

3030

3131
async def main():
32-
try:
32+
async with gpib_device:
3333
print("Controller version:", await gpib_device.version())
34-
finally:
35-
# Disconnect from the GPIB controller. We may safely call disconnect() on a non-connected gpib device, even
36-
# in case of a connection error
37-
await gpib_device.disconnect()
3834

3935
logging.basicConfig(level=logging.DEBUG) # Set to logging.INFO for less verbose output
4036
asyncio.run(main())

0 commit comments

Comments
 (0)