bosko lekovic
/
ETHtoCOM_10
nova verzija tcp+udp->serial com
DataFlash/dataFlash.cpp
- Committer:
- bosko001
- Date:
- 2020-04-18
- Revision:
- 7:7ea932eb31f6
- Parent:
- 5:c9a908749d4c
- Child:
- 8:c0f54b381346
File content as of revision 7:7ea932eb31f6:
#include "dataFlash.h" #include "flashDataBlock.h" #include "EthernetSetup.h" #include "clubbing.h" #include "dataFlash.h" #include "doHTML.h" struct S_FlashData s_ramData, *gps_rd = &s_ramData; //RAM podaci /*********** upis/citanje na ram */ void progDataIntoFlash( struct S_FlashData *ps_fd ) { write_niz_in_flash( 0, (char *)ps_fd, sizeof(S_FlashData) ); } void readDataFromFlash( struct S_FlashData *ps_fd ) { read_fdb( 0, (char*)ps_fd, sizeof(struct S_FlashData) ); } /* upis citanje u RAM na koji pokazuje globalni pointer gps_rd */ void fillDataIntoFlash( void ) { progDataIntoFlash( gps_rd ); // write_niz_in_flash( 0, (char *)gps_rd, sizeof(S_FlashData) ); } void refreshDataFromFlash( void ) { readDataFromFlash( gps_rd ); // read_fdb( 0, (char*)gps_rd, sizeof(struct S_FlashData) ); } void init_FlashData( void ) { init_fdb( ); readDataFromFlash( gps_rd ); } void deinit_FlashData( void ) { deinit_fdb( ); } void showFlashData( void ) { refreshDataFromFlash( ); P_str( "FLASH IP ", gps_rd->myIP ); P_str( "FLASH MASK ", gps_rd->myMask ); P_str( "FLASH GATE ", gps_rd->myGate ); P_str( "FLASH UDP PORT ", gps_rd->myUdpPort ); P_str( "FLASH TCP PORT ", gps_rd->myTcpPort ); P_str( "FLASH UDP IP[0] ", gps_rd->UdpIP[0] ); P_str( "FLASH UDP IP[1] ", gps_rd->UdpIP[1] ); P_str( "FLASH UDP IP[2] ", gps_rd->UdpIP[2] ); P_str( "FLASH UDP IP[3] ", gps_rd->UdpIP[3] ); P_str( "FLASH UDP IP[4] ", gps_rd->UdpIP[4] ); P_str( "FLASH UDP PORT[0] ", gps_rd->UdpPort[0] ); P_str( "FLASH UDP PORT[1] ", gps_rd->UdpPort[1] ); P_str( "FLASH UDP PORT[2] ", gps_rd->UdpPort[2] ); P_str( "FLASH UDP PORT[3] ", gps_rd->UdpPort[3] ); P_str( "FLASH TCP IP[0] ", gps_rd->TcpIP[0] ); P_str( "FLASH TCP IP[1] ", gps_rd->TcpIP[1] ); P_str( "FLASH TCP IP[2] ", gps_rd->TcpIP[2] ); P_str( "FLASH TCP IP[3] ", gps_rd->TcpIP[3] ); P_str( "FLASH TCP IP[4] ", gps_rd->TcpIP[4] ); P_str( "FLASH TCP PORT[0] ", gps_rd->TcpPort[0] ); P_str( "FLASH TCP PORT[1] ", gps_rd->TcpPort[1] ); P_str( "FLASH TCP PORT[2] ", gps_rd->TcpPort[2] ); P_str( "FLASH TCP PORT[3] ", gps_rd->TcpPort[3] ); P_str( "FLASH SERIAL BAUD ", gps_rd->baud_rate ); P_str( "FLASH SERIAL BAUD ", gps_rd->parity ); P_str( "FLASH SERIAL BAUD ", gps_rd->data_bits ); P_str( "FLASH SERIAL BAUD ", gps_rd->stop_bits ); } // //struct S_FlashData //{ // char myIP[16]; // char myMask[16]; // char myGate[16]; // char myUdpPort[6]; // char myTcpPort[6]; // char UdpIP[5][16]; // char UdpPort[4][6]; // char TcpPort[4][6]; // char baud_rate[7], parity[6], data_bits[2], stop_bits[4]; //}; #define COPY_IP_TO_FLASH( dest, source ) if( test_ip( pch->get_myIP( ) ) ) strncpy( gps_rd->dest, pch->source, 16 ) void putHTMLintoFLASH( C_HTMLparse *pch ) { if( test_ip( pch->get_myIP( ) ) ) strncpy( gps_rd->myIP, pch->get_myIP( ), 16 ); if( test_ip( pch->get_myMASK( ) ) ) strncpy( gps_rd->myMask, pch->get_myMASK(), 16 ); if( test_ip( pch->get_myGATE( ) ) ) strncpy( gps_rd->myGate, pch->get_myGATE(), 16 ); if( test_num( pch->get_myUdpPort())) strncpy( gps_rd->myUdpPort, pch->get_myUdpPort(), 6 ); if( test_num( pch->get_myTcpPort())) strncpy( gps_rd->myTcpPort, pch->get_myTcpPort(), 6 ); if( test_ip( pch->get_UdpIP(1) ) ) strncpy( gps_rd->UdpIP[0], pch->get_UdpIP(1), 16 ); if( test_ip( pch->get_UdpIP(2) ) ) strncpy( gps_rd->UdpIP[1], pch->get_UdpIP(2), 16 ); if( test_ip( pch->get_UdpIP(3) ) ) strncpy( gps_rd->UdpIP[2], pch->get_UdpIP(3), 16 ); if( test_ip( pch->get_UdpIP(4) ) ) strncpy( gps_rd->UdpIP[3], pch->get_UdpIP(4), 16 ); if( test_ip( pch->get_UdpIP(5) ) ) strncpy( gps_rd->UdpIP[4], pch->get_UdpIP(5), 16 ); if( test_num( pch->get_UdpPort(1))) strncpy( gps_rd->UdpPort[0], pch->get_UdpPort(1), 6 ); if( test_num( pch->get_UdpPort(2))) strncpy( gps_rd->UdpPort[1], pch->get_UdpPort(2), 6 ); if( test_num( pch->get_UdpPort(3))) strncpy( gps_rd->UdpPort[2], pch->get_UdpPort(3), 6 ); if( test_num( pch->get_UdpPort(4))) strncpy( gps_rd->UdpPort[3], pch->get_UdpPort(4), 6 ); if( test_ip( pch->get_TcpIP(1) ) ) strncpy( gps_rd->TcpIP[0], pch->get_TcpIP(1), 16 ); if( test_ip( pch->get_TcpIP(2) ) ) strncpy( gps_rd->TcpIP[1], pch->get_TcpIP(2), 16 ); if( test_ip( pch->get_TcpIP(3) ) ) strncpy( gps_rd->TcpIP[2], pch->get_TcpIP(3), 16 ); if( test_ip( pch->get_TcpIP(4) ) ) strncpy( gps_rd->TcpIP[3], pch->get_TcpIP(4), 16 ); if( test_ip( pch->get_TcpIP(5) ) ) strncpy( gps_rd->TcpIP[4], pch->get_TcpIP(5), 16 ); if( test_num(pch->get_TcpPort(1))) strncpy( gps_rd->TcpPort[0], pch->get_TcpPort(1), 6 ); if( test_num(pch->get_TcpPort(2))) strncpy( gps_rd->TcpPort[1], pch->get_TcpPort(2), 6 ); if( test_num(pch->get_TcpPort(3))) strncpy( gps_rd->TcpPort[2], pch->get_TcpPort(3), 6 ); if( test_num(pch->get_TcpPort(4))) strncpy( gps_rd->TcpPort[3], pch->get_TcpPort(4), 6 ); // // printf("baud = %s\n\r", pch->get_selected_option( "baud_rate" )); // printf("parity = %s\n\r", pch->get_selected_option( "parity" )); // printf("dataBits = %s\n\r", pch->get_selected_option( "data_bits" )); // printf("stopBits = %s\n\r", pch->get_selected_option( "stop_bits" )); //fflush(stdout); strncpy( gps_rd->baud_rate, pch->get_selected_option( "baud_rate" ), 7 ); strncpy( gps_rd->parity, pch->get_selected_option( "parity" ), 6 ); strncpy( gps_rd->data_bits, pch->get_selected_option( "data_bits" ), 2 ); strncpy( gps_rd->stop_bits, pch->get_selected_option( "stop_bits" ), 4 ); fillDataIntoFlash( ); } // else if( !strcmp( s_hpv[i].name, "baud_rate") ) set_selected_option( "baud_rate" , s_hpv[i].value ); // else if( !strcmp( s_hpv[i].name, "parity") ) set_selected_option( "parity" , s_hpv[i].value ); // else if( !strcmp( s_hpv[i].name, "data_bits") ) { set_selected_option( "data_bits" , s_hpv[i].value ); } // else if( !strcmp( s_hpv[i].name, "stop_bits") ) { set_selected_option( "stop_bits" , s_hpv[i].value ); } void putFLASHintoHTML( C_HTMLparse *pch ) { refreshDataFromFlash( ); if( test_ip( gps_rd->myIP ) ) pch->set_myIP( gps_rd->myIP ); if( test_ip( gps_rd->myMask ) ) pch->set_myMASK( gps_rd->myMask ); if( test_ip( gps_rd->myGate ) ) pch->set_myGATE( gps_rd->myGate ); if( test_num( gps_rd->myUdpPort )) pch->set_myUdpPort(gps_rd->myUdpPort); if( test_num( gps_rd->myTcpPort )) pch->set_myTcpPort(gps_rd->myTcpPort); if( test_ip( gps_rd->UdpIP[0] ) ) pch->set_UdpIP(1,gps_rd->UdpIP[0]); if( test_ip( gps_rd->UdpIP[1] ) ) pch->set_UdpIP(2,gps_rd->UdpIP[1]); if( test_ip( gps_rd->UdpIP[2] ) ) pch->set_UdpIP(3,gps_rd->UdpIP[2]); if( test_ip( gps_rd->UdpIP[3] ) ) pch->set_UdpIP(4,gps_rd->UdpIP[3]); if( test_ip( gps_rd->UdpIP[4] ) ) pch->set_UdpIP(5,gps_rd->UdpIP[4]); if( test_num( gps_rd->UdpPort[0] )) pch->set_UdpPort( 1, gps_rd->UdpPort[0] ); if( test_num( gps_rd->UdpPort[1] )) pch->set_UdpPort( 2, gps_rd->UdpPort[1] ); if( test_num( gps_rd->UdpPort[2] )) pch->set_UdpPort( 3, gps_rd->UdpPort[2] ); if( test_num( gps_rd->UdpPort[3] )) pch->set_UdpPort( 4, gps_rd->UdpPort[3] ); if( test_ip( gps_rd->TcpIP[0] ) ) pch->set_TcpIP(1, gps_rd->TcpIP[0]); if( test_ip( gps_rd->TcpIP[1] ) ) pch->set_TcpIP(2, gps_rd->TcpIP[1]); if( test_ip( gps_rd->TcpIP[2] ) ) pch->set_TcpIP(3, gps_rd->TcpIP[2]); if( test_ip( gps_rd->TcpIP[3] ) ) pch->set_TcpIP(4, gps_rd->TcpIP[3]); if( test_ip( gps_rd->TcpIP[4] ) ) pch->set_TcpIP(5, gps_rd->TcpIP[4]); if( test_num( gps_rd->TcpPort[0] )) pch->set_TcpPort( 1, gps_rd->TcpPort[0] ); if( test_num( gps_rd->TcpPort[1] )) pch->set_TcpPort( 2, gps_rd->TcpPort[1] ); if( test_num( gps_rd->TcpPort[2] )) pch->set_TcpPort( 3, gps_rd->TcpPort[2] ); if( test_num( gps_rd->TcpPort[3] )) pch->set_TcpPort( 4, gps_rd->TcpPort[3] ); pch->set_selected_option( "baud_rate", gps_rd->baud_rate ); pch->set_selected_option( "parity", gps_rd->parity ); pch->set_selected_option( "data_bits", gps_rd->data_bits ); pch->set_selected_option( "stop_bits", gps_rd->stop_bits ); }