summaryrefslogtreecommitdiff
path: root/Sprinter
diff options
context:
space:
mode:
authorVáclav 'ax' Hůla <axtheb@gmail.com>2011-09-17 19:50:06 +0200
committerVáclav 'ax' Hůla <axtheb@gmail.com>2011-09-17 19:50:06 +0200
commit3991d6c46a8b25bae95c0d84072e2a26f2606699 (patch)
treec8a4cd7eee671f63dc86170ba809801d13957f19 /Sprinter
parent0e91bea8f1b223703248f801733738b39f3d5fd8 (diff)
simplified string-to-number conversions
Diffstat (limited to 'Sprinter')
-rw-r--r--Sprinter/Sprinter.pde10
1 files changed, 5 insertions, 5 deletions
diff --git a/Sprinter/Sprinter.pde b/Sprinter/Sprinter.pde
index a941531..fdd3920 100644
--- a/Sprinter/Sprinter.pde
+++ b/Sprinter/Sprinter.pde
@@ -392,7 +392,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 = atoi(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);
@@ -409,7 +409,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();
@@ -442,7 +442,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
@@ -504,8 +504,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)