Delta / Mbed OS Delta_CLI

Fork of NNN40_CLI by Delta

Revision:
21:72d7a6e85d7f
Parent:
20:bd1760975052
Child:
24:838a0b25934b
--- a/CLI_Source/command-interpreter.cpp	Wed Oct 19 10:34:28 2016 +0000
+++ b/CLI_Source/command-interpreter.cpp	Thu Oct 20 03:14:33 2016 +0000
@@ -91,12 +91,17 @@
 	
 	return result;
 }
-int cyntecAtoInt(uint8_t *str, uint8_t len)
+int cyntecAtoInt(uint8_t *str)
 {
 	int result = 0;
 	uint8_t i = 0;
+	bool is_negative = false;
 	
-	while( *str != '\0' && i < len)
+	if (*str == '-') {
+		is_negative = true;
+		str++;
+	}
+	while( *str != '\0')
 	{
 		result *= 10;
 		result = result + ( *str - '0' );
@@ -104,7 +109,10 @@
 		i++;
 	}
 	
-	return result;
+	if (is_negative)
+		return -result;
+	else
+		return result;
 }
 uint8_t cyntecArgToUint8(uint8_t *str, uint8_t len)
 {