-
Notifications
You must be signed in to change notification settings - Fork 1
/
testing_serial.py
67 lines (54 loc) · 1.22 KB
/
testing_serial.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import serial
import config.config as config
from interfaces.rfid import RFIDInterface
import asyncio
s = serial.Serial('/dev/ttyACM0', 9600)
# def test_serial():
# """
# read a line and print.
# """
# text = ""
# msg = s.read().decode()
# while msg != '\n':
# text += msg
# msg = s.read().decode()
# print(text)
# loop.call_soon(s.write, "ok\n".encode())
#
#
# loop = asyncio.get_event_loop()
# loop.add_reader(s, test_serial)
# try:
# loop.run_forever()
# except KeyboardInterrupt:
# pass
# finally:
# loop.close()
# radio_settings = {
# "port": "/dev/ttyUSB3",
# "rate": 9600,
# }
#
# gps_settings = {
# "port": "/dev/ttyUSB0",
# "rate": 9600,
# }
#
# temp_settings = {
# "port": "/dev/ttyACM0",
# "rate": 9600,
# }
db_setting = {
"file": "local_data.db"
}
async def main():
config.set_specific("rfid", "port", "/dev/ttyACM0")
config.set_specific("rfid", "rate", 9600)
config.set_specific("db", "file", "local_data.db")
rfid = RFIDInterface(False)
stopped = await rfid.check_rfid("turb")
print(stopped)
return "all async loops exited"
if __name__ == "__main__":
output = asyncio.run(main())
print(output)