开源改变世界!!

“文件”未命名类型 – 编译时出错 #27

推推 grbl 2年前 (2023-02-12) 344次浏览
关闭
PhilippEBZ 打开了这个问题 2020 年 12 月 14 日 · 5 条评论
关闭

“文件”未命名类型 – 编译时出错#27

PhilippEBZ 打开了这个问题 2020 年 12 月 14 日 · 5 条评论

评论

“文件”未命名类型 - 编译时出错 #27
菲利普EBZ 评论了 2020 年 12 月 14 日  

你好,

我尝试用 Arduino 1.8.13 编译项目。起初我没有安装 SdFat 库,但现在我收到此错误并且我不知道如何让它工作。你有什么想法吗?

这是我得到的输出:

谢谢你!!

menu_file.cpp:53:1: error: 'File' does not name a type
 File fileToShow ;   // this contains the file being sent from SD
 ^
C:\TEMP\arduino_build_855381\sketch\menu_file.cpp: In function 'uint16_t fileCnt(uint8_t)':
menu_file.cpp:138:3: error: 'File' was not declared in this scope
   File file ; 
   ^
C:\TEMP\arduino_build_855381\sketch\menu_file.cpp:138:3: note: suggested alternative:
In file included from C:\TEMP\arduino_build_855381\sketch\TFT_eSPI_ms/TFT_eSPI.h:114:0,
                 from C:\TEMP\arduino_build_855381\sketch\config.h:4,
                 from C:\TEMP\arduino_build_855381\sketch\menu_file.cpp:13:
C:\Users\pkleesse\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\FS\src/FS.h:47:7: note:   'fs::File'
 class File : public Stream
       ^
