![](/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:
- 106:a34fcf9f0e02
- Parent:
- 105:a930035b6556
- Child:
- 109:a5b8264ffbbc
diff -r a930035b6556 -r a34fcf9f0e02 file_system_manager.cpp --- a/file_system_manager.cpp Tue Mar 10 18:10:57 2015 +0000 +++ b/file_system_manager.cpp Fri Mar 13 19:40:56 2015 +0000 @@ -9,11 +9,8 @@ qspifs.format(); send_msg("\n\rFile system configured!!\n\r"); } - debug_msg(""); files('i'); // check if the files are created - debug_msg(""); //files('c'); - debug_msg(""); send_msg("\n\r*******File System Ready*******\n\r"); } @@ -21,84 +18,117 @@ void set_ip( char * new_header_ip ){ FILE * fip = fopen("/qspi/myip.txt", "w"); - fprintf( fip, "%s\n\r", new_header_ip ); - fclose( fip ); + if( fip ) + { + fprintf( fip, "%s\n\r", new_header_ip ); + fclose( fip ); + } } void set_header_ext( int new_header_ext ){ FILE * fext = fopen( "/qspi/myext.txt", "w" ); - fprintf( fext, "%i\n\r", new_header_ext ); - fclose( fext ); + if( fext ) + { + fprintf( fext, "%i\n\r", new_header_ext ); + fclose( fext ); + } } void set_header_sip_port( int new_header_sip_port ){ FILE * fport = fopen("/qspi/mysipport.txt", "w"); - fprintf( fport,"%i\n\r", new_header_sip_port ); - fclose( fport ); + if( fport ) + { + fprintf( fport,"%i\n\r", new_header_sip_port ); + fclose( fport ); + } } void set_server_ip( char * new_server_ip ){ FILE * fsip = fopen("/qspi/serverip.txt", "w"); - fprintf( fsip,"%s\n\r", new_server_ip ); - fclose( fsip ); + if( fsip ) + { + fprintf( fsip,"%s\n\r", new_server_ip ); + fclose( fsip ); + } } void set_server_ext( int new_server_ext ){ FILE * fserext = fopen("/qspi/peerext.txt", "w"); - fprintf( fserext , "%i\n\r", new_server_ext ); - fclose( fserext ); + if( fserext ) + { + fprintf( fserext , "%i\n\r", new_server_ext ); + fclose( fserext ); + } } void set_server_port( int new_server_port ){ FILE * fsport = fopen("/qspi/serverport.txt", "w"); - fprintf(fsport,"%i\n\r", new_server_port ); - fclose( fsport ); + if( fsport ) + { + fprintf(fsport,"%i\n\r", new_server_port ); + fclose( fsport ); + } } void set_mask( char * new_mask ){ FILE * fmask = fopen("/qspi/mymask.txt", "w"); - fprintf(fmask,"%s\n\r",new_mask ); - fclose( fmask ); + if( fmask ) + { + fprintf(fmask,"%s\n\r",new_mask ); + fclose( fmask ); + } } void set_gateway( char * new_gateway ){ - //fgate = fopen("/qspi/mygateway.txt", "w"); FILE * fgate = fopen("/qspi/mygateway.txt", "w"); - fprintf(fgate,"%s\n\r", new_gateway ); - fclose( fgate ); + if( fgate ) + { + fprintf(fgate,"%s\n\r", new_gateway ); + fclose( fgate ); + } } void set_udp_port_listener( int new_udp_port_listener ){ FILE * fudpport = fopen( "/qspi/udpport.txt", "w" ); - fprintf( fudpport, "%i\n\r",new_udp_port_listener ); - fclose( fudpport ); + if( fudpport ) + { + fprintf( fudpport, "%i\n\r",new_udp_port_listener ); + fclose( fudpport ); + } } void set_tcp_port_listener( int new_tcp_port_listener ){ FILE * ftcpport = fopen( "/qspi/tcpport.txt", "w" ); - fprintf( ftcpport, "%i\n\r",new_tcp_port_listener ); - fclose( ftcpport ); + if( ftcpport ) + { + fprintf( ftcpport, "%i\n\r",new_tcp_port_listener ); + fclose( ftcpport ); + } } void set_fw_ip( char * new_fw_ip ){ FILE * ffwip = fopen("/qspi/fw_ip.txt", "w" ); - fprintf(ffwip,"%s\n\r", new_fw_ip ); - fclose( ffwip ); + if( ffwip ) + { + fprintf(ffwip,"%s\n\r", new_fw_ip ); + fclose( ffwip ); + } } void set_fw_port( int new_fw_port ){ FILE * ffwport = fopen("/qspi/fw_port.txt", "w" ); - fprintf(ffwport,"%i\n\r", new_fw_port ); - fclose( ffwport ); + if( ffwport ) + { + fprintf(ffwport,"%i\n\r", new_fw_port ); + fclose( ffwport ); + } } void set_max_ext( int new_max_ext ){ FILE * fmex = fopen( "/qspi/maxext.txt", "w" ); if( fmex ){ fprintf( fmex, "%i\n\r", new_max_ext ); - //debug_msg(""); fclose( fmex ); - //debug_msg(""); } } @@ -110,12 +140,26 @@ } } +void set_shift_port( int new_shift_port ){ + FILE * shift_port = fopen("/qspi/shift_port.txt", "w" ); + if( shift_port ) + { + fprintf( shift_port,"%i\n\r", new_shift_port ); + fclose( shift_port ); + if( debug_file ) debug_msg("Set /qspi/shift_port.txt"); + } + else + { + if( debug_file ) debug_msg("Cannot open /qspi/shift_port.txt"); + } +} + // Print the content of a given file -void cat(const char * fname){ +void cat( const char * fname ){ char buff[513]; int num; - FILE *fp = fopen(fname, "r"); + FILE *fp = fopen( fname, "r" ); if (fp == NULL) { if( debug_file ) if( debug_uart3 && !( from_eth ) ) pc.printf( "Failed to open %s", fname); return; @@ -128,20 +172,7 @@ if( tcp_session && !udp_query ) while( !( tcp_client.send_all( buff, strlen( buff ) ) ) ); else if( udp_query ){ - //FIXME mudar isso para udp_query_send_msg udp_query_send_msg( buff ); - /* - int send = udp_client.sendTo( udp_server, buff, strlen( buff ) ); - if( send != strlen( buff ) ) - { - if( debug_reconnect ) - { - send_msg("Reconnect udp_query client"); - } - - reconnect_prompt_udp_socket(); - miss_prompt_udp_send_pkg++; - }*/ } } }