Open pjalocha opened 9 years ago
Could use one of following algorithms:
"Bootloader measures the signal length between rising edge of first 1 bit in 0x7F to the falling edge of the last 1 bit in 0x7F to deduce the baudrate value"
Source: STM32 microcontroller system memory boot mode
First character received by the STM32 boot loader:
0111 1111
← 0x7F
_<------>
First NMEA sentence sended by the GPS
$GPGGA,184155.422,,,,,0,00,,,M,0.0,M,,0000*5E
0010 0100
← 0x24
← $
__<--->__
The pattern to measure could be
0010 0100
← 0x24
← $
0100 0111
← 0x47
← G
0101 0000
← 0x50
← P
0100 0111
← 0x47
← G
0100 0111
← 0x47
← G
0100 0001
← 0x41
← A
0010 0100 0100 0111 0101 0000 0100 0111 0100 0111 0100 0001
// s is the first string received at 115200
switch (s) {
case 'OGN':
baudrate = 115200;
break;
case '`b#':
baudrate = 57600;
break;
case '`sÌrÈ':
baudrate = 38400;
break;
…
}
OGN Tracker Console.
$PSRF150,1*3E
$GPGGA,193512.912,,,,,0,00,,,M,0.0,M,,0000*51
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
b# ¤
á§Çäb!ᧁ§@ó$ ¦æ¥ÆÆÆÄ楄ÆFƆFÆƄ@ó$ ÆÆÆÆÆÆÆæb$ "¥æ¥ÆÁÆÆÆ楅¤ÆfƇEó$ ¦æ¥ÆÆÆÄ楄ÆFƆFÆƄAó$ ÆÆÆÆÆÆÆæb$ "¥æ¥ÆÁ
sÌrÈ=̤ÿàªpbડ¨ábbqrppRpRbàqó¨ᨊurrrrrb¡¨j±Xñ99±+8i(ý¨ábbprppRpRbàqó¨ᨊurrrrrb¡¨j±XGð99±+8i(ýçÁ=ó𱈨ábâq
bavpñaRqprapRàq!rèᨊõâbbbbbrrâqrq⡨j????X0°±\r
uâbññqrÃçÁ{ó∨ábòp
bavpñ¡???
`zFÿþþXR
JBþHJ
JPXþ
HH
þHJJJZþ°yHXBZJRJX
BXJHXJRHX
RüBXXBþ
HJRHX
RüXJ
B
þHBRþXBR
If the GPS don't start with the same string, "simply" use a repeating pattern i.e. ($GPGGA
,æ¥ÆÆÆ
,ább
)
https://github.com/rob42/FreeboardPLC_v1_2/blob/master/Gps.cpp#L89-L148
could be done by switching between several standard rates as long as no valid NMEA frames are detected. Once the NMEA frames start arriving the speed should stay. Algorithm is easy and should achieve correct speed within 10-20 seconds.
It can be very convenient, as one needs not to check eveyr time if the GPS speed matched the configured tracker speed.