-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
36 lines (28 loc) · 847 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import ipp
import asyncio
import logging
logger = logging.getLogger(__name__)
async def main():
# host = "localhost"
host = "10.0.0.1"
# port = 50007
port = 1294
client = ipp.Client(host, port)
if not await client.connect():
print("Failed to connect to server.")
async def sendAndWait(ippCommandMethod):
# print("Send and wait: %s" % ippCommandMethod)
tag = await ippCommandMethod()
# print("Command tag %s" % tag)
while True:
msg = await client.handleMessage()
# print("Got msg: %s" % msg)
if ("%05d %%" % (tag)) in msg:
# print("%05d transaction complete" % tag)
break
await sendAndWait(client.startSession)
await sendAndWait(client.getDMEVersion)
await sendAndWait(client.endSession)
print(client.transactions)
if __name__ == "__main__":
asyncio.run(main())