bosko lekovic
/
ETHtoCOM_10
nova verzija tcp+udp->serial com
DataFlash/dataFlash.cpp@7:7ea932eb31f6, 2020-04-18 (annotated)
- Committer:
- bosko001
- Date:
- Sat Apr 18 22:32:13 2020 +0000
- Revision:
- 7:7ea932eb31f6
- Parent:
- 5:c9a908749d4c
- Child:
- 8:c0f54b381346
potpuno ispravan html - flash rad
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bosko001 | 3:1196befeace0 | 1 | #include "dataFlash.h" |
bosko001 | 3:1196befeace0 | 2 | |
bosko001 | 3:1196befeace0 | 3 | #include "flashDataBlock.h" |
bosko001 | 3:1196befeace0 | 4 | #include "EthernetSetup.h" |
bosko001 | 3:1196befeace0 | 5 | #include "clubbing.h" |
bosko001 | 3:1196befeace0 | 6 | #include "dataFlash.h" |
bosko001 | 3:1196befeace0 | 7 | |
bosko001 | 5:c9a908749d4c | 8 | #include "doHTML.h" |
bosko001 | 5:c9a908749d4c | 9 | |
bosko001 | 5:c9a908749d4c | 10 | |
bosko001 | 5:c9a908749d4c | 11 | |
bosko001 | 5:c9a908749d4c | 12 | |
bosko001 | 5:c9a908749d4c | 13 | struct S_FlashData s_ramData, *gps_rd = &s_ramData; //RAM podaci |
bosko001 | 5:c9a908749d4c | 14 | |
bosko001 | 5:c9a908749d4c | 15 | |
bosko001 | 5:c9a908749d4c | 16 | /*********** upis/citanje na ram */ |
bosko001 | 5:c9a908749d4c | 17 | void progDataIntoFlash( struct S_FlashData *ps_fd ) |
bosko001 | 5:c9a908749d4c | 18 | { |
bosko001 | 5:c9a908749d4c | 19 | write_niz_in_flash( 0, (char *)ps_fd, sizeof(S_FlashData) ); |
bosko001 | 5:c9a908749d4c | 20 | } |
bosko001 | 5:c9a908749d4c | 21 | |
bosko001 | 5:c9a908749d4c | 22 | void readDataFromFlash( struct S_FlashData *ps_fd ) |
bosko001 | 5:c9a908749d4c | 23 | { |
bosko001 | 5:c9a908749d4c | 24 | read_fdb( 0, (char*)ps_fd, sizeof(struct S_FlashData) ); |
bosko001 | 5:c9a908749d4c | 25 | } |
bosko001 | 5:c9a908749d4c | 26 | |
bosko001 | 5:c9a908749d4c | 27 | |
bosko001 | 5:c9a908749d4c | 28 | /* upis citanje u RAM na koji pokazuje globalni pointer gps_rd */ |
bosko001 | 5:c9a908749d4c | 29 | void fillDataIntoFlash( void ) |
bosko001 | 5:c9a908749d4c | 30 | { |
bosko001 | 5:c9a908749d4c | 31 | progDataIntoFlash( gps_rd ); |
bosko001 | 5:c9a908749d4c | 32 | // write_niz_in_flash( 0, (char *)gps_rd, sizeof(S_FlashData) ); |
bosko001 | 5:c9a908749d4c | 33 | } |
bosko001 | 5:c9a908749d4c | 34 | void refreshDataFromFlash( void ) |
bosko001 | 5:c9a908749d4c | 35 | { |
bosko001 | 5:c9a908749d4c | 36 | readDataFromFlash( gps_rd ); |
bosko001 | 5:c9a908749d4c | 37 | // read_fdb( 0, (char*)gps_rd, sizeof(struct S_FlashData) ); |
bosko001 | 5:c9a908749d4c | 38 | } |
bosko001 | 5:c9a908749d4c | 39 | |
bosko001 | 5:c9a908749d4c | 40 | |
bosko001 | 5:c9a908749d4c | 41 | void init_FlashData( void ) |
bosko001 | 5:c9a908749d4c | 42 | { |
bosko001 | 5:c9a908749d4c | 43 | init_fdb( ); |
bosko001 | 5:c9a908749d4c | 44 | readDataFromFlash( gps_rd ); |
bosko001 | 5:c9a908749d4c | 45 | |
bosko001 | 5:c9a908749d4c | 46 | } |
bosko001 | 5:c9a908749d4c | 47 | |
bosko001 | 5:c9a908749d4c | 48 | |
bosko001 | 5:c9a908749d4c | 49 | void deinit_FlashData( void ) |
bosko001 | 5:c9a908749d4c | 50 | { |
bosko001 | 5:c9a908749d4c | 51 | deinit_fdb( ); |
bosko001 | 5:c9a908749d4c | 52 | } |
bosko001 | 5:c9a908749d4c | 53 | |
bosko001 | 5:c9a908749d4c | 54 | void showFlashData( void ) |
bosko001 | 5:c9a908749d4c | 55 | { |
bosko001 | 7:7ea932eb31f6 | 56 | refreshDataFromFlash( ); |
bosko001 | 7:7ea932eb31f6 | 57 | P_str( "FLASH IP ", gps_rd->myIP ); |
bosko001 | 7:7ea932eb31f6 | 58 | P_str( "FLASH MASK ", gps_rd->myMask ); |
bosko001 | 7:7ea932eb31f6 | 59 | P_str( "FLASH GATE ", gps_rd->myGate ); |
bosko001 | 5:c9a908749d4c | 60 | |
bosko001 | 7:7ea932eb31f6 | 61 | P_str( "FLASH UDP PORT ", gps_rd->myUdpPort ); |
bosko001 | 7:7ea932eb31f6 | 62 | P_str( "FLASH TCP PORT ", gps_rd->myTcpPort ); |
bosko001 | 5:c9a908749d4c | 63 | |
bosko001 | 7:7ea932eb31f6 | 64 | P_str( "FLASH UDP IP[0] ", gps_rd->UdpIP[0] ); |
bosko001 | 7:7ea932eb31f6 | 65 | P_str( "FLASH UDP IP[1] ", gps_rd->UdpIP[1] ); |
bosko001 | 7:7ea932eb31f6 | 66 | P_str( "FLASH UDP IP[2] ", gps_rd->UdpIP[2] ); |
bosko001 | 7:7ea932eb31f6 | 67 | P_str( "FLASH UDP IP[3] ", gps_rd->UdpIP[3] ); |
bosko001 | 7:7ea932eb31f6 | 68 | P_str( "FLASH UDP IP[4] ", gps_rd->UdpIP[4] ); |
bosko001 | 7:7ea932eb31f6 | 69 | |
bosko001 | 7:7ea932eb31f6 | 70 | P_str( "FLASH UDP PORT[0] ", gps_rd->UdpPort[0] ); |
bosko001 | 7:7ea932eb31f6 | 71 | P_str( "FLASH UDP PORT[1] ", gps_rd->UdpPort[1] ); |
bosko001 | 7:7ea932eb31f6 | 72 | P_str( "FLASH UDP PORT[2] ", gps_rd->UdpPort[2] ); |
bosko001 | 7:7ea932eb31f6 | 73 | P_str( "FLASH UDP PORT[3] ", gps_rd->UdpPort[3] ); |
bosko001 | 7:7ea932eb31f6 | 74 | |
bosko001 | 7:7ea932eb31f6 | 75 | P_str( "FLASH TCP IP[0] ", gps_rd->TcpIP[0] ); |
bosko001 | 7:7ea932eb31f6 | 76 | P_str( "FLASH TCP IP[1] ", gps_rd->TcpIP[1] ); |
bosko001 | 7:7ea932eb31f6 | 77 | P_str( "FLASH TCP IP[2] ", gps_rd->TcpIP[2] ); |
bosko001 | 7:7ea932eb31f6 | 78 | P_str( "FLASH TCP IP[3] ", gps_rd->TcpIP[3] ); |
bosko001 | 7:7ea932eb31f6 | 79 | P_str( "FLASH TCP IP[4] ", gps_rd->TcpIP[4] ); |
bosko001 | 7:7ea932eb31f6 | 80 | |
bosko001 | 7:7ea932eb31f6 | 81 | P_str( "FLASH TCP PORT[0] ", gps_rd->TcpPort[0] ); |
bosko001 | 7:7ea932eb31f6 | 82 | P_str( "FLASH TCP PORT[1] ", gps_rd->TcpPort[1] ); |
bosko001 | 7:7ea932eb31f6 | 83 | P_str( "FLASH TCP PORT[2] ", gps_rd->TcpPort[2] ); |
bosko001 | 7:7ea932eb31f6 | 84 | P_str( "FLASH TCP PORT[3] ", gps_rd->TcpPort[3] ); |
bosko001 | 5:c9a908749d4c | 85 | |
bosko001 | 7:7ea932eb31f6 | 86 | P_str( "FLASH SERIAL BAUD ", gps_rd->baud_rate ); |
bosko001 | 7:7ea932eb31f6 | 87 | P_str( "FLASH SERIAL BAUD ", gps_rd->parity ); |
bosko001 | 7:7ea932eb31f6 | 88 | P_str( "FLASH SERIAL BAUD ", gps_rd->data_bits ); |
bosko001 | 7:7ea932eb31f6 | 89 | P_str( "FLASH SERIAL BAUD ", gps_rd->stop_bits ); |
bosko001 | 5:c9a908749d4c | 90 | } |
bosko001 | 5:c9a908749d4c | 91 | |
bosko001 | 5:c9a908749d4c | 92 | |
bosko001 | 7:7ea932eb31f6 | 93 | // |
bosko001 | 7:7ea932eb31f6 | 94 | //struct S_FlashData |
bosko001 | 7:7ea932eb31f6 | 95 | //{ |
bosko001 | 7:7ea932eb31f6 | 96 | // char myIP[16]; |
bosko001 | 7:7ea932eb31f6 | 97 | // char myMask[16]; |
bosko001 | 7:7ea932eb31f6 | 98 | // char myGate[16]; |
bosko001 | 7:7ea932eb31f6 | 99 | // char myUdpPort[6]; |
bosko001 | 7:7ea932eb31f6 | 100 | // char myTcpPort[6]; |
bosko001 | 7:7ea932eb31f6 | 101 | // char UdpIP[5][16]; |
bosko001 | 7:7ea932eb31f6 | 102 | // char UdpPort[4][6]; |
bosko001 | 7:7ea932eb31f6 | 103 | // char TcpPort[4][6]; |
bosko001 | 7:7ea932eb31f6 | 104 | // char baud_rate[7], parity[6], data_bits[2], stop_bits[4]; |
bosko001 | 7:7ea932eb31f6 | 105 | //}; |
bosko001 | 7:7ea932eb31f6 | 106 | |
bosko001 | 7:7ea932eb31f6 | 107 | |
bosko001 | 7:7ea932eb31f6 | 108 | |
bosko001 | 7:7ea932eb31f6 | 109 | #define COPY_IP_TO_FLASH( dest, source ) if( test_ip( pch->get_myIP( ) ) ) strncpy( gps_rd->dest, pch->source, 16 ) |
bosko001 | 7:7ea932eb31f6 | 110 | |
bosko001 | 5:c9a908749d4c | 111 | |
bosko001 | 5:c9a908749d4c | 112 | void putHTMLintoFLASH( C_HTMLparse *pch ) |
bosko001 | 5:c9a908749d4c | 113 | { |
bosko001 | 5:c9a908749d4c | 114 | |
bosko001 | 5:c9a908749d4c | 115 | |
bosko001 | 7:7ea932eb31f6 | 116 | if( test_ip( pch->get_myIP( ) ) ) strncpy( gps_rd->myIP, pch->get_myIP( ), 16 ); |
bosko001 | 7:7ea932eb31f6 | 117 | if( test_ip( pch->get_myMASK( ) ) ) strncpy( gps_rd->myMask, pch->get_myMASK(), 16 ); |
bosko001 | 7:7ea932eb31f6 | 118 | if( test_ip( pch->get_myGATE( ) ) ) strncpy( gps_rd->myGate, pch->get_myGATE(), 16 ); |
bosko001 | 5:c9a908749d4c | 119 | |
bosko001 | 7:7ea932eb31f6 | 120 | if( test_num( pch->get_myUdpPort())) strncpy( gps_rd->myUdpPort, pch->get_myUdpPort(), 6 ); |
bosko001 | 7:7ea932eb31f6 | 121 | if( test_num( pch->get_myTcpPort())) strncpy( gps_rd->myTcpPort, pch->get_myTcpPort(), 6 ); |
bosko001 | 5:c9a908749d4c | 122 | |
bosko001 | 7:7ea932eb31f6 | 123 | if( test_ip( pch->get_UdpIP(1) ) ) strncpy( gps_rd->UdpIP[0], pch->get_UdpIP(1), 16 ); |
bosko001 | 7:7ea932eb31f6 | 124 | if( test_ip( pch->get_UdpIP(2) ) ) strncpy( gps_rd->UdpIP[1], pch->get_UdpIP(2), 16 ); |
bosko001 | 7:7ea932eb31f6 | 125 | if( test_ip( pch->get_UdpIP(3) ) ) strncpy( gps_rd->UdpIP[2], pch->get_UdpIP(3), 16 ); |
bosko001 | 7:7ea932eb31f6 | 126 | if( test_ip( pch->get_UdpIP(4) ) ) strncpy( gps_rd->UdpIP[3], pch->get_UdpIP(4), 16 ); |
bosko001 | 7:7ea932eb31f6 | 127 | if( test_ip( pch->get_UdpIP(5) ) ) strncpy( gps_rd->UdpIP[4], pch->get_UdpIP(5), 16 ); |
bosko001 | 7:7ea932eb31f6 | 128 | |
bosko001 | 7:7ea932eb31f6 | 129 | if( test_num( pch->get_UdpPort(1))) strncpy( gps_rd->UdpPort[0], pch->get_UdpPort(1), 6 ); |
bosko001 | 7:7ea932eb31f6 | 130 | if( test_num( pch->get_UdpPort(2))) strncpy( gps_rd->UdpPort[1], pch->get_UdpPort(2), 6 ); |
bosko001 | 7:7ea932eb31f6 | 131 | if( test_num( pch->get_UdpPort(3))) strncpy( gps_rd->UdpPort[2], pch->get_UdpPort(3), 6 ); |
bosko001 | 7:7ea932eb31f6 | 132 | if( test_num( pch->get_UdpPort(4))) strncpy( gps_rd->UdpPort[3], pch->get_UdpPort(4), 6 ); |
bosko001 | 7:7ea932eb31f6 | 133 | |
bosko001 | 7:7ea932eb31f6 | 134 | if( test_ip( pch->get_TcpIP(1) ) ) strncpy( gps_rd->TcpIP[0], pch->get_TcpIP(1), 16 ); |
bosko001 | 7:7ea932eb31f6 | 135 | if( test_ip( pch->get_TcpIP(2) ) ) strncpy( gps_rd->TcpIP[1], pch->get_TcpIP(2), 16 ); |
bosko001 | 7:7ea932eb31f6 | 136 | if( test_ip( pch->get_TcpIP(3) ) ) strncpy( gps_rd->TcpIP[2], pch->get_TcpIP(3), 16 ); |
bosko001 | 7:7ea932eb31f6 | 137 | if( test_ip( pch->get_TcpIP(4) ) ) strncpy( gps_rd->TcpIP[3], pch->get_TcpIP(4), 16 ); |
bosko001 | 7:7ea932eb31f6 | 138 | if( test_ip( pch->get_TcpIP(5) ) ) strncpy( gps_rd->TcpIP[4], pch->get_TcpIP(5), 16 ); |
bosko001 | 5:c9a908749d4c | 139 | |
bosko001 | 7:7ea932eb31f6 | 140 | if( test_num(pch->get_TcpPort(1))) strncpy( gps_rd->TcpPort[0], pch->get_TcpPort(1), 6 ); |
bosko001 | 7:7ea932eb31f6 | 141 | if( test_num(pch->get_TcpPort(2))) strncpy( gps_rd->TcpPort[1], pch->get_TcpPort(2), 6 ); |
bosko001 | 7:7ea932eb31f6 | 142 | if( test_num(pch->get_TcpPort(3))) strncpy( gps_rd->TcpPort[2], pch->get_TcpPort(3), 6 ); |
bosko001 | 7:7ea932eb31f6 | 143 | if( test_num(pch->get_TcpPort(4))) strncpy( gps_rd->TcpPort[3], pch->get_TcpPort(4), 6 ); |
bosko001 | 7:7ea932eb31f6 | 144 | // |
bosko001 | 7:7ea932eb31f6 | 145 | // printf("baud = %s\n\r", pch->get_selected_option( "baud_rate" )); |
bosko001 | 7:7ea932eb31f6 | 146 | // printf("parity = %s\n\r", pch->get_selected_option( "parity" )); |
bosko001 | 7:7ea932eb31f6 | 147 | // printf("dataBits = %s\n\r", pch->get_selected_option( "data_bits" )); |
bosko001 | 7:7ea932eb31f6 | 148 | // printf("stopBits = %s\n\r", pch->get_selected_option( "stop_bits" )); |
bosko001 | 7:7ea932eb31f6 | 149 | //fflush(stdout); |
bosko001 | 5:c9a908749d4c | 150 | |
bosko001 | 7:7ea932eb31f6 | 151 | strncpy( gps_rd->baud_rate, pch->get_selected_option( "baud_rate" ), 7 ); |
bosko001 | 7:7ea932eb31f6 | 152 | strncpy( gps_rd->parity, pch->get_selected_option( "parity" ), 6 ); |
bosko001 | 7:7ea932eb31f6 | 153 | strncpy( gps_rd->data_bits, pch->get_selected_option( "data_bits" ), 2 ); |
bosko001 | 7:7ea932eb31f6 | 154 | strncpy( gps_rd->stop_bits, pch->get_selected_option( "stop_bits" ), 4 ); |
bosko001 | 7:7ea932eb31f6 | 155 | |
bosko001 | 5:c9a908749d4c | 156 | fillDataIntoFlash( ); |
bosko001 | 5:c9a908749d4c | 157 | } |
bosko001 | 5:c9a908749d4c | 158 | |
bosko001 | 7:7ea932eb31f6 | 159 | // else if( !strcmp( s_hpv[i].name, "baud_rate") ) set_selected_option( "baud_rate" , s_hpv[i].value ); |
bosko001 | 7:7ea932eb31f6 | 160 | // else if( !strcmp( s_hpv[i].name, "parity") ) set_selected_option( "parity" , s_hpv[i].value ); |
bosko001 | 7:7ea932eb31f6 | 161 | // else if( !strcmp( s_hpv[i].name, "data_bits") ) { set_selected_option( "data_bits" , s_hpv[i].value ); } |
bosko001 | 7:7ea932eb31f6 | 162 | // else if( !strcmp( s_hpv[i].name, "stop_bits") ) { set_selected_option( "stop_bits" , s_hpv[i].value ); } |
bosko001 | 5:c9a908749d4c | 163 | |
bosko001 | 5:c9a908749d4c | 164 | void putFLASHintoHTML( C_HTMLparse *pch ) |
bosko001 | 5:c9a908749d4c | 165 | { |
bosko001 | 5:c9a908749d4c | 166 | |
bosko001 | 5:c9a908749d4c | 167 | refreshDataFromFlash( ); |
bosko001 | 5:c9a908749d4c | 168 | |
bosko001 | 7:7ea932eb31f6 | 169 | if( test_ip( gps_rd->myIP ) ) pch->set_myIP( gps_rd->myIP ); |
bosko001 | 7:7ea932eb31f6 | 170 | if( test_ip( gps_rd->myMask ) ) pch->set_myMASK( gps_rd->myMask ); |
bosko001 | 7:7ea932eb31f6 | 171 | if( test_ip( gps_rd->myGate ) ) pch->set_myGATE( gps_rd->myGate ); |
bosko001 | 5:c9a908749d4c | 172 | |
bosko001 | 7:7ea932eb31f6 | 173 | if( test_num( gps_rd->myUdpPort )) pch->set_myUdpPort(gps_rd->myUdpPort); |
bosko001 | 7:7ea932eb31f6 | 174 | if( test_num( gps_rd->myTcpPort )) pch->set_myTcpPort(gps_rd->myTcpPort); |
bosko001 | 5:c9a908749d4c | 175 | |
bosko001 | 7:7ea932eb31f6 | 176 | if( test_ip( gps_rd->UdpIP[0] ) ) pch->set_UdpIP(1,gps_rd->UdpIP[0]); |
bosko001 | 7:7ea932eb31f6 | 177 | if( test_ip( gps_rd->UdpIP[1] ) ) pch->set_UdpIP(2,gps_rd->UdpIP[1]); |
bosko001 | 7:7ea932eb31f6 | 178 | if( test_ip( gps_rd->UdpIP[2] ) ) pch->set_UdpIP(3,gps_rd->UdpIP[2]); |
bosko001 | 7:7ea932eb31f6 | 179 | if( test_ip( gps_rd->UdpIP[3] ) ) pch->set_UdpIP(4,gps_rd->UdpIP[3]); |
bosko001 | 7:7ea932eb31f6 | 180 | if( test_ip( gps_rd->UdpIP[4] ) ) pch->set_UdpIP(5,gps_rd->UdpIP[4]); |
bosko001 | 5:c9a908749d4c | 181 | |
bosko001 | 7:7ea932eb31f6 | 182 | if( test_num( gps_rd->UdpPort[0] )) pch->set_UdpPort( 1, gps_rd->UdpPort[0] ); |
bosko001 | 7:7ea932eb31f6 | 183 | if( test_num( gps_rd->UdpPort[1] )) pch->set_UdpPort( 2, gps_rd->UdpPort[1] ); |
bosko001 | 7:7ea932eb31f6 | 184 | if( test_num( gps_rd->UdpPort[2] )) pch->set_UdpPort( 3, gps_rd->UdpPort[2] ); |
bosko001 | 7:7ea932eb31f6 | 185 | if( test_num( gps_rd->UdpPort[3] )) pch->set_UdpPort( 4, gps_rd->UdpPort[3] ); |
bosko001 | 7:7ea932eb31f6 | 186 | |
bosko001 | 7:7ea932eb31f6 | 187 | if( test_ip( gps_rd->TcpIP[0] ) ) pch->set_TcpIP(1, gps_rd->TcpIP[0]); |
bosko001 | 7:7ea932eb31f6 | 188 | if( test_ip( gps_rd->TcpIP[1] ) ) pch->set_TcpIP(2, gps_rd->TcpIP[1]); |
bosko001 | 7:7ea932eb31f6 | 189 | if( test_ip( gps_rd->TcpIP[2] ) ) pch->set_TcpIP(3, gps_rd->TcpIP[2]); |
bosko001 | 7:7ea932eb31f6 | 190 | if( test_ip( gps_rd->TcpIP[3] ) ) pch->set_TcpIP(4, gps_rd->TcpIP[3]); |
bosko001 | 7:7ea932eb31f6 | 191 | if( test_ip( gps_rd->TcpIP[4] ) ) pch->set_TcpIP(5, gps_rd->TcpIP[4]); |
bosko001 | 7:7ea932eb31f6 | 192 | |
bosko001 | 7:7ea932eb31f6 | 193 | if( test_num( gps_rd->TcpPort[0] )) pch->set_TcpPort( 1, gps_rd->TcpPort[0] ); |
bosko001 | 7:7ea932eb31f6 | 194 | if( test_num( gps_rd->TcpPort[1] )) pch->set_TcpPort( 2, gps_rd->TcpPort[1] ); |
bosko001 | 7:7ea932eb31f6 | 195 | if( test_num( gps_rd->TcpPort[2] )) pch->set_TcpPort( 3, gps_rd->TcpPort[2] ); |
bosko001 | 7:7ea932eb31f6 | 196 | if( test_num( gps_rd->TcpPort[3] )) pch->set_TcpPort( 4, gps_rd->TcpPort[3] ); |
bosko001 | 7:7ea932eb31f6 | 197 | |
bosko001 | 7:7ea932eb31f6 | 198 | |
bosko001 | 7:7ea932eb31f6 | 199 | pch->set_selected_option( "baud_rate", gps_rd->baud_rate ); |
bosko001 | 7:7ea932eb31f6 | 200 | pch->set_selected_option( "parity", gps_rd->parity ); |
bosko001 | 7:7ea932eb31f6 | 201 | pch->set_selected_option( "data_bits", gps_rd->data_bits ); |
bosko001 | 7:7ea932eb31f6 | 202 | pch->set_selected_option( "stop_bits", gps_rd->stop_bits ); |
bosko001 | 5:c9a908749d4c | 203 | |
bosko001 | 5:c9a908749d4c | 204 | } |
bosko001 | 5:c9a908749d4c | 205 | |
bosko001 | 5:c9a908749d4c | 206 |