![](/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
file_system_manager.cpp
- Committer:
- klauss
- Date:
- 2015-03-13
- Revision:
- 106:a34fcf9f0e02
- Parent:
- 105:a930035b6556
- Child:
- 109:a5b8264ffbbc
File content as of revision 106:a34fcf9f0e02:
#include "file_system_manager.h" QSPIFileSystem qspifs("qspi"); /* void init_fsystem(){ // init file system and check if files exist if (!qspifs.isformatted()) { qspifs.format(); send_msg("\n\rFile system configured!!\n\r"); } files('i'); // check if the files are created //files('c'); send_msg("\n\r*******File System Ready*******\n\r"); } */ void set_ip( char * new_header_ip ){ FILE * fip = fopen("/qspi/myip.txt", "w"); 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" ); 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"); 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"); 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"); 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"); 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"); if( fmask ) { fprintf(fmask,"%s\n\r",new_mask ); fclose( fmask ); } } void set_gateway( char * new_gateway ){ FILE * fgate = fopen("/qspi/mygateway.txt", "w"); 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" ); 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" ); 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" ); 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" ); 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 ); fclose( fmex ); } } void set_min_ext( int new_min_ext ){ FILE * fmin = fopen( "/qspi/minext.txt", "w" ); if( fmin ){ fprintf( fmin, "%i\n\r", new_min_ext ); fclose( fmin ); } } 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 ){ char buff[513]; int num; FILE *fp = fopen( fname, "r" ); if (fp == NULL) { if( debug_file ) if( debug_uart3 && !( from_eth ) ) pc.printf( "Failed to open %s", fname); return; } while( ( num = fread( buff, 1, 512, fp ) ) > 0 ){ buff[ num ] = '\0'; if( debug_uart3 && !( from_eth ) ) pc.printf( buff ); if( from_eth ){ if( tcp_session && !udp_query ) while( !( tcp_client.send_all( buff, strlen( buff ) ) ) ); else if( udp_query ){ udp_query_send_msg( buff ); } } } fclose(fp); }