nova proba

Committer:
bosko001
Date:
Fri May 01 23:15:28 2020 +0000
Revision:
12:cbfc10c15437
Parent:
11:2cc7e6f06cff
Child:
13:03617f6ed112
popravljeno

Who changed what in which revision?

UserRevisionLine numberNew 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 showFlashData( );
bosko001 3:1196befeace0 65
bosko001 5:c9a908749d4c 66 gpc_html = new C_HTMLparse;
bosko001 3:1196befeace0 67
bosko001 12:cbfc10c15437 68 // auto c = gpc_html->getHTML_free( ); // konvertovanje HTMLa u niz
bosko001 12:cbfc10c15437 69 // printf("\n\r HTML:\n\n %s\n\rduzina = %d", c, strlen(c)); // slanje HTML-a
bosko001 12:cbfc10c15437 70 // free(c); // oslobadjanje memorije HTML niza
bosko001 12:cbfc10c15437 71
bosko001 5:c9a908749d4c 72 // putHTMLintoFLASH( gpc_html );
bosko001 5:c9a908749d4c 73 putFLASHintoHTML( gpc_html );
bosko001 3:1196befeace0 74
bosko001 1:e1bde4e82763 75
bosko001 12:cbfc10c15437 76 // init_EthToScom( );
bosko001 12:cbfc10c15437 77
bosko001 12:cbfc10c15437 78 extern EthernetInterface *gp_eth;
bosko001 12:cbfc10c15437 79
bosko001 12:cbfc10c15437 80 gp_eth = ethernet_setup( );
bosko001 12:cbfc10c15437 81
bosko001 12:cbfc10c15437 82 if(gp_eth == NULL) printf("ethernet greska\n\r");
bosko001 12:cbfc10c15437 83 else
bosko001 12:cbfc10c15437 84 {
bosko001 12:cbfc10c15437 85 printf("eth OK\n\r");
bosko001 12:cbfc10c15437 86 scomRxThreadRiseUp( );
bosko001 12:cbfc10c15437 87 udpRxThreadRiseUp( );
bosko001 11:2cc7e6f06cff 88
bosko001 11:2cc7e6f06cff 89 #if NO_UDP <= 1
bosko001 2:45b351b4fc2a 90 inic_TcpServerToFlash( );
bosko001 11:2cc7e6f06cff 91 #endif
bosko001 12:cbfc10c15437 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 //};