DmitryG 0 19 февраля, 2017 Опубликовано 19 февраля, 2017 (изменено) · Жалоба Здравствуйте! Проект: Организация сервера на базе Stm32f4. Добавил в проект HTML файл. Обновил с помощью программы makefsdata файл fsdata.c. Удалил устаревший fsdata.c. Однако, Отладчик ругается, что HTML файлы, загружаемые в память микроконтроллера, инициализированы одновременно в двух файлах. (Error: L6200E: Symbol file__index_html multiply defined (by fs.o and fsdata.o)) Файл fs.c Код #include "lwip/opt.h" #include "lwip/def.h" #include "fs.h" #include "fsdata.h" #include <string.h> /** Set this to 1 to include "fsdata_custom.c" instead of "fsdata.c" for the * file system (to prevent changing the file included in CVS) */ #ifndef HTTPD_USE_CUSTUM_FSDATA #define HTTPD_USE_CUSTUM_FSDATA 0 #endif #if HTTPD_USE_CUSTUM_FSDATA #include "fsdata_custom.c" #else /* HTTPD_USE_CUSTUM_FSDATA */ #include "fsdata.c" #endif /* HTTPD_USE_CUSTUM_FSDATA */ /*-----------------------------------------------------------------------------------*/ /* Define the number of open files that we can support. */ #ifndef LWIP_MAX_OPEN_FILES #define LWIP_MAX_OPEN_FILES 10 #endif /* Define the file system memory allocation structure. */ struct fs_table { struct fs_file file; u8_t inuse; }; /* Allocate file system memory */ struct fs_table fs_memory[LWIP_MAX_OPEN_FILES]; #if LWIP_HTTPD_CUSTOM_FILES int fs_open_custom(struct fs_file *file, const char *name); void fs_close_custom(struct fs_file *file); #endif /* LWIP_HTTPD_CUSTOM_FILES */ /*-----------------------------------------------------------------------------------*/ static struct fs_file * fs_malloc(void) { int i; for(i = 0; i < LWIP_MAX_OPEN_FILES; i++) { if(fs_memory[i].inuse == 0) { fs_memory[i].inuse = 1; return(&fs_memory[i].file); } } return(NULL); } /*-----------------------------------------------------------------------------------*/ static void fs_free(struct fs_file *file) { int i; for(i = 0; i < LWIP_MAX_OPEN_FILES; i++) { if(&fs_memory[i].file == file) { fs_memory[i].inuse = 0; break; } } return; } /*-----------------------------------------------------------------------------------*/ struct fs_file * fs_open(const char *name) { struct fs_file *file; const struct fsdata_file *f; file = fs_malloc(); if(file == NULL) { return NULL; } #if LWIP_HTTPD_CUSTOM_FILES if(fs_open_custom(file, name)) { file->is_custom_file = 1; return file; } file->is_custom_file = 0; #endif /* LWIP_HTTPD_CUSTOM_FILES */ for(f = FS_ROOT; f != NULL; f = f->next) { if (!strcmp(name, (char *)f->name)) { file->data = (const char *)f->data; file->len = f->len; file->index = f->len; file->pextension = NULL; file->http_header_included = f->http_header_included; #if HTTPD_PRECALCULATED_CHECKSUM file->chksum_count = f->chksum_count; file->chksum = f->chksum; #endif /* HTTPD_PRECALCULATED_CHECKSUM */ #if LWIP_HTTPD_FILE_STATE file->state = fs_state_init(file, name); #endif /* #if LWIP_HTTPD_FILE_STATE */ return file; } } fs_free(file); return NULL; } /*-----------------------------------------------------------------------------------*/ void fs_close(struct fs_file *file) { #if LWIP_HTTPD_CUSTOM_FILES if (file->is_custom_file) { fs_close_custom(file); } #endif /* LWIP_HTTPD_CUSTOM_FILES */ #if LWIP_HTTPD_FILE_STATE fs_state_free(file, file->state); #endif /* #if LWIP_HTTPD_FILE_STATE */ fs_free(file); } /*-----------------------------------------------------------------------------------*/ int fs_read(struct fs_file *file, char *buffer, int count) { int read; if(file->index == file->len) { return -1; } read = file->len - file->index; if(read > count) { read = count; } MEMCPY(buffer, (file->data + file->index), read); file->index += read; return(read); } /*-----------------------------------------------------------------------------------*/ int fs_bytes_left(struct fs_file *file) { return file->len - file->index; } Файл fsdata.c Код #include "fs.h" #include "lwip/def.h" #include "fsdata.h" #define file_NULL (struct fsdata_file *) NULL static const unsigned int dummy_align__index_html = 0; static const unsigned char data__index_html[] = { /* /index.html (12 chars) */ 0x2f,0x69,0x6e,0x64,0x65,0x78,0x2e,0x68,0x74,0x6d,0x6c,0x00, /* HTTP header */ /* "HTTP/1.0 200 OK " (17 bytes) */ 0x48,0x54,0x54,0x50,0x2f,0x31,0x2e,0x30,0x20,0x32,0x30,0x30,0x20,0x4f,0x4b,0x0d, 0x0a, /* "Server: lwIP/1.3.1 (http://savannah.nongnu.org/projects/lwip) " (63 bytes) */ 0x53,0x65,0x72,0x76,0x65,0x72,0x3a,0x20,0x6c,0x77,0x49,0x50,0x2f,0x31,0x2e,0x33, 0x2e,0x31,0x20,0x28,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x73,0x61,0x76,0x61,0x6e, 0x6e,0x61,0x68,0x2e,0x6e,0x6f,0x6e,0x67,0x6e,0x75,0x2e,0x6f,0x72,0x67,0x2f,0x70, 0x72,0x6f,0x6a,0x65,0x63,0x74,0x73,0x2f,0x6c,0x77,0x69,0x70,0x29,0x0d,0x0a, /* "Content-type: text/html " (27 bytes) */ 0x43,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x74,0x79,0x70,0x65,0x3a,0x20,0x74,0x65, 0x78,0x74,0x2f,0x68,0x74,0x6d,0x6c,0x0d,0x0a,0x0d,0x0a, /* raw file data (569 bytes) */ 0x3c,0x21,0x44,0x4f,0x43,0x54,0x59,0x50,0x45,0x20,0x48,0x54,0x4d,0x4c,0x20,0x50, 0x55,0x42,0x4c,0x49,0x43,0x20,0x22,0x2d,0x2f,0x2f,0x57,0x33,0x43,0x2f,0x2f,0x44, 0x54,0x44,0x20,0x48,0x54,0x4d,0x4c,0x20,0x34,0x2e,0x30,0x31,0x20,0x54,0x72,0x61, 0x6e,0x73,0x69,0x74,0x69,0x6f,0x6e,0x61,0x6c,0x2f,0x2f,0x45,0x4e,0x22,0x3e,0x0d, 0x0a,0x3c,0x68,0x74,0x6d,0x6c,0x20,0x78,0x6d,0x6c,0x6e,0x73,0x3a,0x76,0x3d,0x22, 0x75,0x72,0x6e,0x3a,0x73,0x63,0x68,0x65,0x6d,0x61,0x73,0x2d,0x6d,0x69,0x63,0x72, 0x6f,0x73,0x6f,0x66,0x74,0x2d,0x63,0x6f,0x6d,0x3a,0x76,0x6d,0x6c,0x22,0x20,0x78, 0x6d,0x6c,0x6e,0x73,0x3a,0x6f,0x3d,0x22,0x75,0x72,0x6e,0x3a,0x73,0x63,0x68,0x65, 0x6d,0x61,0x73,0x2d,0x6d,0x69,0x63,0x72,0x6f,0x73,0x6f,0x66,0x74,0x2d,0x63,0x6f, 0x6d,0x3a,0x6f,0x66,0x66,0x69,0x63,0x65,0x3a,0x6f,0x66,0x66,0x69,0x63,0x65,0x22, 0x20,0x78,0x6d,0x6c,0x6e,0x73,0x3a,0x77,0x3d,0x22,0x75,0x72,0x6e,0x3a,0x73,0x63, 0x68,0x65,0x6d,0x61,0x73,0x2d,0x6d,0x69,0x63,0x72,0x6f,0x73,0x6f,0x66,0x74,0x2d, 0x63,0x6f,0x6d,0x3a,0x6f,0x66,0x66,0x69,0x63,0x65,0x3a,0x77,0x6f,0x72,0x64,0x22, 0x20,0x78,0x6d,0x6c,0x6e,0x73,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77, 0x77,0x77,0x2e,0x77,0x33,0x2e,0x6f,0x72,0x67,0x2f,0x54,0x52,0x2f,0x52,0x45,0x43, 0x2d,0x68,0x74,0x6d,0x6c,0x34,0x30,0x22,0x3e,0x3c,0x68,0x65,0x61,0x64,0x3e,0x0d, 0x0a,0x3c,0x6d,0x65,0x74,0x61,0x20,0x68,0x74,0x74,0x70,0x2d,0x65,0x71,0x75,0x69, 0x76,0x3d,0x22,0x43,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x54,0x79,0x70,0x65,0x22, 0x20,0x63,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x3d,0x22,0x74,0x65,0x78,0x74,0x2f,0x68, 0x74,0x6d,0x6c,0x3b,0x20,0x63,0x68,0x61,0x72,0x73,0x65,0x74,0x3d,0x69,0x73,0x6f, 0x2d,0x38,0x38,0x35,0x39,0x2d,0x31,0x22,0x3e,0x0d,0x0a,0x3c,0x6c,0x69,0x6e,0x6b, 0x20,0x72,0x65,0x6c,0x3d,0x22,0x46,0x69,0x6c,0x65,0x2d,0x4c,0x69,0x73,0x74,0x22, 0x20,0x68,0x72,0x65,0x66,0x3d,0x22,0x53,0x54,0x4d,0x33,0x32,0x46,0x34,0x78,0x37, 0x5f,0x66,0x69,0x6c,0x65,0x73,0x2f,0x66,0x69,0x6c,0x65,0x6c,0x69,0x73,0x74,0x2e, 0x78,0x6d,0x6c,0x22,0x3e,0x0d,0x0a,0x3c,0x6c,0x69,0x6e,0x6b,0x20,0x72,0x65,0x6c, 0x3d,0x22,0x45,0x64,0x69,0x74,0x2d,0x54,0x69,0x6d,0x65,0x2d,0x44,0x61,0x74,0x61, 0x22,0x20,0x68,0x72,0x65,0x66,0x3d,0x22,0x53,0x54,0x4d,0x33,0x32,0x46,0x34,0x78, 0x37,0x5f,0x66,0x69,0x6c,0x65,0x73,0x2f,0x65,0x64,0x69,0x74,0x64,0x61,0x74,0x61, 0x2e,0x6d,0x73,0x6f,0x22,0x3e,0x3c,0x74,0x69,0x74,0x6c,0x65,0x3e,0x53,0x54,0x4d, 0x33,0x32,0x46,0x34,0x78,0x37,0x3c,0x2f,0x74,0x69,0x74,0x6c,0x65,0x3e,0x3c,0x2f, 0x68,0x65,0x61,0x64,0x3e,0x0d,0x0a,0x3c,0x62,0x6f,0x64,0x79,0x20,0x73,0x74,0x79, 0x6c,0x65,0x3d,0x22,0x22,0x20,0x6c,0x61,0x6e,0x67,0x3d,0x22,0x45,0x4e,0x2d,0x55, 0x53,0x22,0x20,0x6c,0x69,0x6e,0x6b,0x3d,0x22,0x62,0x6c,0x75,0x65,0x22,0x20,0x76, 0x6c,0x69,0x6e,0x6b,0x3d,0x22,0x62,0x6c,0x75,0x65,0x22,0x3e,0x0d,0x0a,0x48,0x65, 0x6c,0x6c,0x6f,0x20,0x77,0x6f,0x72,0x6c,0x64,0x0d,0x0a,0x3c,0x2f,0x62,0x6f,0x64, 0x79,0x3e,0x3c,0x2f,0x68,0x74,0x6d,0x6c,0x3e,}; const struct fsdata_file file__index_html[] = { { file_NULL, data__index_html, data__index_html + 12, sizeof(data__index_html) - 12, 1, }}; #define FS_ROOT file__index_html #define FS_NUMFILES 1 Примечательно, что подобные операции в оригинальном проекте от ST стабильно работают. Подскажите, пожалуйста, что не так? Изменено 19 февраля, 2017 пользователем IgorKossak [codebox] для длинного кода, [code] - для короткого! Цитата Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты Поделиться
ig_z 0 19 февраля, 2017 Опубликовано 19 февраля, 2017 · Жалоба 3.Удалить из проекта fsdata.c 2.Научиться правильно именовать свои темы 1.Изучать свой проект и язык 0. Задавать подобные вопросы в песочнице Примечательно, что подобные операции в оригинальном проекте от ST стабильно работают. Какие операции? Цитата Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты Поделиться