Reading Gcode in LocalFiileSystem and encodeing int array. but this program has bug.probably

Fork of MakeSequencer by yuki sato

Revision:
3:09ee560a3007
Parent:
2:4fc4593498d7
Child:
4:1d7c50f17687
diff -r 4fc4593498d7 -r 09ee560a3007 MakeSequencer.cpp
--- a/MakeSequencer.cpp	Thu Oct 11 11:07:31 2018 +0000
+++ b/MakeSequencer.cpp	Thu Oct 11 11:23:53 2018 +0000
@@ -61,8 +61,7 @@
 
 bool MakeSequencer::ReadGcode()
 {
-    int _ele = 0;
-    
+    _ele = 0;
     for(int i = 0;fgets(_buf,sizeof(_buf), _fp) != NULL;i++)
     {
         _codesize = i;
@@ -71,12 +70,8 @@
             return false;
         else
         {
-            int    _tempnum[ARRAY_EREMENT];
             string _tempstr[ARRAY_EREMENT];
-            char   _element[ARRAY_EREMENT][CODE_LENGTH];
-            char   _char;
-            int    _count = -1;
-            bool   _check[ARRAY_EREMENT][CODE_LENGTH];
+            _count = -1;
             
             for(int n = 0;n < ARRAY_EREMENT;n++)
             {
@@ -122,19 +117,10 @@
             for(int n = 0;n < _ele;n++)
             {
                 _tempnum[n] = atoi(_tempstr[n].c_str());
-                
-                if(i != 0 && _check[n][i] && _element[n][i] != _element[n][0])
-                {
-                    //printf("{%d}-{%d},",n,i);
-                    _data[n][i] = _data[n][i-1];
-                }
-                else
-                {
-                    _data[n][i] = _tempnum[n];
-                }        
-                printf("%c:%d ",_element[n][0],_data[n][i]);    
+                _data[n][i] = (i != 0 && _check[n][i] && _element[n][i] != _element[n][0])
+                            ? _data[n][i-1]
+                            : _tempnum[n];
             }
-            printf("\n\r");
         }
     }
     return true;