I need to catch the begining of a data frame via serial (FTDI) in a UWP app (C++/CX).
The beginning of this frame is only determined by a break signal.
By calling the functions LoadAsync / ReadBuffer / ReadBytes from the dataReader in a "kind of loop", like in SerialSample available on the Windows IOT git, I'm able to retrieve the full frame but I can't locate the first byte.
For instance :
What I want : [0] [1] [2] [...] [n-2] [n-1] [n]
What I get : [55] [56] [...] [n-1] [n] [0] [1] [...] [54]
or if I restart the program : [22] [23] [...] [n-1] [n] [0] [1] [...] [21]
The beginning only depends on when I launch the communication. Moreover, the number "n" of byte in the frame isn't known in advance.
I tried to use the PinChanged event to detect the break signal and they are indeed detected, but only during the asynchronous operation "LoadAsync".
After the return of this function, data are loaded and I can't know exactly between which byte the break occurred.
I also tried to load data byte by byte, and then when a break is detected, I consider the beginning of the frame.
Unfortunately, the event is also asynchronous and seems to have a slight delay : I have an offset and this one seems to be always the same during my first "trig".
After having loaded few frames, a random offset appears (and I don't know why...).
Moreover if I want to trigger after N frames, the offset isn't the same as before, so I can't just "fix indices" of my bytes received.
To summarize : Is there a way to know exactly between which bytes a break occurs ?
Thanks.