summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkliment <kliment.yanev@gmail.com>2011-09-18 07:05:53 -0700
committerkliment <kliment.yanev@gmail.com>2011-09-18 07:05:53 -0700
commita27649c455c4d13385b32d45bf353ab890da052a (patch)
tree66e54b4511c00d6a0e0339f8b811daf7c9527aac
parent8fa84ce04eda414886cc5b075d7257e49b6f7f0a (diff)
parent3d4980b4f2ebf4ddf165b960dd6226758a30d696 (diff)
Merge pull request #95 from AxTheB/master
simplified string-to-number conversions
-rw-r--r--Sprinter/Sprinter.pde10
1 files changed, 5 insertions, 5 deletions
diff --git a/Sprinter/Sprinter.pde b/Sprinter/Sprinter.pde
index 7e9b3ba..0fa00d3 100644
--- a/Sprinter/Sprinter.pde
+++ b/Sprinter/Sprinter.pde
@@ -408,7 +408,7 @@ inline void get_command()
if(strstr(cmdbuffer[bufindw], "N") != NULL)
{
strchr_pointer = strchr(cmdbuffer[bufindw], 'N');
- gcode_N = (strtol(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL, 10));
+ gcode_N = atol(strchr_pointer+1);
if(gcode_N != gcode_LastN+1 && (strstr(cmdbuffer[bufindw], "M110") == NULL) ) {
Serial.print("Serial Error: Line Number is not Last Line Number+1, Last Line:");
Serial.println(gcode_LastN);
@@ -425,7 +425,7 @@ inline void get_command()
while(cmdbuffer[bufindw][count] != '*') checksum = checksum^cmdbuffer[bufindw][count++];
strchr_pointer = strchr(cmdbuffer[bufindw], '*');
- if( (int)(strtod(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL)) != checksum) {
+ if( atoi(strchr_pointer+1) != checksum) {
Serial.print("Error: checksum mismatch, Last Line:");
Serial.println(gcode_LastN);
FlushSerialRequestResend();
@@ -458,7 +458,7 @@ inline void get_command()
}
if((strstr(cmdbuffer[bufindw], "G") != NULL)){
strchr_pointer = strchr(cmdbuffer[bufindw], 'G');
- switch((int)((strtod(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL)))){
+ switch(atoi(strchr_pointer+1)){
case 0:
case 1:
#ifdef SDSUPPORT
@@ -520,8 +520,8 @@ if(!sdmode || serial_count!=0){
}
-inline float code_value() { return (strtod(&cmdbuffer[bufindr][strchr_pointer - cmdbuffer[bufindr] + 1], NULL)); }
-inline long code_value_long() { return (strtol(&cmdbuffer[bufindr][strchr_pointer - cmdbuffer[bufindr] + 1], NULL, 10)); }
+inline float code_value() { return strtod(strchr_pointer, NULL); }
+inline long code_value_long() { return atol(strchr_pointer); }
inline bool code_seen(char code_string[]) { return (strstr(cmdbuffer[bufindr], code_string) != NULL); } //Return True if the string was found
inline bool code_seen(char code)