1
0
mirror of https://github.com/jonathanhogg/scopething synced 2025-07-14 03:02:09 +01:00
Files
scopething/scope.py
2016-10-11 16:54:56 +01:00

31 lines
673 B
Python

import asyncio
from streams import SerialStream
class Scope(object):
def __init__(self, stream):
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(SerialStream())
await s.reset()
print(await s.get_revision())
if __name__ == '__main__':
asyncio.get_event_loop().run_until_complete(main())