Novice, please,
How to parse the data from the external device? Use the analog serial port to receive the serial data from the STM32. The data content is FA E0 10 00 67 02 A8 0A 18 19 F3 FF A2 F3 AE 16 25 0E 10 EC AF D1 AD 9B
FA E0 10 00 will never change, but the data of the fifth and sixth bytes will change. How to capture the contents of the two byte positions 67 02? And convert it to a decimal value. (For example, 67 02 is converted, the two bytes need to be exchanged to become 02 67, and the final decimal result is 615)
If you store all those data bytes in a character array, with the 0xFA byte in element zero, then the data of interest can be rearranged as an integer thusly:
@gcjr That is a really neat solution. My only suggestion is
if (sizeof(Hdr) > bufIdx && Hdr [bufIdx] != c) {
bufIdx = 0;
return;
}
Just for interest I tried to do a String version, since Strings can store 0x00, but it turns out that Stream.cpp has a lot of bugs in its methods that prevent it handling char > 0x80
read() is fine, but readBytes(), timedRead, the parse methods and find methods and readString methods all fail on char > 0x80
One of the consequences of this is that readString will not work with UTF-8 input
If anyone wants a corrected version of Stream.cpp it is available from my Taming Arduino Strings tutorial.
Edit -- My mistake, String is fine reading >0x80 and reading UTF-8
On Mega, Uno and some other boards SoftwareSerial is limited to 19200.
I did not read any clear spec about the board you are using, but beware of this.
I have not seen any references of SoftwareSerial working properly on 115200.