bosko lekovic
/
EthToCom_11
nova proba
main.cpp@18:5ee53205451a, 2020-05-17 (annotated)
- Committer:
- Bosko Lekovic
- Date:
- Sun May 17 17:16:03 2020 +0200
- Revision:
- 18:5ee53205451a
- Parent:
- 16:c4e0e8b4d8fc
- Child:
- 19:7bdb1a10043f
udp i serial zakomentarisani
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bosko001 | 0:fe8cd064ea08 | 1 | #include "mbed.h" |
bosko001 | 2:45b351b4fc2a | 2 | #include "clubbing.h" |
bosko001 | 2:45b351b4fc2a | 3 | #include "EthernetSetup.h" |
bosko001 | 2:45b351b4fc2a | 4 | #include "UdpToScom.h" |
Bosko Lekovic |
18:5ee53205451a | 5 | #include "TcpClients.h" |
bosko001 | 2:45b351b4fc2a | 6 | #include "TcpServerToFlash.h" |
bosko001 | 2:45b351b4fc2a | 7 | #include "dxml.h" |
bosko001 | 2:45b351b4fc2a | 8 | #include "doHTML.h" |
bosko001 | 3:1196befeace0 | 9 | #include "dataFlash.h" |
bosko001 | 2:45b351b4fc2a | 10 | #include "string.h" |
bosko001 | 0:fe8cd064ea08 | 11 | |
bosko001 | 5:c9a908749d4c | 12 | |
bosko001 | 5:c9a908749d4c | 13 | |
bosko001 | 5:c9a908749d4c | 14 | |
bosko001 | 5:c9a908749d4c | 15 | |
bosko001 | 2:45b351b4fc2a | 16 | volatile PFV pfv = NULL; |
bosko001 | 1:e1bde4e82763 | 17 | |
bosko001 | 1:e1bde4e82763 | 18 | |
bosko001 | 2:45b351b4fc2a | 19 | DigitalOut GLed(LED2,1); |
bosko001 | 1:e1bde4e82763 | 20 | |
bosko001 | 2:45b351b4fc2a | 21 | void pfv_fun( void ) |
bosko001 | 1:e1bde4e82763 | 22 | { |
bosko001 | 2:45b351b4fc2a | 23 | while(true) |
bosko001 | 2:45b351b4fc2a | 24 | { |
bosko001 | 2:45b351b4fc2a | 25 | if(pfv) {pfv(); pfv = NULL;} |
bosko001 | 2:45b351b4fc2a | 26 | cleanTcpServerToFlashThread( ); |
bosko001 | 2:45b351b4fc2a | 27 | |
bosko001 | 2:45b351b4fc2a | 28 | } |
bosko001 | 1:e1bde4e82763 | 29 | } |
Bosko Lekovic |
18:5ee53205451a | 30 | Thread pfv_thread(pfv_fun, osPriorityNormal, 1000); |
bosko001 | 1:e1bde4e82763 | 31 | |
bosko001 | 7:7ea932eb31f6 | 32 | |
bosko001 | 7:7ea932eb31f6 | 33 | void input_fun( void ) |
bosko001 | 7:7ea932eb31f6 | 34 | { |
bosko001 | 7:7ea932eb31f6 | 35 | while(true) |
bosko001 | 7:7ea932eb31f6 | 36 | { |
bosko001 | 7:7ea932eb31f6 | 37 | unsigned char uc; |
Bosko Lekovic |
18:5ee53205451a | 38 | int fltip, kanal, fleg; |
bosko001 | 7:7ea932eb31f6 | 39 | uc = (unsigned char)getchar( ); |
bosko001 | 7:7ea932eb31f6 | 40 | printf( "\n\runesen karakter %c\n\r", uc); |
Bosko Lekovic |
18:5ee53205451a | 41 | |
Bosko Lekovic |
18:5ee53205451a | 42 | switch( uc ) |
bosko001 | 7:7ea932eb31f6 | 43 | { |
Bosko Lekovic |
18:5ee53205451a | 44 | case 'h': |
Bosko Lekovic |
18:5ee53205451a | 45 | { |
bosko001 | 7:7ea932eb31f6 | 46 | extern C_HTMLparse *gpc_html; |
bosko001 | 7:7ea932eb31f6 | 47 | auto c = gpc_html->getHTML_free( ); |
bosko001 | 7:7ea932eb31f6 | 48 | printf("\n\r%s\n\r", c); |
bosko001 | 7:7ea932eb31f6 | 49 | free(c); |
Bosko Lekovic |
18:5ee53205451a | 50 | } |
Bosko Lekovic |
18:5ee53205451a | 51 | break; |
Bosko Lekovic |
18:5ee53205451a | 52 | case 'c': |
Bosko Lekovic |
18:5ee53205451a | 53 | fltip = 1; |
Bosko Lekovic |
18:5ee53205451a | 54 | break; |
Bosko Lekovic |
18:5ee53205451a | 55 | case 'f': |
Bosko Lekovic |
18:5ee53205451a | 56 | fltip = 2; |
Bosko Lekovic |
18:5ee53205451a | 57 | break; |
Bosko Lekovic |
18:5ee53205451a | 58 | case '0': case '1': case '2': case '3': |
Bosko Lekovic |
18:5ee53205451a | 59 | if(fltip == 1) kanal = uc - '0'; |
Bosko Lekovic |
18:5ee53205451a | 60 | else fleg = uc - '0'; |
Bosko Lekovic |
18:5ee53205451a | 61 | break; |
Bosko Lekovic |
18:5ee53205451a | 62 | case 'd': |
Bosko Lekovic |
18:5ee53205451a | 63 | { |
Bosko Lekovic |
18:5ee53205451a | 64 | // extern void tcpRxThreadCancel( int i, int flag); |
Bosko Lekovic |
18:5ee53205451a | 65 | // tcpRxThreadCancel( kanal, fleg ); |
Bosko Lekovic |
18:5ee53205451a | 66 | printf(" komanda za tred[%d] fleg=%d\n\r", kanal, fleg); |
Bosko Lekovic |
18:5ee53205451a | 67 | } |
Bosko Lekovic |
18:5ee53205451a | 68 | break; |
Bosko Lekovic |
18:5ee53205451a | 69 | case 'S': |
Bosko Lekovic |
18:5ee53205451a | 70 | { |
Bosko Lekovic |
18:5ee53205451a | 71 | extern void _semafor_release(void ); |
Bosko Lekovic |
18:5ee53205451a | 72 | _semafor_release(); |
Bosko Lekovic |
18:5ee53205451a | 73 | } |
Bosko Lekovic |
18:5ee53205451a | 74 | break; |
Bosko Lekovic |
18:5ee53205451a | 75 | case 'T': |
Bosko Lekovic |
18:5ee53205451a | 76 | inic_TcpServerToFlash( ); |
Bosko Lekovic |
18:5ee53205451a | 77 | break; |
Bosko Lekovic |
18:5ee53205451a | 78 | case 'R': |
Bosko Lekovic |
18:5ee53205451a | 79 | printf("systemInit()\n\r"); |
Bosko Lekovic |
18:5ee53205451a | 80 | SystemInit(); |
Bosko Lekovic |
18:5ee53205451a | 81 | //goto __main; |
Bosko Lekovic |
18:5ee53205451a | 82 | break; |
bosko001 | 7:7ea932eb31f6 | 83 | } |
bosko001 | 7:7ea932eb31f6 | 84 | } |
bosko001 | 7:7ea932eb31f6 | 85 | } |
Bosko Lekovic |
18:5ee53205451a | 86 | Thread input_thread(input_fun, osPriorityNormal, 1000); |
bosko001 | 7:7ea932eb31f6 | 87 | |
bosko001 | 7:7ea932eb31f6 | 88 | |
bosko001 | 5:c9a908749d4c | 89 | C_HTMLparse *gpc_html; |
bosko001 | 7:7ea932eb31f6 | 90 | |
bosko001 | 7:7ea932eb31f6 | 91 | |
Bosko Lekovic |
18:5ee53205451a | 92 | |
bosko001 | 0:fe8cd064ea08 | 93 | |
bosko001 | 0:fe8cd064ea08 | 94 | int main(void) |
bosko001 | 0:fe8cd064ea08 | 95 | { |
bosko001 | 1:e1bde4e82763 | 96 | |
Bosko Lekovic |
18:5ee53205451a | 97 | printf("\n\r\n\n---------- POCETAK ------------- \n\n\r"); |
bosko001 | 3:1196befeace0 | 98 | |
bosko001 | 3:1196befeace0 | 99 | init_FlashData( ); |
bosko001 | 3:1196befeace0 | 100 | |
bosko001 | 5:c9a908749d4c | 101 | gpc_html = new C_HTMLparse; |
Bosko Lekovic |
18:5ee53205451a | 102 | C_HTMLparse *p_temp_html = new C_HTMLparse; |
bosko001 | 3:1196befeace0 | 103 | |
Bosko Lekovic |
18:5ee53205451a | 104 | // PROVERA KONZISTENCIJE FLASH PODATAKA |
Bosko Lekovic |
18:5ee53205451a | 105 | putFLASHintoHTML( p_temp_html ); |
bosko001 | 12:cbfc10c15437 | 106 | |
Bosko Lekovic |
18:5ee53205451a | 107 | if( test_FlashDataProbity( )) |
Bosko Lekovic |
18:5ee53205451a | 108 | { |
Bosko Lekovic |
18:5ee53205451a | 109 | printf( "MAIN: dobri Flash podaci\n\r"); |
Bosko Lekovic |
18:5ee53205451a | 110 | putFLASHintoHTML( gpc_html ); |
Bosko Lekovic |
18:5ee53205451a | 111 | } |
Bosko Lekovic |
18:5ee53205451a | 112 | else |
Bosko Lekovic |
18:5ee53205451a | 113 | { |
Bosko Lekovic |
18:5ee53205451a | 114 | printf("MAIN: losi FLASH podaci\n\r"); |
Bosko Lekovic |
18:5ee53205451a | 115 | putHTMLintoFLASH( gpc_html ); |
Bosko Lekovic |
18:5ee53205451a | 116 | putFLASHintoHTML( gpc_html ); |
Bosko Lekovic |
18:5ee53205451a | 117 | } |
Bosko Lekovic |
18:5ee53205451a | 118 | delete p_temp_html; |
Bosko Lekovic |
18:5ee53205451a | 119 | |
Bosko Lekovic |
18:5ee53205451a | 120 | // showFlashData( ); |
bosko001 | 3:1196befeace0 | 121 | |
bosko001 | 1:e1bde4e82763 | 122 | |
bosko001 | 12:cbfc10c15437 | 123 | // init_EthToScom( ); |
bosko001 | 12:cbfc10c15437 | 124 | |
bosko001 | 12:cbfc10c15437 | 125 | extern EthernetInterface *gp_eth; |
bosko001 | 12:cbfc10c15437 | 126 | |
bosko001 | 16:c4e0e8b4d8fc | 127 | init_EthToScom( ); |
Bosko Lekovic |
18:5ee53205451a | 128 | tcpRxThreadsRiseUp( ); |
bosko001 | 16:c4e0e8b4d8fc | 129 | |
bosko001 | 16:c4e0e8b4d8fc | 130 | // gp_eth = ethernet_setup( ); |
bosko001 | 16:c4e0e8b4d8fc | 131 | inic_TcpServerToFlash( ); |
bosko001 | 12:cbfc10c15437 | 132 | |
bosko001 | 16:c4e0e8b4d8fc | 133 | // if(gp_eth == NULL) printf("ethernet greska\n\r"); |
bosko001 | 16:c4e0e8b4d8fc | 134 | // else |
bosko001 | 16:c4e0e8b4d8fc | 135 | // { |
bosko001 | 16:c4e0e8b4d8fc | 136 | // printf("eth OK\n\r"); |
bosko001 | 16:c4e0e8b4d8fc | 137 | // scomRxThreadRiseUp( ); |
bosko001 | 16:c4e0e8b4d8fc | 138 | // udpRxThreadRiseUp( ); |
bosko001 | 11:2cc7e6f06cff | 139 | |
bosko001 | 16:c4e0e8b4d8fc | 140 | // //#if NO_UDP <= 1 |
bosko001 | 16:c4e0e8b4d8fc | 141 | // inic_TcpServerToFlash( ); |
bosko001 | 16:c4e0e8b4d8fc | 142 | // //#endif |
bosko001 | 16:c4e0e8b4d8fc | 143 | // } |
bosko001 | 12:cbfc10c15437 | 144 | |
bosko001 | 4:7abcf4543282 | 145 | extern void test_HTML(void); |
bosko001 | 12:cbfc10c15437 | 146 | // test_HTML( ); |
bosko001 | 4:7abcf4543282 | 147 | |
bosko001 | 2:45b351b4fc2a | 148 | |
bosko001 | 2:45b351b4fc2a | 149 | int i=0; |
bosko001 | 2:45b351b4fc2a | 150 | while(true) |
bosko001 | 2:45b351b4fc2a | 151 | { |
bosko001 | 2:45b351b4fc2a | 152 | if(i++ >10 ) { i=0; GLed = !GLed;} |
bosko001 | 2:45b351b4fc2a | 153 | wait(0.01); |
bosko001 | 0:fe8cd064ea08 | 154 | } |
bosko001 | 3:1196befeace0 | 155 | |
Bosko Lekovic |
18:5ee53205451a | 156 | // deinit_FlashData( ); |
bosko001 | 3:1196befeace0 | 157 | |
bosko001 | 3:1196befeace0 | 158 | |
bosko001 | 0:fe8cd064ea08 | 159 | } |
bosko001 | 0:fe8cd064ea08 | 160 | |
bosko001 | 1:e1bde4e82763 | 161 | |
bosko001 | 2:45b351b4fc2a | 162 | |
bosko001 | 2:45b351b4fc2a | 163 | |
bosko001 | 2:45b351b4fc2a | 164 | |
bosko001 | 1:e1bde4e82763 | 165 | |
bosko001 | 1:e1bde4e82763 | 166 | |
bosko001 | 1:e1bde4e82763 | 167 | |
bosko001 | 0:fe8cd064ea08 | 168 | // |
bosko001 | 0:fe8cd064ea08 | 169 | //enum nsapi_error { |
bosko001 | 0:fe8cd064ea08 | 170 | // NSAPI_ERROR_OK = 0, /*!< no error */ |
bosko001 | 0:fe8cd064ea08 | 171 | // NSAPI_ERROR_WOULD_BLOCK = -3001, /*!< no data is not available but call is non-blocking */ |
bosko001 | 0:fe8cd064ea08 | 172 | // NSAPI_ERROR_UNSUPPORTED = -3002, /*!< unsupported functionality */ |
bosko001 | 0:fe8cd064ea08 | 173 | // NSAPI_ERROR_PARAMETER = -3003, /*!< invalid configuration */ |
bosko001 | 0:fe8cd064ea08 | 174 | // NSAPI_ERROR_NO_CONNECTION = -3004, /*!< not connected to a network */ |
bosko001 | 0:fe8cd064ea08 | 175 | // NSAPI_ERROR_NO_SOCKET = -3005, /*!< socket not available for use */ |
bosko001 | 0:fe8cd064ea08 | 176 | // NSAPI_ERROR_NO_ADDRESS = -3006, /*!< IP address is not known */ |
bosko001 | 0:fe8cd064ea08 | 177 | // NSAPI_ERROR_NO_MEMORY = -3007, /*!< memory resource not available */ |
bosko001 | 0:fe8cd064ea08 | 178 | // NSAPI_ERROR_NO_SSID = -3008, /*!< ssid not found */ |
bosko001 | 0:fe8cd064ea08 | 179 | // NSAPI_ERROR_DNS_FAILURE = -3009, /*!< DNS failed to complete successfully */ |
bosko001 | 0:fe8cd064ea08 | 180 | // NSAPI_ERROR_DHCP_FAILURE = -3010, /*!< DHCP failed to complete successfully */ |
bosko001 | 0:fe8cd064ea08 | 181 | // NSAPI_ERROR_AUTH_FAILURE = -3011, /*!< connection to access point failed */ |
bosko001 | 0:fe8cd064ea08 | 182 | // NSAPI_ERROR_DEVICE_ERROR = -3012, /*!< failure interfacing with the network processor */ |
bosko001 | 0:fe8cd064ea08 | 183 | // NSAPI_ERROR_IN_PROGRESS = -3013, /*!< operation (eg connect) in progress */ |
bosko001 | 0:fe8cd064ea08 | 184 | // NSAPI_ERROR_ALREADY = -3014, /*!< operation (eg connect) already in progress */ |
bosko001 | 0:fe8cd064ea08 | 185 | // NSAPI_ERROR_IS_CONNECTED = -3015, /*!< socket is already connected */ |
bosko001 | 0:fe8cd064ea08 | 186 | // NSAPI_ERROR_CONNECTION_LOST = -3016, /*!< connection lost */ |
bosko001 | 0:fe8cd064ea08 | 187 | // NSAPI_ERROR_CONNECTION_TIMEOUT = -3017, /*!< connection timed out */ |
bosko001 | 0:fe8cd064ea08 | 188 | //}; |