فهرست منبع

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

PavelSindler 6 سال پیش
والد
کامیت
84f7d057f3
1فایلهای تغییر یافته به همراه17 افزوده شده و 7 حذف شده
  1. 17 7
      Firmware/util.cpp

+ 17 - 7
Firmware/util.cpp

@@ -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;
 }