bosko lekovic
/
ETHtoCOM_10
nova verzija tcp+udp->serial com
DataFlash/dataFlash.cpp@5:c9a908749d4c, 2020-04-12 (annotated)
- Committer:
- bosko001
- Date:
- Sun Apr 12 17:59:57 2020 +0000
- Revision:
- 5:c9a908749d4c
- Parent:
- dataFlash.cpp@4:7abcf4543282
- Child:
- 7:7ea932eb31f6
12.04.2020; napravljena class C_HTMLparse; treba napraviti obradu POST upita
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 | 5:c9a908749d4c | 56 | P_str( "FLASH IP ", gps_rd->s_EthAdd.ip ); |
bosko001 | 5:c9a908749d4c | 57 | P_str( "FLASH MASK ", gps_rd->s_EthAdd.mask ); |
bosko001 | 5:c9a908749d4c | 58 | P_str( "FLASH GATE ", gps_rd->s_EthAdd.gate ); |
bosko001 | 5:c9a908749d4c | 59 | |
bosko001 | 5:c9a908749d4c | 60 | P_str( "FLASH UDP PORT ", gps_rd->serverPortUdp ); |
bosko001 | 5:c9a908749d4c | 61 | P_str( "FLASH TCP PORT ", gps_rd->serverPortTcp ); |
bosko001 | 5:c9a908749d4c | 62 | |
bosko001 | 5:c9a908749d4c | 63 | P_str( "FLASH UDP IP[0] ", gps_rd->s_EthAddRemUdp[0].ip ); |
bosko001 | 5:c9a908749d4c | 64 | P_int( "FLASH UDP PORT[0] ", gps_rd->s_EthAddRemUdp[0].port ); |
bosko001 | 5:c9a908749d4c | 65 | P_str( "FLASH TCP IP[0] ", gps_rd->s_EthAddRemTcp[0].ip ); |
bosko001 | 5:c9a908749d4c | 66 | P_int( "FLASH TCP PORT[0] ", gps_rd->s_EthAddRemTcp[0].port ); |
bosko001 | 5:c9a908749d4c | 67 | |
bosko001 | 5:c9a908749d4c | 68 | // P_int( "FLASH SERIAL BAUD ", gps_rd->baudRate ); |
bosko001 | 5:c9a908749d4c | 69 | // P_int( "FLASH SERIAL BAUD ", gps_rd->parity ); |
bosko001 | 5:c9a908749d4c | 70 | // P_int( "FLASH SERIAL BAUD ", gps_rd->dataBits ); |
bosko001 | 5:c9a908749d4c | 71 | // P_int( "FLASH SERIAL BAUD ", gps_rd->stopBits ); |
bosko001 | 5:c9a908749d4c | 72 | } |
bosko001 | 5:c9a908749d4c | 73 | |
bosko001 | 5:c9a908749d4c | 74 | |
bosko001 | 5:c9a908749d4c | 75 | |
bosko001 | 5:c9a908749d4c | 76 | void putHTMLintoFLASH( C_HTMLparse *pch ) |
bosko001 | 5:c9a908749d4c | 77 | { |
bosko001 | 5:c9a908749d4c | 78 | |
bosko001 | 5:c9a908749d4c | 79 | |
bosko001 | 5:c9a908749d4c | 80 | if( test_ip( pch->get_myIP( ) ) ) strncpy( gps_rd->s_EthAdd.ip, pch->get_myIP( ), 16 ); |
bosko001 | 5:c9a908749d4c | 81 | if( test_ip( pch->get_myMASK( ) ) ) strncpy( gps_rd->s_EthAdd.mask, pch->get_myMASK(), 16 ); |
bosko001 | 5:c9a908749d4c | 82 | if( test_ip( pch->get_myGATE( ) ) ) strncpy( gps_rd->s_EthAdd.gate, pch->get_myGATE(), 16 ); |
bosko001 | 5:c9a908749d4c | 83 | |
bosko001 | 5:c9a908749d4c | 84 | strncpy( gps_rd->serverPortUdp, pch->get_myUdpPort(), 6 ); |
bosko001 | 5:c9a908749d4c | 85 | strncpy( gps_rd->serverPortTcp, pch->get_myTcpPort(), 6 ); |
bosko001 | 5:c9a908749d4c | 86 | |
bosko001 | 5:c9a908749d4c | 87 | if( test_ip( pch->get_UdpIP(1) ) )strncpy( gps_rd->s_EthAddRemUdp[0].ip, pch->get_UdpIP(1), 16 ); |
bosko001 | 5:c9a908749d4c | 88 | gps_rd->s_EthAddRemUdp[0].port = atoi( pch->get_UdpPort(1) ); |
bosko001 | 5:c9a908749d4c | 89 | |
bosko001 | 5:c9a908749d4c | 90 | if( test_ip( pch->get_TcpIP(1) ) )strncpy( gps_rd->s_EthAddRemTcp[0].ip, pch->get_TcpIP(1), 16 ); |
bosko001 | 5:c9a908749d4c | 91 | gps_rd->s_EthAddRemTcp[0].port = atoi( pch->get_TcpPort(1) ); |
bosko001 | 5:c9a908749d4c | 92 | |
bosko001 | 5:c9a908749d4c | 93 | fillDataIntoFlash( ); |
bosko001 | 5:c9a908749d4c | 94 | } |
bosko001 | 5:c9a908749d4c | 95 | |
bosko001 | 5:c9a908749d4c | 96 | |
bosko001 | 5:c9a908749d4c | 97 | void putFLASHintoHTML( C_HTMLparse *pch ) |
bosko001 | 5:c9a908749d4c | 98 | { |
bosko001 | 5:c9a908749d4c | 99 | |
bosko001 | 5:c9a908749d4c | 100 | refreshDataFromFlash( ); |
bosko001 | 5:c9a908749d4c | 101 | |
bosko001 | 5:c9a908749d4c | 102 | if( test_ip( gps_rd->s_EthAdd.ip ) ) pch->set_myIP( gps_rd->s_EthAdd.ip ); |
bosko001 | 5:c9a908749d4c | 103 | if( test_ip( gps_rd->s_EthAdd.mask ) ) pch->set_myMASK( gps_rd->s_EthAdd.mask ); |
bosko001 | 5:c9a908749d4c | 104 | if( test_ip( gps_rd->s_EthAdd.gate ) ) pch->set_myGATE( gps_rd->s_EthAdd.gate ); |
bosko001 | 5:c9a908749d4c | 105 | |
bosko001 | 5:c9a908749d4c | 106 | if( test_num( gps_rd->serverPortUdp )) pch->set_myUdpPort(gps_rd->serverPortUdp); |
bosko001 | 5:c9a908749d4c | 107 | if( test_num( gps_rd->serverPortTcp )) pch->set_myTcpPort(gps_rd->serverPortTcp); |
bosko001 | 5:c9a908749d4c | 108 | |
bosko001 | 5:c9a908749d4c | 109 | if( test_ip( gps_rd->s_EthAddRemUdp[0].ip ) ) pch->set_UdpIP(1,gps_rd->s_EthAddRemUdp[0].ip); |
bosko001 | 5:c9a908749d4c | 110 | |
bosko001 | 5:c9a908749d4c | 111 | char port[10]; |
bosko001 | 5:c9a908749d4c | 112 | sprintf(port, "%d", gps_rd->s_EthAddRemUdp[0].port); |
bosko001 | 5:c9a908749d4c | 113 | pch->set_UdpPort( 1, port ); |
bosko001 | 5:c9a908749d4c | 114 | |
bosko001 | 5:c9a908749d4c | 115 | if( test_ip( gps_rd->s_EthAddRemTcp[0].ip ) ) pch->set_TcpIP(1, gps_rd->s_EthAddRemTcp[0].ip ); |
bosko001 | 5:c9a908749d4c | 116 | sprintf( port, "%d", gps_rd->s_EthAddRemTcp[0].port); |
bosko001 | 5:c9a908749d4c | 117 | pch->set_TcpPort( 1, port ); |
bosko001 | 5:c9a908749d4c | 118 | |
bosko001 | 5:c9a908749d4c | 119 | } |
bosko001 | 5:c9a908749d4c | 120 | |
bosko001 | 5:c9a908749d4c | 121 | |
bosko001 | 5:c9a908749d4c | 122 | |
bosko001 | 5:c9a908749d4c | 123 | |
bosko001 | 5:c9a908749d4c | 124 | |
bosko001 | 3:1196befeace0 | 125 | // |
bosko001 | 3:1196befeace0 | 126 | //struct S_EthernetAddress |
bosko001 | 3:1196befeace0 | 127 | //{ |
bosko001 | 3:1196befeace0 | 128 | // char ip[16]; |
bosko001 | 3:1196befeace0 | 129 | // char mask[16]; |
bosko001 | 3:1196befeace0 | 130 | // char gate[16]; |
bosko001 | 3:1196befeace0 | 131 | // // int port; |
bosko001 | 3:1196befeace0 | 132 | //}; |
bosko001 | 3:1196befeace0 | 133 | // |
bosko001 | 3:1196befeace0 | 134 | //struct S_EthernetAddress_Remote |
bosko001 | 3:1196befeace0 | 135 | //{ |
bosko001 | 3:1196befeace0 | 136 | // char ip[16]; |
bosko001 | 3:1196befeace0 | 137 | // int port; |
bosko001 | 3:1196befeace0 | 138 | //}; |
bosko001 | 3:1196befeace0 | 139 | // |
bosko001 | 3:1196befeace0 | 140 | //struct S_FlashData |
bosko001 | 3:1196befeace0 | 141 | //{ |
bosko001 | 3:1196befeace0 | 142 | // struct S_EthernetAddress s_EthAdd; |
bosko001 | 3:1196befeace0 | 143 | // char serverPortUdp[6]; |
bosko001 | 3:1196befeace0 | 144 | // char serverPortTcp[6]; |
bosko001 | 3:1196befeace0 | 145 | // struct S_EthernetAddress_Remote s_EthAddRemUdp[3]; |
bosko001 | 3:1196befeace0 | 146 | //// struct S_EthernetAddress_RangeRemote s_EthAddRangeRemUDP; |
bosko001 | 3:1196befeace0 | 147 | // struct S_EthernetAddress_Remote s_EthAddRemTcp[3]; |
bosko001 | 3:1196befeace0 | 148 | //// struct S_EthernetAddress_RangeRemote s_EthAddRangeRemTcp; |
bosko001 | 3:1196befeace0 | 149 | // int baudRate, parity, dataBits, stopBits; |
bosko001 | 3:1196befeace0 | 150 | //}; |
bosko001 | 3:1196befeace0 | 151 | // |
bosko001 | 3:1196befeace0 | 152 | //union U_FlashData |
bosko001 | 3:1196befeace0 | 153 | //{ |
bosko001 | 3:1196befeace0 | 154 | // struct S_FlashData s_flashData; |
bosko001 | 3:1196befeace0 | 155 | // char data[sizeof( struct S_FlashData )]; |
bosko001 | 5:c9a908749d4c | 156 | //}; |