Browse Source

More MKS UI sprintf

Scott Lahteine 4 years ago
parent
commit
4e314ef6d4
1 changed files with 21 additions and 21 deletions
  1. 21
    21
      Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp

+ 21
- 21
Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp View File

478
 
478
 
479
 typedef struct {
479
 typedef struct {
480
   int write_index;
480
   int write_index;
481
-  uint8_t saveFileName[30];
481
+  char saveFileName[30];
482
   uint8_t fileTransfer;
482
   uint8_t fileTransfer;
483
   uint32_t fileLen;
483
   uint32_t fileLen;
484
   uint32_t tick_begin;
484
   uint32_t tick_begin;
593
 }
593
 }
594
 
594
 
595
 static void wifi_gcode_exec(uint8_t *cmd_line) {
595
 static void wifi_gcode_exec(uint8_t *cmd_line) {
596
-  int8_t tempBuf[100] = { 0 };
596
+  char tempBuf[100] = { 0 };
597
   uint8_t *tmpStr = 0;
597
   uint8_t *tmpStr = 0;
598
   int  cmd_value;
598
   int  cmd_value;
599
   volatile int print_rate;
599
   volatile int print_rate;
631
             while (tmpStr[index] == ' ') index++;
631
             while (tmpStr[index] == ' ') index++;
632
 
632
 
633
             if (gCfgItems.wifi_type == ESP_WIFI) {
633
             if (gCfgItems.wifi_type == ESP_WIFI) {
634
-              char *path = (char *)tempBuf;
634
+              char *path = tempBuf;
635
 
635
 
636
               if (strlen((char *)&tmpStr[index]) < 80) {
636
               if (strlen((char *)&tmpStr[index]) < 80) {
637
                 send_to_wifi((uint8_t *)"Begin file list\r\n", strlen("Begin file list\r\n"));
637
                 send_to_wifi((uint8_t *)"Begin file list\r\n", strlen("Begin file list\r\n"));
828
           if ((uiCfg.print_state == WORKING) || (uiCfg.print_state == PAUSED)|| (uiCfg.print_state == REPRINTING)) {
828
           if ((uiCfg.print_state == WORKING) || (uiCfg.print_state == PAUSED)|| (uiCfg.print_state == REPRINTING)) {
829
             print_rate = uiCfg.totalSend;
829
             print_rate = uiCfg.totalSend;
830
             ZERO(tempBuf);
830
             ZERO(tempBuf);
831
-            sprintf_P((char *)tempBuf, PSTR("M27 %d\r\n"), print_rate);
832
-            send_to_wifi((uint8_t *)tempBuf, strlen((char *)tempBuf));
831
+            sprintf_P(tempBuf, PSTR("M27 %d\r\n"), print_rate);
832
+            send_to_wifi((uint8_t *)tempBuf, strlen(tempBuf));
833
           }
833
           }
834
           break;
834
           break;
835
 
835
 
841
             while (tmpStr[index] == ' ') index++;
841
             while (tmpStr[index] == ' ') index++;
842
 
842
 
843
             if (strstr_P((char *)&tmpStr[index], PSTR(".g")) || strstr_P((char *)&tmpStr[index], PSTR(".G"))) {
843
             if (strstr_P((char *)&tmpStr[index], PSTR(".g")) || strstr_P((char *)&tmpStr[index], PSTR(".G"))) {
844
-              strcpy((char *)file_writer.saveFileName, (char *)&tmpStr[index]);
844
+              strcpy(file_writer.saveFileName, (char *)&tmpStr[index]);
845
 
845
 
846
               if (gCfgItems.fileSysType == FILE_SYS_SD) {
846
               if (gCfgItems.fileSysType == FILE_SYS_SD) {
847
                 ZERO(tempBuf);
847
                 ZERO(tempBuf);
848
-                sprintf_P((char *)tempBuf, PSTR("%s"), file_writer.saveFileName);
848
+                sprintf_P(tempBuf, PSTR("%s"), file_writer.saveFileName);
849
               }
849
               }
850
               else if (gCfgItems.fileSysType == FILE_SYS_USB) {
850
               else if (gCfgItems.fileSysType == FILE_SYS_USB) {
851
                 ZERO(tempBuf);
851
                 ZERO(tempBuf);
852
-                sprintf_P((char *)tempBuf, PSTR("%s"), (char *)file_writer.saveFileName);
852
+                sprintf_P(tempBuf, PSTR("%s"), file_writer.saveFileName);
853
               }
853
               }
854
               mount_file_sys(gCfgItems.fileSysType);
854
               mount_file_sys(gCfgItems.fileSysType);
855
 
855
 
858
                 card.openFileWrite(cur_name);
858
                 card.openFileWrite(cur_name);
859
                 if (card.isFileOpen()) {
859
                 if (card.isFileOpen()) {
860
                   ZERO(file_writer.saveFileName);
860
                   ZERO(file_writer.saveFileName);
861
-                  strcpy((char *)file_writer.saveFileName, (char *)&tmpStr[index]);
861
+                  strcpy(file_writer.saveFileName, (char *)&tmpStr[index]);
862
                   ZERO(tempBuf);
862
                   ZERO(tempBuf);
863
-                  sprintf_P((char *)tempBuf, PSTR("Writing to file: %s\r\n"), (char *)file_writer.saveFileName);
863
+                  sprintf_P(tempBuf, PSTR("Writing to file: %s\r\n"), file_writer.saveFileName);
864
                   wifi_ret_ack();
864
                   wifi_ret_ack();
865
-                  send_to_wifi((uint8_t *)tempBuf, strlen((char *)tempBuf));
865
+                  send_to_wifi((uint8_t *)tempBuf, strlen(tempBuf));
866
                   wifi_link_state = WIFI_WAIT_TRANS_START;
866
                   wifi_link_state = WIFI_WAIT_TRANS_START;
867
                 }
867
                 }
868
                 else {
868
                 else {
882
 
882
 
883
             SEND_OK_TO_WIFI;
883
             SEND_OK_TO_WIFI;
884
 
884
 
885
-            char *outBuf = (char *)tempBuf;
885
+            char *outBuf = tempBuf;
886
             char tbuf[34];
886
             char tbuf[34];
887
 
887
 
888
             sprintf_P(tbuf, PSTR("%d /%d"), (int)thermalManager.degHotend(0), (int)thermalManager.degTargetHotend(0));
888
             sprintf_P(tbuf, PSTR("%d /%d"), (int)thermalManager.degHotend(0), (int)thermalManager.degTargetHotend(0));
917
             strcat_P(outBuf, PSTR(" @:0 B@:0\r\n"));
917
             strcat_P(outBuf, PSTR(" @:0 B@:0\r\n"));
918
           }
918
           }
919
           else {
919
           else {
920
-            sprintf_P((char *)tempBuf, PSTR("T:%d /%d B:%d /%d T0:%d /%d T1:%d /%d @:0 B@:0\r\n"),
920
+            sprintf_P(tempBuf, PSTR("T:%d /%d B:%d /%d T0:%d /%d T1:%d /%d @:0 B@:0\r\n"),
921
               thermalManager.degHotend(0), thermalManager.degTargetHotend(0),
921
               thermalManager.degHotend(0), thermalManager.degTargetHotend(0),
922
               #if HAS_HEATED_BED
922
               #if HAS_HEATED_BED
923
                 thermalManager.degBed(), thermalManager.degTargetBed(),
923
                 thermalManager.degBed(), thermalManager.degTargetBed(),
933
             );
933
             );
934
           }
934
           }
935
 
935
 
936
-          send_to_wifi((uint8_t *)tempBuf, strlen((char *)tempBuf));
936
+          send_to_wifi((uint8_t *)tempBuf, strlen(tempBuf));
937
           queue.enqueue_one_P(PSTR("M105"));
937
           queue.enqueue_one_P(PSTR("M105"));
938
           break;
938
           break;
939
 
939
 
940
         case 992:
940
         case 992:
941
           if ((uiCfg.print_state == WORKING) || (uiCfg.print_state == PAUSED)) {
941
           if ((uiCfg.print_state == WORKING) || (uiCfg.print_state == PAUSED)) {
942
             ZERO(tempBuf);
942
             ZERO(tempBuf);
943
-            sprintf_P((char *)tempBuf, PSTR("M992 %d%d:%d%d:%d%d\r\n"), print_time.hours/10, print_time.hours%10, print_time.minutes/10, print_time.minutes%10, print_time.seconds/10, print_time.seconds%10);
943
+            sprintf_P(tempBuf, PSTR("M992 %d%d:%d%d:%d%d\r\n"), print_time.hours/10, print_time.hours%10, print_time.minutes/10, print_time.minutes%10, print_time.seconds/10, print_time.seconds%10);
944
             wifi_ret_ack();
944
             wifi_ret_ack();
945
-            send_to_wifi((uint8_t *)tempBuf, strlen((char *)tempBuf));
945
+            send_to_wifi((uint8_t *)tempBuf, strlen(tempBuf));
946
           }
946
           }
947
           break;
947
           break;
948
 
948
 
950
           if ((uiCfg.print_state == WORKING) || (uiCfg.print_state == PAUSED)) {
950
           if ((uiCfg.print_state == WORKING) || (uiCfg.print_state == PAUSED)) {
951
             ZERO(tempBuf);
951
             ZERO(tempBuf);
952
             if (strlen((char *)list_file.file_name[sel_id]) > (100 - 1)) return;
952
             if (strlen((char *)list_file.file_name[sel_id]) > (100 - 1)) return;
953
-            sprintf_P((char *)tempBuf, PSTR("M994 %s;%d\n"), list_file.file_name[sel_id], (int)gCfgItems.curFilesize);
953
+            sprintf_P(tempBuf, PSTR("M994 %s;%d\n"), list_file.file_name[sel_id], (int)gCfgItems.curFilesize);
954
             wifi_ret_ack();
954
             wifi_ret_ack();
955
-            send_to_wifi((uint8_t *)tempBuf, strlen((char *)tempBuf));
955
+            send_to_wifi((uint8_t *)tempBuf, strlen(tempBuf));
956
           }
956
           }
957
           break;
957
           break;
958
 
958
 
1279
 
1279
 
1280
   ZERO(public_buf);
1280
   ZERO(public_buf);
1281
 
1281
 
1282
-  if (strlen((const char *)file_writer.saveFileName) > sizeof(saveFilePath))
1282
+  if (strlen(file_writer.saveFileName) > sizeof(saveFilePath))
1283
     return;
1283
     return;
1284
 
1284
 
1285
   ZERO(saveFilePath);
1285
   ZERO(saveFilePath);
1303
 
1303
 
1304
   #if ENABLED(SDSUPPORT)
1304
   #if ENABLED(SDSUPPORT)
1305
 
1305
 
1306
-    uint8_t dosName[FILENAME_LENGTH];
1306
+    char dosName[FILENAME_LENGTH];
1307
 
1307
 
1308
-    if (!longName2DosName((const char *)file_writer.saveFileName,dosName)) {
1308
+    if (!longName2DosName(file_writer.saveFileName, dosName)) {
1309
       clear_cur_ui();
1309
       clear_cur_ui();
1310
       upload_result = 2;
1310
       upload_result = 2;
1311
       wifiTransError.flag = 1;
1311
       wifiTransError.flag = 1;

Loading…
Cancel
Save