![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Modularizando o src
Dependencies: EALib EthernetInterface_vz mbed-rtos mbed
Fork of header_main_colinas_V0-20-09-14 by
Diff: file_system_manager.cpp
- Revision:
- 121:ee02790d00b7
- Parent:
- 119:ee6a53069455
- Child:
- 122:480c44b0e205
--- a/file_system_manager.cpp Mon May 04 17:25:29 2015 +0000 +++ b/file_system_manager.cpp Fri May 08 04:15:23 2015 +0000 @@ -2,7 +2,10 @@ QSPIFileSystem qspifs("qspi"); -void set_ip( const char * new_header_ip ){ +char file_buffer [ FILE_BUFFER_SIZE ]; + +void set_ip ( const char * new_header_ip ) +{ FILE * fip = fopen("/qspi/myip.txt", "w"); if ( fip ) { @@ -11,7 +14,42 @@ } } -void set_header_ext( const int new_header_ext ){ +int get_ip ( char * header_ip, const size_t length ) +{ + FILE * fip = fopen("/qspi/myip.txt", "r"); + if ( fip != NULL ) + { + int read = fread ( header_ip, 1, length, fip ); + if( read > 0 ) + { + for ( register int i = 0; i < read; i++ ) + { + if( header_ip [ i ] == '\n' || header_ip [ i ] == '\r' ) + { + header_ip [ i ] = '\0'; + break; + } + } + + if ( debug_file ) debug_msg ("Eth ip %s", header_ip ); + } else { + return ( -3 ); + } + + header_ip [ length ] = 0; + + fclose ( fip ); + + return ( read ); + } + + if ( debug_file ) debug_msg ("Failed to open /qspi/myip.txt" ); + + return ( -1 ); +} + +void set_header_ext ( const int new_header_ext ) +{ FILE * fext = fopen( "/qspi/myext.txt", "w" ); if ( fext ) { @@ -20,7 +58,8 @@ } } -void set_header_sip_port( const int new_header_sip_port ){ +void set_header_sip_port ( const int new_header_sip_port ) +{ FILE * fport = fopen("/qspi/mysipport.txt", "w"); if ( fport ) { @@ -29,7 +68,8 @@ } } -void set_server_ip( const char * new_server_ip ){ +void set_server_ip ( const char * new_server_ip ) +{ FILE * fsip = fopen("/qspi/serverip.txt", "w"); if ( fsip ) { @@ -38,7 +78,8 @@ } } -void set_server_ext( const int new_server_ext ){ +void set_server_ext ( const int new_server_ext ) +{ FILE * fserext = fopen("/qspi/peerext.txt", "w"); if ( fserext ) { @@ -47,7 +88,8 @@ } } -void set_server_port( const int new_server_port ){ +void set_server_port ( const int new_server_port ) +{ FILE * fsport = fopen("/qspi/serverport.txt", "w"); if ( fsport ) { @@ -56,7 +98,8 @@ } } -void set_mask( const char * new_mask ){ +void set_mask ( const char * new_mask ) +{ FILE * fmask = fopen("/qspi/mymask.txt", "w"); if ( fmask ) { @@ -65,7 +108,8 @@ } } -void set_gateway( const char * new_gateway ){ +void set_gateway ( const char * new_gateway ) +{ //fgate = fopen("/qspi/mygateway.txt", "w"); FILE * fgate = fopen("/qspi/mygateway.txt", "w"); if ( fgate ) @@ -75,7 +119,8 @@ } } -void set_udp_port_listener( const int new_udp_port_listener ){ +void set_udp_port_listener ( const int new_udp_port_listener ) +{ FILE * fudpport = fopen( "/qspi/udpport.txt", "w" ); if ( fudpport ) { @@ -84,7 +129,8 @@ } } -void set_tcp_port_listener( const int new_tcp_port_listener ){ +void set_tcp_port_listener ( const int new_tcp_port_listener ) +{ FILE * ftcpport = fopen( "/qspi/tcpport.txt", "w" ); if ( ftcpport ) { @@ -93,7 +139,8 @@ } } -void set_fw_ip( const char * new_fw_ip ){ +void set_fw_ip ( const char * new_fw_ip ) +{ FILE * ffwip = fopen("/qspi/fw_ip.txt", "w" ); if ( ffwip ) { @@ -102,7 +149,8 @@ } } -void set_fw_port( const int new_fw_port ){ +void set_fw_port ( const int new_fw_port ) +{ FILE * ffwport = fopen("/qspi/fw_port.txt", "w" ); if ( ffwport ) { @@ -111,7 +159,8 @@ } } -void set_max_ext( const int new_max_ext ){ +void set_max_ext ( const int new_max_ext ) +{ FILE * fmex = fopen( "/qspi/maxext.txt", "w" ); if ( fmex ){ fprintf( fmex, "%i\n\r", new_max_ext ); @@ -119,7 +168,8 @@ } } -void set_min_ext( const int new_min_ext ){ +void set_min_ext ( const int new_min_ext ) +{ FILE * fmin = fopen( "/qspi/minext.txt", "w" ); if ( fmin ){ fprintf( fmin, "%i\n\r", new_min_ext ); @@ -128,7 +178,8 @@ } // Print the content of a given file -void cat( const char * fname ){ +void cat ( const char * fname ) +{ char buff[513]; int num; @@ -152,7 +203,8 @@ fclose(fp); } -void set_shift_port( const int new_shift_port ){ +void set_shift_port( const int new_shift_port ) +{ FILE * shift_port = fopen("/qspi/shift_port.txt", "w" ); if( shift_port ) { @@ -164,4 +216,561 @@ { if( debug_file ) debug_msg("Cannot open /qspi/shift_port.txt"); } +} + +void files( const char type ) +{ + FILE *fip = NULL; + FILE *fmask = NULL; + FILE *fgate = NULL; + FILE *fport = NULL; + FILE *fsip = NULL; + FILE *fsport = NULL; + FILE *fext = NULL; + FILE *fserext = NULL; + FILE *fudpport = NULL; + FILE *ftcpport = NULL; + FILE *ffwip = NULL; + FILE *ffwport = NULL; + FILE *fmax = NULL; + FILE *fmin = NULL; + FILE *fshift_port = NULL; + + // show files + if ( type == 's' ) { + + if( debug_uart3 && !( from_eth ) ) pc.printf("Header IP " ); + if( from_eth ) { + snprintf( file_buffer, FILE_BUFFER_SIZE, "Header IP " ); + if( tcp_session && !udp_query ) while( !( tcp_client.send_all( file_buffer, strlen( file_buffer ) ) ) ); + + else if( udp_query ) { + udp_query_send_msg( file_buffer ); + } + } + + cat ("/qspi/myip.txt"); + + if( debug_uart3 && !( from_eth ) ) pc.printf("Header ext "); + if( from_eth ) { + snprintf( file_buffer, FILE_BUFFER_SIZE, "Header ext " ); + if( tcp_session && !udp_query ) while( !( tcp_client.send_all( file_buffer, strlen( file_buffer ) ) ) ); + + else if( udp_query ) { + udp_query_send_msg( file_buffer ); + } + } + + cat("/qspi/myext.txt"); + + if( debug_uart3 && !( from_eth ) ) pc.printf("Header port "); + if( from_eth ) { + snprintf( file_buffer, FILE_BUFFER_SIZE, "Header port " ); + if( tcp_session && !udp_query ) while( !( tcp_client.send_all( file_buffer, strlen( file_buffer ) ) ) ); + + else if( udp_query ) { + udp_query_send_msg( file_buffer ); + } + } + + cat("/qspi/mysipport.txt"); + + if( debug_uart3 && !( from_eth ) ) pc.printf("Server IP "); + if( from_eth ) { + snprintf( file_buffer, FILE_BUFFER_SIZE, "Server IP " ); + if( tcp_session && !udp_query ) while( !( tcp_client.send_all( file_buffer, strlen( file_buffer ) ) ) ); + + else if( udp_query ) { + udp_query_send_msg( file_buffer ); + } + } + + cat("/qspi/serverip.txt"); + + if( debug_uart3 && !( from_eth ) ) pc.printf("Server ext "); + if( from_eth ) { + snprintf( file_buffer, FILE_BUFFER_SIZE, "Server ext " ); + if( tcp_session && !udp_query ) while( !( tcp_client.send_all( file_buffer, strlen( file_buffer ) ) ) ); + + else if( udp_query ) { + udp_query_send_msg( file_buffer ); + } + } + + cat("/qspi/peerext.txt"); + + if( debug_uart3 && !( from_eth ) ) pc.printf("Server port "); + if( from_eth ) { + snprintf( file_buffer, FILE_BUFFER_SIZE, "Server port " ); + if( tcp_session && !udp_query ) while( !( tcp_client.send_all( file_buffer, strlen( file_buffer ) ) ) ); + + else if( udp_query ) { + udp_query_send_msg( file_buffer ); + } + } + cat("/qspi/serverport.txt"); + + if( debug_uart3 && !( from_eth ) ) pc.printf("Mascara de rede "); + if( from_eth ) { + snprintf( file_buffer, FILE_BUFFER_SIZE, "Mascara de rede " ); + if( tcp_session && !udp_query ) while( !( tcp_client.send_all( file_buffer, strlen( file_buffer ) ) ) ); + + else if( udp_query ) { + udp_query_send_msg( file_buffer ); + } + } + cat("/qspi/mymask.txt"); + + if( debug_uart3 && !( from_eth ) ) pc.printf("Gateway IP "); + if( from_eth ) { + snprintf( file_buffer, FILE_BUFFER_SIZE, "Gateway IP " ); + if( tcp_session && !udp_query ) while( !( tcp_client.send_all( file_buffer, strlen( file_buffer ) ) ) ); + + else if( udp_query ) { + udp_query_send_msg( file_buffer ); + } + } + cat("/qspi/mygateway.txt"); + + if( debug_uart3 && !( from_eth ) ) pc.printf("UDP Port "); + if( from_eth ) { + snprintf( file_buffer, FILE_BUFFER_SIZE, "UDP Port " ); + if( tcp_session && !udp_query ) while( !( tcp_client.send_all( file_buffer, strlen( file_buffer ) ) ) ); + + else if( udp_query ) { + udp_query_send_msg( file_buffer ); + } + } + + cat("/qspi/udpport.txt"); + + if( debug_uart3 && !( from_eth ) ) pc.printf("TCP Port "); + if( from_eth ) { + snprintf( file_buffer, FILE_BUFFER_SIZE, "TCP Port " ); + if( tcp_session && !udp_query ) while( !( tcp_client.send_all( file_buffer, strlen( file_buffer ) ) ) ); + + else if( udp_query ) { + udp_query_send_msg( file_buffer ); + } + } + + cat("/qspi/tcpport.txt"); + + if( debug_uart3 && !( from_eth ) ) pc.printf("FW Server IP "); + if( from_eth ) { + snprintf( file_buffer, FILE_BUFFER_SIZE, "FW Server IP " ); + if( tcp_session && !udp_query ) while( !( tcp_client.send_all( file_buffer, strlen( file_buffer ) ) ) ); + + else if( udp_query ) { + udp_query_send_msg( file_buffer ); + } + } + + cat("/qspi/fw_ip.txt"); + + if( debug_uart3 && !( from_eth ) ) pc.printf("FW Server Port "); + if( from_eth ) { + snprintf( file_buffer, FILE_BUFFER_SIZE, "FW Server Port " ); + if( tcp_session && !udp_query ) while( !( tcp_client.send_all( file_buffer, strlen( file_buffer ) ) ) ); + + else if( udp_query ) { + udp_query_send_msg( file_buffer ); + } + } + + cat("/qspi/fw_port.txt"); + + if( debug_uart3 && !( from_eth ) ) pc.printf("Max Ext "); + if( from_eth ) { + snprintf( file_buffer, FILE_BUFFER_SIZE, "Max Ext " ); + if( tcp_session && !udp_query ) while( !( tcp_client.send_all( file_buffer, strlen( file_buffer ) ) ) ); + + else if( udp_query ) { + udp_query_send_msg( file_buffer ); + } + } + + cat("/qspi/maxext.txt"); + + if( debug_uart3 && !( from_eth ) ) pc.printf("Min Ext "); + if( from_eth ) { + snprintf( file_buffer, FILE_BUFFER_SIZE, "Min Ext " ); + if( tcp_session && !udp_query ) while( !( tcp_client.send_all( file_buffer, strlen( file_buffer ) ) ) ); + + else if( udp_query ) { + udp_query_send_msg( file_buffer ); + } + } + + cat("/qspi/minext.txt"); + + if( debug_uart3 && !( from_eth ) ) pc.printf("Shift Port "); + if( from_eth ) { + snprintf( file_buffer, FILE_BUFFER_SIZE, "Shift Port " ); + if( tcp_session && !udp_query ) while( !( tcp_client.send_all( file_buffer, strlen( file_buffer ) ) ) ); + + else if( udp_query ) { + udp_query_send_msg( file_buffer ); + } + } + + cat("/qspi/shift_port.txt"); + + if( debug_uart3 && !( from_eth ) ) pc.printf("Clock Server IP "); + if( from_eth ) { + snprintf( file_buffer, FILE_BUFFER_SIZE, "Clock Server IP " ); + if( tcp_session && !udp_query ) while( !( tcp_client.send_all( file_buffer, strlen( file_buffer ) ) ) ); + + else if( udp_query ) { + udp_query_send_msg( file_buffer ); + } + } + + cat("/qspi/serverip.txt"); + + if( debug_uart3 && !( from_eth ) ) pc.printf("Clock Server Port %d\r\n", CLOCK_SERVER_PORT ); + if( from_eth ) { + snprintf( file_buffer, FILE_BUFFER_SIZE, "Clock Server Port %d\r\n", CLOCK_SERVER_PORT ); + if( tcp_session && !udp_query ) while( !( tcp_client.send_all( file_buffer, strlen( file_buffer ) ) ) ); + + else if( udp_query ) { + udp_query_send_msg( file_buffer ); + } + } + + if( debug_uart3 && !( from_eth ) ) pc.printf("Clock Header Port %d\r\n", CLOCK_HEADER_PORT ); + if( from_eth ) { + snprintf( file_buffer, FILE_BUFFER_SIZE, "Clock Header Port %d\r\n", CLOCK_HEADER_PORT ); + if( tcp_session && !udp_query ) while( !( tcp_client.send_all( file_buffer, strlen( file_buffer ) ) ) ); + + else if( udp_query ) { + udp_query_send_msg( file_buffer ); + } + } + + if( debug_uart3 && !( from_eth ) ) pc.printf("Bootloader Port %d\r\n", BL_PORT ); + if( from_eth ) { + snprintf( file_buffer, FILE_BUFFER_SIZE, "Bootloader Port %d\r\n", BL_PORT ); + if( tcp_session && !udp_query ) while( !( tcp_client.send_all( file_buffer, strlen( file_buffer ) ) ) ); + + else if( udp_query ) { + udp_query_send_msg( file_buffer ); + } + } + + //*------------ formatando a saida ----------------*// + for( register int i = 0; i < FILE_BUFFER_SIZE; i++ ) file_buffer[ i ] = 0; + + if( from_eth ) { + if( tcp_session && !udp_query ) { + snprintf( file_buffer, FILE_BUFFER_SIZE, "> " ); + if( tcp_session && !udp_query ) while( !( tcp_client.send_all( file_buffer, strlen( file_buffer ) ) ) ); + } else if( udp_query ) { + udp_query_send_msg( "> " ); + + } + } + } + + if (type == 'c' ) { + // close all files + if( fip ) fclose( fip ); + if( fmask ) fclose( fmask ); + if( fgate ) fclose( fgate ); + if( fport )fclose( fport ); + if( fsip ) fclose( fsip ); + if( fsport ) fclose( fsport ); + if( fext ) fclose( fext ); + if( fserext ) fclose( fserext ); + if( fudpport ) fclose( fudpport ); + if( ftcpport ) fclose( ftcpport ); + if( fmax ) fclose( fmax ); + if( fmin ) fclose( fmin ); + if( ffwip ) fclose( ffwip ); + if( ffwport) fclose( ffwport ); + if( fshift_port ) fclose ( fshift_port ); + } + + + // Check if files exist, if not create the files + //fixme criar um bool pra cada file + if (type == 'i' ) + { + bool exists = true; + + fip = fopen ("/qspi/myip.txt", "r"); + if( fip == NULL) { + set_ip( MY_IP ); + exists = false; + } + if ( fip ) fclose ( fip ); + fip = NULL; + + fserext = fopen("/qspi/myext.txt", "r"); + if( fserext == NULL ) { + set_header_ext( MY_EXT ); + exists = false; + } + if ( fserext ) fclose ( fserext ); + fserext = NULL; + + fport = fopen("/qspi/mysipport.txt", "r"); + if (fport == NULL) { + set_header_sip_port( MY_PORT ); + exists = false; + } + if ( fport ) fclose ( fport ); + fport = NULL; + + fsip = fopen("/qspi/serverip.txt", "r"); + if (fsip == NULL) { + set_server_ip( SERVER_IP ); + exists = false; + } + if ( fsip ) fclose ( fsip ); + fsip = NULL; + + fext = fopen("/qspi/peerext.txt", "r"); + if ( fext == NULL ) { + set_server_ext( PEER_EXT ); + exists = false; + } + if ( fext ) fclose ( fext ); + fext = NULL; + + fsport = fopen("/qspi/serverport.txt", "r"); + if (fsport == NULL) { + set_server_port( SERVER_PORT ); + exists = false; + } + if ( fsport ) fclose ( fsport ); + fsport = NULL; + + fmask = fopen("/qspi/mymask.txt", "r"); + if (fmask == NULL) { + set_mask( MY_MSK ); + exists = false; + } + if ( fmask ) fclose ( fmask ); + fmask = NULL; + + fgate = fopen("/qspi/mygateway.txt", "r"); + if (fgate == NULL) { + set_gateway( MY_GTW ); + exists = false; + } + if ( fgate ) fclose ( fgate ); + fgate = NULL; + + fudpport = fopen("/qspi/udpport.txt", "r" ); + if( fudpport == NULL ) { + set_udp_port_listener( UDP_PORT_LISTENER ); + exists = false; + } + if ( fudpport ) fclose ( fudpport ); + fudpport = NULL; + + ftcpport = fopen("/qspi/tcpport.txt", "r" ); + if( ftcpport == NULL ) { + set_tcp_port_listener( TCP_PORT_LISTENER ); + exists = false; + } + if ( ftcpport ) fclose ( ftcpport ); + ftcpport = NULL; + + ffwip = fopen("/qspi/fw_ip.txt", "r" ); + if( ffwip == NULL ) { + set_fw_ip( __FW_SERVER_IP__ ); + exists = false; + } + if ( ffwip ) fclose ( ffwip ); + ffwip = NULL; + + ffwport = fopen("/qspi/fw_port.txt", "r" ); + if( ffwport == NULL ) { + set_fw_port( __FW_SERVER_PORT__ ); + exists = false; + } + if ( ffwport ) fclose ( ffwport ); + ffwport = NULL; + + fmax = fopen("/qspi/maxext.txt", "r" ); + if( fmax == NULL ) { + set_max_ext( MAX_EXT ); + exists = false; + } + if ( fmax ) fclose ( fmax ); + fmax = NULL; + + fmin = fopen("/qspi/minext.txt", "r" ); + if( fmin == NULL ) { + if( debug_file ) debug_msg("Don't exist /qspi/minext.txt"); + set_min_ext( MIN_EXT ); + exists = false; + } + if ( fmin ) fclose ( fmin ); + fmin = NULL; + + fshift_port = fopen("/qspi/shift_port.txt", "r" ); + if( fshift_port == NULL ) + { + if( debug_file ) debug_msg("Don't exist /qspi/shift_port.txt"); + set_shift_port( SHIFT_PORT ); + exists = false; + } + if ( fshift_port ) fclose ( fshift_port ); + fshift_port = NULL; + + if( !exists ) { + if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rDefault configurations set!\n\r"); + if( from_eth ) { + snprintf( file_buffer, FILE_BUFFER_SIZE, "Default configurations set!\n\r"); + file_buffer[ strlen( file_buffer ) - 1 ] = '\0'; + if( tcp_session && !udp_query ) { + tcp_client.send_all( file_buffer, strlen( file_buffer ) ); + for( register int i = 0; i < FILE_BUFFER_SIZE; i++ ) file_buffer[ i ] = 0; + } + } + } + } + + if (type == 'r' ) { + // Just open for read + fip = fopen ("/qspi/myip.txt", "r"); + fmask = fopen("/qspi/mymask.txt", "r"); + fgate = fopen("/qspi/mygateway.txt", "r"); + fport = fopen("/qspi/mysipport.txt", "r"); + fsip = fopen("/qspi/serverip.txt", "r"); + fsport = fopen("/qspi/serverport.txt", "r"); + fext = fopen( "/qspi/myext.txt", "r" ); + fserext = fopen( "/qspi/peerext.txt", "r" ); + fudpport = fopen( "/qspi/udpport.txt", "r" ); + ftcpport = fopen( "/qspi/tcpport.txt", "r" ); + ffwip = fopen("/qspi/fw_ip.txt", "r" ); + ffwport = fopen("/qspi/fw_port.txt", "r" ); + fmax = fopen("/qspi/maxext.txt", "r" ); + fmin = fopen("/qspi/minext.txt", "r" ); + fshift_port = fopen("/qspi/shift_port.txt", "r" ); + + } + + if( type == 'w') { + + // Create and write the default configs + set_ip( MY_IP ); + + set_header_sip_port( MY_PORT ); + + set_header_ext( MY_EXT ); + + set_server_ip( SERVER_IP ); + + set_server_ext( PEER_EXT ); + + set_server_port( SERVER_PORT ); + + set_mask( MY_MSK ); + + set_gateway( MY_GTW ); + + set_udp_port_listener( UDP_PORT_LISTENER ); + + set_tcp_port_listener( TCP_PORT_LISTENER ); + + set_fw_ip( __FW_SERVER_IP__ ); + + set_fw_port( __FW_SERVER_PORT__ ); + + set_max_ext( MAX_EXT ); + + set_min_ext( MIN_EXT ); + + set_shift_port( SHIFT_PORT ); + + if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rDefault configurations set!\n\r"); + if( from_eth ) { + snprintf( file_buffer, FILE_BUFFER_SIZE, "\n\rDefault configurations set!\n\r"); + file_buffer[ strlen( file_buffer ) - 1 ] = '\0'; + if( tcp_session && !udp_query ) { + tcp_client.send_all( file_buffer, strlen( file_buffer ) ); + } else if( udp_query ) { + udp_query_send_msg( file_buffer ); + } + for( register int i = 0; i < FILE_BUFFER_SIZE; i++ ) file_buffer[ i ] = 0; + } + + } + + if (type == 'e') + { + //Erase configs + fip = fopen ("/qspi/myip.txt", "w"); + fmask = fopen("/qspi/mymask.txt", "w"); + fgate = fopen("/qspi/mygateway.txt", "w"); + fport = fopen("/qspi/mysipport.txt", "w"); + fsip = fopen("/qspi/serverip.txt", "w"); + fsport = fopen("/qspi/serverport.txt", "w"); + fext = fopen( "/qspi/myext.txt", "w" ); + fserext = fopen( "/qspi/peerext.txt", "w" ); + fudpport = fopen( "/qspi/udpport.txt", "w" ); + ftcpport = fopen( "/qspi/tcpport.txt", "w" ); + ffwip = fopen("/qspi/fw_ip.txt", "w" ); + ffwport = fopen("/qspi/fw_port.txt", "w" ); + fmax = fopen("/qspi/maxext.txt", "w" ); + fmin = fopen("/qspi/minext.txt", "w" ); + fshift_port = fopen("/qspi/shift_port.txt", "w" ); + + if( fip ) fprintf( fip, "%s\n\r", "" ); + if( fport ) fprintf( fport, "%i\n\r", 0 ); + if( fext ) fprintf( fext, "%i\n\r", 0 ); + + if( fsip ) fprintf( fsip, "%s\n\r", "" ); + if( fserext ) fprintf( fserext, "%i\n\r", 0 ); + if( fsport ) fprintf( fsport, "%i\n\r", 0 ); + + if( fmask ) fprintf( fmask, "%s\n\r","" ); + if( fgate ) fprintf( fgate, "%s\n\r", "" ); + + if( fudpport ) fprintf( fudpport, "%i\n\r", 0 ); + if( ftcpport ) fprintf( ftcpport, "%i\n\r", 0 ); + + if( ffwip ) fprintf( ffwip, "%s\n\r","" ); + if( ffwport ) fprintf( ffwport, "%i\n\r",0 ); + + if( fmax ) fprintf( fmax, "%i\n\r", 0 ); + if( fmin ) fprintf( fmin, "%i\n\r", 0 ); + + if( fshift_port ) fprintf( fshift_port, "%i\n\r", 0 ); + + files('c'); + + if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rErased configurations set!\n\r"); + if( from_eth ) { + snprintf( file_buffer, FILE_BUFFER_SIZE, "\n\rErased configurations set!\n\r"); + file_buffer[ strlen( file_buffer ) - 1 ] = '\0'; + if( tcp_session && !udp_query ) { + tcp_client.send_all( file_buffer, strlen( file_buffer ) ); + } else if( udp_query ) { + udp_query_send_msg( file_buffer ); + } + for( register int i = 0; i < FILE_BUFFER_SIZE; i++ ) file_buffer[ i ] = 0; + } + + } +} + +int init_fsystem ( void ) +{ + // init file system and check if files exist + int return_value = 0; + + if (!qspifs.isformatted()) { + qspifs.format(); + return_value |= BIT0; + } + // check if the files are created + files('i'); + files('c'); + + return ( return_value |= BIT1 ); } \ No newline at end of file