fw version check: FW_VERSION string is case insensitive (parsing RC works)

This commit is contained in:
PavelSindler 2018-02-01 20:23:45 +01:00
parent d92f6292aa
commit 84f7d057f3

View File

@ -86,7 +86,7 @@ inline bool parse_version(const char *str, uint16_t version[4])
version[3] = FIRMWARE_REVISION_ALPHA;
else if (n == strlen_P(STR_REVISION_BETA) && strncmp_P(p, STR_REVISION_BETA, n) == 0)
version[3] = FIRMWARE_REVISION_BETA;
else if ((n == 2 || n == 3) && p[0] == 'r' && p[1] == 'c') {
else if ((n == 2 || n == 3) && (p[0] == 'r' || p[0] == 'R') && (p[1] == 'c' || p[1] == 'C')) {
if (n == 2)
version[3] = FIRMWARE_REVISION_RC;
else {
@ -116,12 +116,22 @@ inline bool parse_version(const char *str, uint16_t version[4])
inline bool strncmp_PP(const char *p1, const char *p2, uint8_t n)
{
for (; n > 0; -- n, ++ p1, ++ p2) {
if (pgm_read_byte(p1) < pgm_read_byte(p2))
return -1;
if (pgm_read_byte(p1) > pgm_read_byte(p2))
return 1;
if (pgm_read_byte(p1) == 0)
return 0;
if (pgm_read_byte(p1) >= 65 && pgm_read_byte(p1) <= 92) //p1 is upper case (p2 is always lowercase)
{
if ((pgm_read_byte(p1)+32) < pgm_read_byte(p2))
return -1;
if ((pgm_read_byte(p1)+32) > pgm_read_byte(p2))
return 1;
}
else if (pgm_read_byte(p1) == 0) {
return 0;
}
else { //p1 is lowercase
if (pgm_read_byte(p1) < pgm_read_byte(p2))
return -1;
if (pgm_read_byte(p1) > pgm_read_byte(p2))
return 1;
}
}
return 0;
}