menu_file.cpp:140:11: error: 'file' was not declared in this scope
   while ( file.openNext( &aDir[level] ) ) {
           ^
menu_file.cpp:145:3: error: 'file' was not declared in this scope
   file.close();
   ^
C:\TEMP\arduino_build_855381\sketch\menu_file.cpp: In function 'boolean updateFilesBtn()':
menu_file.cpp:165:3: error: 'File' was not declared in this scope
   File file ;
   ^
C:\TEMP\arduino_build_855381\sketch\menu_file.cpp:165:3: note: suggested alternative:
In file included from C:\TEMP\arduino_build_855381\sketch\TFT_eSPI_ms/TFT_eSPI.h:114:0,
                 from C:\TEMP\arduino_build_855381\sketch\config.h:4,
                 from C:\TEMP\arduino_build_855381\sketch\menu_file.cpp:13:
C:\Users\pkleesse\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\FS\src/FS.h:47:7: note:   'fs::File'
 class File : public Stream
       ^
menu_file.cpp:168:12: error: 'file' was not declared in this scope
     if ( ! file.openNext( &aDir[dirLevel] ) ) {       // ouvre le prochain fichier dans le répertoire courant ; en cas d'erreur, retour à la page info avec un message d'erreur 
            ^
menu_file.cpp:174:5: error: 'file' was not declared in this scope
     file.close() ;
     ^
menu_file.cpp:182:12: error: 'file' was not declared in this scope
     if ( ! file.openNext( &aDir[dirLevel] ) ) {
            ^
menu_file.cpp:189:10: error: 'file' was not declared in this scope
     if ( file.isDir() ) { 
          ^
menu_file.cpp:193:12: error: 'file' was not declared in this scope
     if ( ! file.getName( pfileNames , 21 ) ) {   // Rempli fileNames avec le nom du fichier
            ^
menu_file.cpp:203:5: error: 'file' was not declared in this scope
     file.close() ;
     ^
C:\TEMP\arduino_build_855381\sketch\menu_file.cpp: In function 'boolean setFileToRead(uint8_t)':
menu_file.cpp:257:3: error: 'fileToShow' was not declared in this scope
   fileToShow.close() ;
   ^
C:\TEMP\arduino_build_855381\sketch\menu_file.cpp: In function 'void setShowBuffer()':
menu_file.cpp:376:3: error: 'fileToShow' was not declared in this scope
   fileToShow.seek( sdMillPos ) ; // set the same position for the file used for display
   ^
C:\TEMP\arduino_build_855381\sketch\menu_file.cpp: In function 'void setPrevShowBuffer()':
menu_file.cpp:421:3: error: 'fileToShow' was not declared in this scope
   fileToShow.seek( sdShowBeginPos ) ; // set this position for the file used for display
   ^
C:\TEMP\arduino_build_855381\sketch\menu_file.cpp: In function 'void setNextShowBuffer()':
menu_file.cpp:432:3: error: 'fileToShow' was not declared in this scope
   fileToShow.seek( sdShowBeginPos ) ; // set this position for the file used for display
   ^
browser.cpp:38:1: error: 'File' does not name a type
 File root ; // used for Directory 
 ^
C:\TEMP\arduino_build_855381\sketch\browser.cpp: In function 'void DownloadFile(String)':
browser.cpp:327:7: error: 'File' was not declared in this scope
       File download ;
       ^
C:\TEMP\arduino_build_855381\sketch\browser.cpp:327:7: note: suggested alternative:
In file included from C:\TEMP\arduino_build_855381\sketch\TFT_eSPI_ms/TFT_eSPI.h:114:0,
                 from C:\TEMP\arduino_build_855381\sketch\config.h:4,
                 from C:\TEMP\arduino_build_855381\sketch\browser.cpp:12:
C:\Users\pkleesse\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\FS\src/FS.h:47:7: note:   'fs::File'
 class File : public Stream
       ^
browser.cpp:328:7: error: 'download' was not declared in this scope
       download = sd.open( filename.c_str() );
       ^
C:\TEMP\arduino_build_855381\sketch\browser.cpp: At global scope:
browser.cpp:356:1: error: 'File' does not name a type
 File UploadFile;
 ^
C:\TEMP\arduino_build_855381\sketch\browser.cpp: In function 'void handleFileUpload()':
browser.cpp:366:9: error: 'UploadFile' was not declared in this scope
         UploadFile.close() ;
         ^
browser.cpp:372:12: error: 'UploadFile' was not declared in this scope
         if(UploadFile) { 
            ^
browser.cpp:381:12: error: 'UploadFile' was not declared in this scope
         if(UploadFile && ( errorWhileUploading == false) )          // If the file was successfully created
            ^
C:\TEMP\arduino_build_855381\sketch\browser.cpp: In function 'void sd_dir()':
browser.cpp:403:5: error: 'root' was not declared in this scope
     root.close() ;
     ^
C:\TEMP\arduino_build_855381\sketch\browser.cpp: In function 'void printDirectory(const char*, uint8_t)':
browser.cpp:428:3: error: 'File' was not declared in this scope
   File root1 = sd.open(dirname);
   ^
C:\TEMP\arduino_build_855381\sketch\browser.cpp:428:3: note: suggested alternative:
In file included from C:\TEMP\arduino_build_855381\sketch\TFT_eSPI_ms/TFT_eSPI.h:114:0,
                 from C:\TEMP\arduino_build_855381\sketch\config.h:4,
                 from C:\TEMP\arduino_build_855381\sketch\browser.cpp:12:
C:\Users\pkleesse\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\FS\src/FS.h:47:7: note:   'fs::File'
 class File : public Stream
       ^
browser.cpp:431:7: error: 'root1' was not declared in this scope
   if(!root1){
       ^
browser.cpp:435:7: error: 'root1' was not declared in this scope
   if(!root1.isDir()){
       ^
browser.cpp:439:3: error: 'root1' was not declared in this scope
   root1.rewind();
   ^
browser.cpp:441:8: error: expected ';' before 'file1'
   File file1 ;
        ^
browser.cpp:442:9: error: 'file1' was not declared in this scope
   while(file1.openNext(&root1)){
         ^
browser.cpp:468:3: error: 'file1' was not declared in this scope
   file1.close();
   ^
C:\TEMP\arduino_build_855381\sketch\browser.cpp: In function 'void SD_file_delete(String)':
browser.cpp:482:5: error: 'File' was not declared in this scope
     File dataFile = sd.open( filename.c_str() ); //  
     ^
C:\TEMP\arduino_build_855381\sketch\browser.cpp:482:5: note: suggested alternative:
In file included from C:\TEMP\arduino_build_855381\sketch\TFT_eSPI_ms/TFT_eSPI.h:114:0,
                 from C:\TEMP\arduino_build_855381\sketch\config.h:4,
                 from C:\TEMP\arduino_build_855381\sketch\browser.cpp:12:
C:\Users\pkleesse\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\FS\src/FS.h:47:7: note:   'fs::File'
 class File : public Stream
       ^
browser.cpp:483:9: error: 'dataFile' was not declared in this scope
     if (dataFile) {
         ^
Mehrere Bibliotheken wurden für "WiFi.h" gefunden
 Benutzt: C:\Users\pkleesse\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\WiFi
 Nicht benutzt: C:\Program Files (x86)\Arduino\libraries\WiFi
Bibliothek SPI in Version 1.0 im Ordner: C:\Users\pkleesse\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\SPI  wird verwendet
Bibliothek FS in Version 1.0 im Ordner: C:\Users\pkleesse\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\FS  wird verwendet
Bibliothek SPIFFS in Version 1.0 im Ordner: C:\Users\pkleesse\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\SPIFFS  wird verwendet
Bibliothek Wire in Version 1.0.1 im Ordner: C:\Users\pkleesse\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\Wire  wird verwendet
Bibliothek SdFat in Version 2.0.2 im Ordner: C:\Users\pkleesse\Documents\Arduino\libraries\SdFat  wird verwendet
Bibliothek Preferences in Version 1.0 im Ordner: C:\Users\pkleesse\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\Preferences  wird verwendet
Bibliothek WiFi in Version 1.0 im Ordner: C:\Users\pkleesse\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\WiFi  wird verwendet
Bibliothek WebServer in Version 1.0 im Ordner: C:\Users\pkleesse\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\WebServer  wird verwendet
exit status 1
'File' does not name a type
“文件”未命名类型 - 编译时出错 #27
所有者

我预计 sdfat 库未正确安装。
还要注意您安装的版本(否则您必须对文件进行微小的更改)。
查看这边RS-CNC 32的教程以获得更多详细信息
https://www.makerfr.com/forum/viewtopic.php?f=38&t=6446&start=240

“文件”未命名类型 - 编译时出错 #27

你好!感谢您的快速回复!

你是对的,我没有那个文件,我不知道 Arduino Library Manager 的最新 SdFat Lib 不会工作。

我可以通过 Arduino IDE 成功编译和上传。

我将 SD 卡读卡器连接到 Github 上描述中的引脚,并相应地设置 CS 引脚。我还将wifi设置设置为AP。
因为我没有 TFT,也没有双节棍,只想尝试浏览器界面、sd 卡和串口,所以我评论如下:

  • tftInit()
  • 初始化按钮()
  • nunchuk_init()

在 setup() 例程之外。

不幸的是,ESP32 一次又一次地重启。

是否可以在没有 tft 和 nunchuk 的情况下测试 grbl_controller,或者那是不可能的?

是否可以通过定义来关闭我(可能还有其他人)未使用的那些功能?

总的来说,我真的很喜欢你的项目的想法!!!感谢您的帮助

这是我从终端得到的:

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1216
ho 0 tail 12 room 4
load:0x40078000,len:9720
ho 0 tail 12 room 4
load:0x40080400,len:6352
entry 0x400806b8

using config.h param for WiFi
Wifi config will be executed
Guru Meditation Error: Core  1 panic'ed (InstrFetchProhibited). Exception was unhandled.
Core 1 register dump:
PC      : 0x00000000  PS      : 0x00060630  A0      : 0x800d7921  A1      : 0x3ffb1f70  
A2      : 0x3ffc1edd  A3      : 0x3ffc33c4  A4      : 0x3ffc3a40  A5      : 0x00000000  
A6      : 0x400d2b4c  A7      : 0x0101a8c0  A8      : 0x800d50fa  A9      : 0x3ffc180c  
A10     : 0x00000000  A11     : 0x3f402019  A12     : 0x3ffc33c4  A13     : 0x3ffc33a1  
A14     : 0x3ffb1f4c  A15     : 0x3ffc3c28  SAR     : 0x0000000a  EXCCAUSE: 0x00000014  
EXCVADDR: 0x00000000  LBEG    : 0x400e20b4  LEND    : 0x400e2116  LCOUNT  : 0x00000000  

Backtrace: 0x00000000:0x3ffb1f70 0x400d791e:0x3ffb1f90 0x400e4205:0x3ffb1fb0 0x4008939d:0x3ffb1fd0

Rebooting...
“文件”未命名类型 - 编译时出错 #27
所有者

可以在没有 TFT 的情况下使用 ESP32。
如果只是想测试wifi(以及通过wifi访问SD卡),可以不用修改原固件。
如果您想测试串行传递,您只需更改一行代码。

为此,更改文件 grbl_controller_esp32.ino,在第 124 行当前有:
uint8_t statusPrinting = PRINTING_STOPPED;

您可以将其更改为:
uint8_t statusPrinting = PRINTING_FROM_USB ;

当这个版本刷入 ESP32 时,它会像您在使用 USB 模式打印时手动输入一样工作。
因此,如果您将 ESP32 板连接到 GRBL,您应该能够使用例如 Arduino 串行终端直接从 pc 到 GRBL 进行通信(例如发送 $$ 之类的命令以获取 GRBL 参数)。不要忘记在 115200 波特率上设置 arduino 串行终端的波特率

“文件”未命名类型 - 编译时出错 #27

你好,

我试过了,将 statusPrinting 更改为 PRINTING_FROM_USB 并取消了我上面提到的那些东西,但我只是得到了串行输出:
failed to open calibrate.txt
当我在评论中有这些东西时,打开和关闭了一个我之前定义的名称的 wifi AP,它是一直在重启。我无法访问 AP,因为它每 2 秒就消失一次,但我可以在手机中看到它。现在没有 AP 出现。

所以我再次对 tft_init() 发表评论,现在它成功初始化并打开了 AP!:-)
它还连接到我的运行 GRBL 1.1h 的 Arduino Nano。

不幸的是,连接AP后,我无法访问我在config.h中提供的IP下的网页。
我什至将笔记本电脑中的 Wifi 卡设置为具有固定 IP 的相同地址范围,但它仍然无法连接。

你还有什么想法吗?

问候
菲利普

“文件”未命名类型 - 编译时出错 #27
所有者

它很奇怪。
其他用户告诉我,只需更改原始固件中的一行代码就足够了,没有人报告 calibrate.txt 有问题。我认为这段文字只是提供信息(调试后我可能忘记将其作为评论)。

我发现了 ESP32 重启的两个原因:

  • 没有足够的力量。这个主要是用wifi的时候。它可以在短时间内消耗高达 1A 的电流。如果您通过 USB 为其供电,则您的 PC 可能仅提供 0.5A(如 USB 规范中所指定)。然后使用单独的电源。
  • 编译时板子类型错误导致部分资源使用冲突