MCPcopy Create free account
hub / github.com/ExpressLRS/ExpressLRS / reader

Function reader

src/python/crsf.py:101–126  ·  view source on GitHub ↗
(s: serial.Serial)

Source from the content-addressed store, hash-verified

99
100
101def reader(s: serial.Serial):
102 starting = False
103 count = 0
104 command = bytes()
105 while True:
106 b = s.read()
107 if len(b) != 0:
108 if count:
109 count -= 1
110 if count == 0:
111 if calc_crc8(command) == ord(b):
112 print("resp: " + "".join("%02x " % x for x in command))
113 process(command)
114 else:
115 s.flushInput()
116 else:
117 command += b
118 elif starting:
119 starting = False
120 if ord(b) > 62:
121 s.flushInput()
122 else:
123 count = ord(b)
124 command = bytes()
125 else:
126 starting = True
127
128
129def send(s: serial.Serial, sync: int, line: bytes):

Callers

nothing calls this directly

Calls 3

processFunction · 0.85
calc_crc8Function · 0.70
readMethod · 0.45

Tested by

no test coverage detected