mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-04 13:17:50 +02:00
Improve board initialization
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
import re
|
||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
import serial
|
import serial
|
||||||
@@ -61,11 +62,12 @@ class SerialDaemon:
|
|||||||
|
|
||||||
async def return_board(self):
|
async def return_board(self):
|
||||||
"""Return the board signature"""
|
"""Return the board signature"""
|
||||||
self.__read_serial() # drain the serial buffer on startup
|
line = ""
|
||||||
|
# drain the serial until we are ready to go
|
||||||
self.__write_serial(b"<s>")
|
self.__write_serial(b"<s>")
|
||||||
time.sleep(0.5)
|
while "DCC-EX" not in line:
|
||||||
board = self.__read_serial().decode().split("\n")[1] # get second line
|
line = self.__read_serial().decode()
|
||||||
|
board = re.findall(r"<iDCC-EX.*>", line)[0]
|
||||||
return(board)
|
return(board)
|
||||||
|
|
||||||
|
|
||||||
@@ -88,8 +90,8 @@ async def main():
|
|||||||
config["Serial"]["Baudrate"],
|
config["Serial"]["Baudrate"],
|
||||||
config["Serial"]["Timeout"]))
|
config["Serial"]["Timeout"]))
|
||||||
logging.warning("Initializing board")
|
logging.warning("Initializing board")
|
||||||
logging.warning(
|
logging.warning("Board {} ready".format(
|
||||||
await sd.return_board())
|
await sd.return_board()))
|
||||||
|
|
||||||
async with server:
|
async with server:
|
||||||
await server.serve_forever()
|
await server.serve_forever()
|
||||||
|
Reference in New Issue
Block a user