bosko lekovic
/
EthToCom_11
nova proba
main.cpp@16:c4e0e8b4d8fc, 2020-05-03 (annotated)
- Committer:
- bosko001
- Date:
- Sun May 03 19:39:27 2020 +0200
- Revision:
- 16:c4e0e8b4d8fc
- Parent:
- 13:03617f6ed112
- Child:
- 18:5ee53205451a
lagano korigovan UDP
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" |
bosko001 | 2:45b351b4fc2a | 5 | #include "TcpServerToFlash.h" |
bosko001 | 2:45b351b4fc2a | 6 | #include "dxml.h" |
bosko001 | 2:45b351b4fc2a | 7 | #include "doHTML.h" |
bosko001 | 3:1196befeace0 | 8 | #include "dataFlash.h" |
bosko001 | 2:45b351b4fc2a | 9 | #include "string.h" |
bosko001 | 0:fe8cd064ea08 | 10 | |
bosko001 | 5:c9a908749d4c | 11 | |
bosko001 | 5:c9a908749d4c | 12 | |
bosko001 | 5:c9a908749d4c | 13 | |
bosko001 | 5:c9a908749d4c | 14 | |
bosko001 | 2:45b351b4fc2a | 15 | volatile PFV pfv = NULL; |
bosko001 | 1:e1bde4e82763 | 16 | |
bosko001 | 1:e1bde4e82763 | 17 | |
bosko001 | 2:45b351b4fc2a | 18 | DigitalOut GLed(LED2,1); |
bosko001 | 1:e1bde4e82763 | 19 | |
bosko001 | 2:45b351b4fc2a | 20 | void pfv_fun( void ) |
bosko001 | 1:e1bde4e82763 | 21 | { |
bosko001 | 2:45b351b4fc2a | 22 | while(true) |
bosko001 | 2:45b351b4fc2a | 23 | { |
bosko001 | 2:45b351b4fc2a | 24 | if(pfv) {pfv(); pfv = NULL;} |
bosko001 | 2:45b351b4fc2a | 25 | cleanTcpServerToFlashThread( ); |
bosko001 | 2:45b351b4fc2a | 26 | |
bosko001 | 2:45b351b4fc2a | 27 | } |
bosko001 | 1:e1bde4e82763 | 28 | } |
bosko001 | 2:45b351b4fc2a | 29 | Thread pfv_thread(pfv_fun); |
bosko001 | 1:e1bde4e82763 | 30 | |
bosko001 | 7:7ea932eb31f6 | 31 | |
bosko001 | 7:7ea932eb31f6 | 32 | void input_fun( void ) |
bosko001 | 7:7ea932eb31f6 | 33 | { |
bosko001 | 7:7ea932eb31f6 | 34 | while(true) |
bosko001 | 7:7ea932eb31f6 | 35 | { |
bosko001 | 7:7ea932eb31f6 | 36 | unsigned char uc; |
bosko001 | 7:7ea932eb31f6 | 37 | uc = (unsigned char)getchar( ); |
bosko001 | 7:7ea932eb31f6 | 38 | printf( "\n\runesen karakter %c\n\r", uc); |
bosko001 | 7:7ea932eb31f6 | 39 | if( uc == 'h' ) |
bosko001 | 7:7ea932eb31f6 | 40 | { |
bosko001 | 7:7ea932eb31f6 | 41 | extern C_HTMLparse *gpc_html; |
bosko001 | 7:7ea932eb31f6 | 42 | auto c = gpc_html->getHTML_free( ); |
bosko001 | 7:7ea932eb31f6 | 43 | printf("\n\r%s\n\r", c); |
bosko001 | 7:7ea932eb31f6 | 44 | free(c); |
bosko001 | 7:7ea932eb31f6 | 45 | |
bosko001 | 7:7ea932eb31f6 | 46 | } |
bosko001 | 7:7ea932eb31f6 | 47 | } |
bosko001 | 7:7ea932eb31f6 | 48 | } |
bosko001 | 7:7ea932eb31f6 | 49 | Thread input_thread(input_fun); |
bosko001 | 7:7ea932eb31f6 | 50 | |
bosko001 | 7:7ea932eb31f6 | 51 | |
bosko001 | 5:c9a908749d4c | 52 | C_HTMLparse *gpc_html; |
bosko001 | 7:7ea932eb31f6 | 53 | |
bosko001 | 7:7ea932eb31f6 | 54 | |
bosko001 | 7:7ea932eb31f6 | 55 | |
bosko001 | 7:7ea932eb31f6 | 56 | |
bosko001 | 0:fe8cd064ea08 | 57 | |
bosko001 | 0:fe8cd064ea08 | 58 | int main(void) |
bosko001 | 0:fe8cd064ea08 | 59 | { |
bosko001 | 1:e1bde4e82763 | 60 | |
bosko001 | 2:45b351b4fc2a | 61 | printf("\n\r---------- POCETAK ------------- \n\r"); |
bosko001 | 3:1196befeace0 | 62 | |
bosko001 | 3:1196befeace0 | 63 | init_FlashData( ); |
bosko001 | 3:1196befeace0 | 64 | |
bosko001 | 5:c9a908749d4c | 65 | gpc_html = new C_HTMLparse; |
bosko001 | 3:1196befeace0 | 66 | |
bosko001 | 12:cbfc10c15437 | 67 | |
bosko001 | 13:03617f6ed112 | 68 | putHTMLintoFLASH( gpc_html ); |
bosko001 | 5:c9a908749d4c | 69 | putFLASHintoHTML( gpc_html ); |
bosko001 | 13:03617f6ed112 | 70 | showFlashData( ); |
bosko001 | 3:1196befeace0 | 71 | |
bosko001 | 1:e1bde4e82763 | 72 | |
bosko001 | 12:cbfc10c15437 | 73 | // init_EthToScom( ); |
bosko001 | 12:cbfc10c15437 | 74 | |
bosko001 | 12:cbfc10c15437 | 75 | extern EthernetInterface *gp_eth; |
bosko001 | 12:cbfc10c15437 | 76 | |
bosko001 | 16:c4e0e8b4d8fc | 77 | init_EthToScom( ); |
bosko001 | 16:c4e0e8b4d8fc | 78 | |
bosko001 | 16:c4e0e8b4d8fc | 79 | // gp_eth = ethernet_setup( ); |
bosko001 | 16:c4e0e8b4d8fc | 80 | inic_TcpServerToFlash( ); |
bosko001 | 12:cbfc10c15437 | 81 | |
bosko001 | 16:c4e0e8b4d8fc | 82 | // if(gp_eth == NULL) printf("ethernet greska\n\r"); |
bosko001 | 16:c4e0e8b4d8fc | 83 | // else |
bosko001 | 16:c4e0e8b4d8fc | 84 | // { |
bosko001 | 16:c4e0e8b4d8fc | 85 | // printf("eth OK\n\r"); |
bosko001 | 16:c4e0e8b4d8fc | 86 | // scomRxThreadRiseUp( ); |
bosko001 | 16:c4e0e8b4d8fc | 87 | // udpRxThreadRiseUp( ); |
bosko001 | 11:2cc7e6f06cff | 88 | |
bosko001 | 16:c4e0e8b4d8fc | 89 | // //#if NO_UDP <= 1 |
bosko001 | 16:c4e0e8b4d8fc | 90 | // inic_TcpServerToFlash( ); |
bosko001 | 16:c4e0e8b4d8fc | 91 | // //#endif |
bosko001 | 16:c4e0e8b4d8fc | 92 | // } |
bosko001 | 12:cbfc10c15437 | 93 | |
bosko001 | 4:7abcf4543282 | 94 | extern void test_HTML(void); |
bosko001 | 12:cbfc10c15437 | 95 | // test_HTML( ); |
bosko001 | 4:7abcf4543282 | 96 | |
bosko001 | 2:45b351b4fc2a | 97 | |
bosko001 | 2:45b351b4fc2a | 98 | int i=0; |
bosko001 | 2:45b351b4fc2a | 99 | while(true) |
bosko001 | 2:45b351b4fc2a | 100 | { |
bosko001 | 2:45b351b4fc2a | 101 | if(i++ >10 ) { i=0; GLed = !GLed;} |
bosko001 | 2:45b351b4fc2a | 102 | wait(0.01); |
bosko001 | 0:fe8cd064ea08 | 103 | } |
bosko001 | 3:1196befeace0 | 104 | |
bosko001 | 3:1196befeace0 | 105 | deinit_FlashData( ); |
bosko001 | 3:1196befeace0 | 106 | |
bosko001 | 3:1196befeace0 | 107 | |
bosko001 | 0:fe8cd064ea08 | 108 | } |
bosko001 | 0:fe8cd064ea08 | 109 | |
bosko001 | 1:e1bde4e82763 | 110 | |
bosko001 | 2:45b351b4fc2a | 111 | |
bosko001 | 2:45b351b4fc2a | 112 | |
bosko001 | 2:45b351b4fc2a | 113 | |
bosko001 | 1:e1bde4e82763 | 114 | |
bosko001 | 1:e1bde4e82763 | 115 | |
bosko001 | 1:e1bde4e82763 | 116 | |
bosko001 | 0:fe8cd064ea08 | 117 | // |
bosko001 | 0:fe8cd064ea08 | 118 | //enum nsapi_error { |
bosko001 | 0:fe8cd064ea08 | 119 | // NSAPI_ERROR_OK = 0, /*!< no error */ |
bosko001 | 0:fe8cd064ea08 | 120 | // NSAPI_ERROR_WOULD_BLOCK = -3001, /*!< no data is not available but call is non-blocking */ |
bosko001 | 0:fe8cd064ea08 | 121 | // NSAPI_ERROR_UNSUPPORTED = -3002, /*!< unsupported functionality */ |
bosko001 | 0:fe8cd064ea08 | 122 | // NSAPI_ERROR_PARAMETER = -3003, /*!< invalid configuration */ |
bosko001 | 0:fe8cd064ea08 | 123 | // NSAPI_ERROR_NO_CONNECTION = -3004, /*!< not connected to a network */ |
bosko001 | 0:fe8cd064ea08 | 124 | // NSAPI_ERROR_NO_SOCKET = -3005, /*!< socket not available for use */ |
bosko001 | 0:fe8cd064ea08 | 125 | // NSAPI_ERROR_NO_ADDRESS = -3006, /*!< IP address is not known */ |
bosko001 | 0:fe8cd064ea08 | 126 | // NSAPI_ERROR_NO_MEMORY = -3007, /*!< memory resource not available */ |
bosko001 | 0:fe8cd064ea08 | 127 | // NSAPI_ERROR_NO_SSID = -3008, /*!< ssid not found */ |
bosko001 | 0:fe8cd064ea08 | 128 | // NSAPI_ERROR_DNS_FAILURE = -3009, /*!< DNS failed to complete successfully */ |
bosko001 | 0:fe8cd064ea08 | 129 | // NSAPI_ERROR_DHCP_FAILURE = -3010, /*!< DHCP failed to complete successfully */ |
bosko001 | 0:fe8cd064ea08 | 130 | // NSAPI_ERROR_AUTH_FAILURE = -3011, /*!< connection to access point failed */ |
bosko001 | 0:fe8cd064ea08 | 131 | // NSAPI_ERROR_DEVICE_ERROR = -3012, /*!< failure interfacing with the network processor */ |
bosko001 | 0:fe8cd064ea08 | 132 | // NSAPI_ERROR_IN_PROGRESS = -3013, /*!< operation (eg connect) in progress */ |
bosko001 | 0:fe8cd064ea08 | 133 | // NSAPI_ERROR_ALREADY = -3014, /*!< operation (eg connect) already in progress */ |
bosko001 | 0:fe8cd064ea08 | 134 | // NSAPI_ERROR_IS_CONNECTED = -3015, /*!< socket is already connected */ |
bosko001 | 0:fe8cd064ea08 | 135 | // NSAPI_ERROR_CONNECTION_LOST = -3016, /*!< connection lost */ |
bosko001 | 0:fe8cd064ea08 | 136 | // NSAPI_ERROR_CONNECTION_TIMEOUT = -3017, /*!< connection timed out */ |
bosko001 | 0:fe8cd064ea08 | 137 | //}; |