mirror of
https://github.com/jonathanhogg/scopething
synced 2025-07-14 03:02:09 +01:00
Initial test stuff
This commit is contained in:
32
scope.py
Normal file
32
scope.py
Normal file
@ -0,0 +1,32 @@
|
||||
|
||||
import asyncio
|
||||
from streams import SerialStream
|
||||
|
||||
|
||||
class Scope(object):
|
||||
|
||||
def __init__(self, stream=None):
|
||||
if stream is None:
|
||||
stream = SerialStream()
|
||||
self._stream = stream
|
||||
|
||||
async def reset(self):
|
||||
await self._stream.write(b'!')
|
||||
await self._stream.readuntil(b'!')
|
||||
|
||||
async def get_revision(self):
|
||||
await self._stream.write(b'?')
|
||||
assert await self._stream.readuntil(b'\r') == b'?\r'
|
||||
revision = await self._stream.readuntil(b'\r')
|
||||
return revision.decode('ascii').strip()
|
||||
|
||||
|
||||
|
||||
async def main():
|
||||
s = Scope()
|
||||
await s.reset()
|
||||
print(await s.get_revision())
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.get_event_loop().run_until_complete(main())
|
||||
|
Reference in New Issue
Block a user