Forum Discussion
Altera_Forum
Honored Contributor
13 years ago --- Quote Start --- Hello, I managed to run the web server example and it works! However, I need to ask you if there is any way that I can send from FPGA to the webpage. In fact, using the webpage, I can write on the LCD, or light the leds ... What i need is the other way around, from fpga to the webpage.. --- Quote End --- Congratulations on getting the Web Server running! That's a BIG step in the right direction. I presume when you ask about sending data from the FPGA to the Web page that you are talking about dynamic data, or perhaps local variables such as IP address, etc. Sending HTML pages is nothing more than sending text, it just includes HTML code as part of the text string. The trick is inserting dynamic (variable) data into the text stream on-the-fly. I'm using the C programming sprintf() function to replace format "wildcards" in a text string with program variables. If you're not familiar with it, sprintf() is just like printf() except that instead of printing to a screen or terminal, it prints to a buffer. To demonstrate this, include the attached ip_config.c and ip_config.h files into your webserver project, and add the following code segment (between the 'Fred's') to http.c http_find_file() function: /* Try to open the file */ printf("\nFetching file: %s.\n\n", filename ); /***** Added by Fred *****/ if (!strcmp(IP_CONFIG_FILE,conn->uri)) { Get_IP_Config(sendbuff); // Call routine to update IP and Host information in HTML format send(conn->fd,(void*)sendbuff,strlen(sendbuff),0); // Send Status XML page conn->state = RESET; // Then reset the connection return -1; // and bail out fo this process } /***** End Fred *****/ conn->file_handle = fopen(filename, "r"); You will also need to include ip_config.h in your http.c file. The way this works is by hijacking the http.c http_find_file() function to look for 'ip.html' after the IP address before it tries to find any of the files in the ro_zipfs.zip that are hard-coded and cannot be changed on-the-fly. You may need to change some of the variable names in the attached files to match your BSP, but it should work. (I'll be eagerly waiting to hear.) (please note that i am not an experienced "c" programmer, so there may be more elegant ways of doing this. this will get you started, then you can experiment from there.) --- Quote Start --- And another thing is that the IP address assigned to the board and used to control the board remotely is local and I can only access it if I am within the domain of my router. What are my options if I want someone outside my router to have access to the board other than getting a real IP? --- Quote End --- AsValdr is on the right track. Most routers have a default IP Address of 192.168.1.1 that will call up a web page in your browser for setting the configuration. You want to configure http port forwarding for the MAC address of your system. You can also assign FTP and telnet to your system this way. Each requires a separate port-forwarding assignment. Check your router documentation for the specifics. I have a couple systems set up that way and they work great.