I read serial data using Pyserial to populate a list of 17 values (1 byte each) with a sampling frequency of 256 Hz.
The byte that I ultimately want to use is the fifth to eighth place on the list. Apart from bytes, the first two values of the stream are always the same ('165', '90'). I get quite a few discarded values, and my list values change, so when I read 5-8 bytes, they are not valid values.
I partially fought this, making sure that before the captured request is captured, the first few values are checked for what they should be (that is, if mylist [0] == 165 & ....).
This is rude, but normal, since the probability that these two values appear next to each other in a list in another place is small. The problem is that this means that as soon as the byte shift, I lose the load of values until it rebuilds.
My question is: what code can I use for:
a) Forcibly reinstall the list as soon as it is discovered that it no longer starts at 165.90. (Elif ....).
b) Determine where '165' and '90' are (next to each other) in the list and extract the values that I want in relation to their position (further, but one, further).
Thanks in advance
S_s
Qs,
mylist.append(mylist.pop(0))
, . , ?
user219284