Speed up Webserver demo data rate by not sending a full ethernet frame each time...
authorDean Camera <dean@fourwalledcubicle.com>
Fri, 12 Feb 2010 07:54:28 +0000 (07:54 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Fri, 12 Feb 2010 07:54:28 +0000 (07:54 +0000)
Projects/Webserver/Lib/FATFs/diskio.c
Projects/Webserver/Lib/FATFs/diskio.h
Projects/Webserver/Lib/HTTPServerApp.c
Projects/Webserver/Lib/TELNETServerApp.c
Projects/Webserver/Lib/uip/uipopt.h
Projects/Webserver/Webserver.txt
Projects/Webserver/makefile

index c7c837b..028c631 100644 (file)
@@ -62,31 +62,3 @@ DRESULT disk_write (
        return RES_OK;\r
 }\r
 #endif /* _READONLY */\r
        return RES_OK;\r
 }\r
 #endif /* _READONLY */\r
-\r
-\r
-\r
-/*-----------------------------------------------------------------------*/\r
-/* Miscellaneous Functions                                               */\r
-\r
-DRESULT disk_ioctl (\r
-       BYTE drv,               /* Physical drive nmuber (0..) */\r
-       BYTE ctrl,              /* Control code */\r
-       void *buff              /* Buffer to send/receive control data */\r
-)\r
-{\r
-       if (ctrl == CTRL_SYNC)\r
-         return RES_OK;\r
-       else\r
-         return RES_PARERR;\r
-}\r
-\r
-\r
-DWORD get_fattime (void)\r
-{\r
-       return ((DWORD)1 << 25) |\r
-              ((DWORD)1 << 21) |\r
-              ((DWORD)1 << 16) |\r
-              ((DWORD)1 << 11) |\r
-              ((DWORD)1 << 5)  |\r
-              ((DWORD)1 << 0);\r
-}\r
index 3df93ae..2f444f7 100644 (file)
@@ -5,7 +5,7 @@
 #ifndef _DISKIO\r
 \r
 #define _READONLY      0       /* 1: Read-only mode */\r
 #ifndef _DISKIO\r
 \r
 #define _READONLY      0       /* 1: Read-only mode */\r
-#define _USE_IOCTL     1\r
+#define _USE_IOCTL     0\r
 \r
 #include "integer.h"\r
 #include "ff.h"\r
 \r
 #include "integer.h"\r
 #include "ff.h"\r
index e781beb..0d0cbb9 100644 (file)
@@ -31,7 +31,7 @@
 /** \file\r
  *\r
  *  Simple HTTP Webserver Application. When connected to the uIP stack,\r
 /** \file\r
  *\r
  *  Simple HTTP Webserver Application. When connected to the uIP stack,\r
- *  this will serve out files to HTTP clients.\r
+ *  this will serve out files to HTTP clients on port 80.\r
  */\r
  \r
 #define  INCLUDE_FROM_HTTPSERVERAPP_C\r
  */\r
  \r
 #define  INCLUDE_FROM_HTTPSERVERAPP_C\r
@@ -270,8 +270,12 @@ static void HTTPServerApp_SendData(void)
        uip_tcp_appstate_t* const AppState    = &uip_conn->appstate;\r
        char*               const AppData     = (char*)uip_appdata;\r
 \r
        uip_tcp_appstate_t* const AppState    = &uip_conn->appstate;\r
        char*               const AppData     = (char*)uip_appdata;\r
 \r
-       /* Must determine the maximum segment size to determine maximum file chunk size */\r
-       uint16_t MaxSegmentSize = uip_mss();\r
+       /* Must determine the maximum segment size to determine maximum file chunk size - never send a completely\r
+        * full packet, as this will cause some hosts to start delaying ACKs until a non-full packet is received.\r
+        * since uIP only allows one packet to be in transit at a time, this would cause long delays between packets\r
+        * until the host times out and sends the ACK for the last received packet.\r
+        */\r
+       uint16_t MaxSegmentSize = (uip_mss() >> 1);\r
 \r
        /* Return file pointer to the last ACKed position */\r
        f_lseek(&AppState->HTTPServer.FileHandle, AppState->HTTPServer.ACKedFilePos);\r
 \r
        /* Return file pointer to the last ACKed position */\r
        f_lseek(&AppState->HTTPServer.FileHandle, AppState->HTTPServer.ACKedFilePos);\r
index 7d8c907..2abd7b0 100644 (file)
@@ -31,7 +31,7 @@
 /** \file\r
  *\r
  *  TELNET Webserver Application. When connected to the uIP stack,\r
 /** \file\r
  *\r
  *  TELNET Webserver Application. When connected to the uIP stack,\r
- *  this will serve out connection information to the client.\r
+ *  this will serve out raw TELNET to the client on port 23.\r
  */\r
  \r
 #define  INCLUDE_FROM_TELNETSERVERAPP_C\r
  */\r
  \r
 #define  INCLUDE_FROM_TELNETSERVERAPP_C\r
@@ -44,9 +44,13 @@ const char PROGMEM WelcomeHeader[] = "******************************************
 \r
 /** Main TELNET menu, giving the user the list of available commands they may issue */\r
 const char PROGMEM TELNETMenu[] = "\r\n"\r
 \r
 /** Main TELNET menu, giving the user the list of available commands they may issue */\r
 const char PROGMEM TELNETMenu[] = "\r\n"\r
-                                  "   Available Commands:\r\n"\r
+                                  "  == Available Commands: ==\r\n"\r
                                   "     c) List Active TCP Connections\r\n"\r
                                   "     c) List Active TCP Connections\r\n"\r
-                                                     "\r\nCommand>";\r
+                                  "  =========================\r\n"\r
+                                  "\r\n>";\r
+                                                                 \r
+/** Header to print before the current connections are printed to the client */\r
+const char PROGMEM CurrentConnectionsHeader = "\r\n* Current TCP Connections: *\r\n";\r
 \r
 /** Initialization function for the simple HTTP webserver. */\r
 void TELNETServerApp_Init(void)\r
 \r
 /** Initialization function for the simple HTTP webserver. */\r
 void TELNETServerApp_Init(void)\r
@@ -65,11 +69,13 @@ void TELNETServerApp_Callback(void)
 \r
        if (uip_connected())\r
        {\r
 \r
        if (uip_connected())\r
        {\r
+               /* New connection - initialize connection state values */\r
                AppState->TELNETServer.CurrentState = TELNET_STATE_SendHeader;\r
        }\r
 \r
        if (uip_acked())\r
        {\r
                AppState->TELNETServer.CurrentState = TELNET_STATE_SendHeader;\r
        }\r
 \r
        if (uip_acked())\r
        {\r
+               /* Progress to the next state once the current state's data has been ACKed */\r
                AppState->TELNETServer.CurrentState = AppState->TELNETServer.NextState; \r
        }\r
 \r
                AppState->TELNETServer.CurrentState = AppState->TELNETServer.NextState; \r
        }\r
 \r
@@ -124,7 +130,7 @@ static void TELNETServerApp_DisplayTCPConnections(void)
 {\r
        char* const AppData    = (char*)uip_appdata;\r
 \r
 {\r
        char* const AppData    = (char*)uip_appdata;\r
 \r
-       strcpy(AppData, "\r\n* Current TCP Connections: *\r\n");\r
+       strcpy_P(AppData, CurrentConnectionsHeader);\r
                                                        \r
        uint16_t ResponseLen     = strlen(AppData);\r
        uint8_t  ActiveConnCount = 0;\r
                                                        \r
        uint16_t ResponseLen     = strlen(AppData);\r
        uint8_t  ActiveConnCount = 0;\r
index 5fca686..244ce1d 100644 (file)
@@ -691,7 +691,7 @@ typedef union
                uint8_t  CurrentState;
                uint8_t  NextState;
                
                uint8_t  CurrentState;
                uint8_t  NextState;
                
-               char     FileName[50];
+               char     FileName[MAX_URI_LENGTH];
                FIL      FileHandle;
                bool     FileOpen;
                uint32_t ACKedFilePos;
                FIL      FileHandle;
                bool     FileOpen;
                uint32_t ACKedFilePos;
index 3ea167f..05d0b1f 100644 (file)
@@ -55,7 +55,7 @@
  *  To use this project, plug the USB AVR into a computer, so that it enumerates as a standard Mass Storage device. Load\r
  *  HTML files onto the disk, so that they can be served out to clients -- the default file to serve should be called\r
  *  <i>index.htm</i>. Filenames must be in 8.3 format for them to be retrieved correctly by the webserver, and the total\r
  *  To use this project, plug the USB AVR into a computer, so that it enumerates as a standard Mass Storage device. Load\r
  *  HTML files onto the disk, so that they can be served out to clients -- the default file to serve should be called\r
  *  <i>index.htm</i>. Filenames must be in 8.3 format for them to be retrieved correctly by the webserver, and the total\r
- *  requested file path must be equal to or less than 50 characters (set in uipopt.h).\r
+ *  requested file path must be equal to or less than the maximum URI length (\see \ref SSec_Options).\r
  *\r
  *  When attached to a RNDIS class device, such as a USB (desktop) modem, the system will enumerate the device, set the\r
  *  appropriate parameters needed for connectivity and begin listening for new HTTP connections on port 80 and TELNET\r
  *\r
  *  When attached to a RNDIS class device, such as a USB (desktop) modem, the system will enumerate the device, set the\r
  *  appropriate parameters needed for connectivity and begin listening for new HTTP connections on port 80 and TELNET\r
  *    <td>Default routing gateway that the webserver should use when connected to a RNDIS device (when ENABLE_DHCP_CLIENT\r
  *        is not defined).</td>\r
  *   </tr>\r
  *    <td>Default routing gateway that the webserver should use when connected to a RNDIS device (when ENABLE_DHCP_CLIENT\r
  *        is not defined).</td>\r
  *   </tr>\r
+ *   <tr>\r
+ *    <td>MAX_URI_LENGTH</td>\r
+ *    <td>Makefile CDEFS</td>\r
+ *    <td>Maximum length of a URI for the Webserver. This is the maximum file path, including subdirectories and seperators.</td>\r
+ *   </tr>\r
  *  </table>\r
  */
\ No newline at end of file
  *  </table>\r
  */
\ No newline at end of file
index d5eda4c..a813b8a 100644 (file)
@@ -200,8 +200,9 @@ CSTANDARD = -std=gnu99
 # Place -D or -U options here for C sources\r
 CDEFS  = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD) $(LUFA_OPTS)\r
 CDEFS += -DENABLE_DHCP_CLIENT\r
 # Place -D or -U options here for C sources\r
 CDEFS  = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD) $(LUFA_OPTS)\r
 CDEFS += -DENABLE_DHCP_CLIENT\r
+CDEFS += -DMAX_URI_LENGTH=50\r
 \r
 \r
-CDEFS += -DUIP_CONF_UDP="defined(ENABLE_DHCP_CLIENT)" -DUIP_CONF_TCP=1 -DUIP_CONF_UDP_CONNS=1 -DUIP_CONF_MAX_CONNECTIONS=5\r
+CDEFS += -DUIP_CONF_UDP="defined(ENABLE_DHCP_CLIENT)" -DUIP_CONF_TCP=1 -DUIP_CONF_UDP_CONNS=1 -DUIP_CONF_MAX_CONNECTIONS=3\r
 CDEFS += -DUIP_CONF_MAX_LISTENPORTS=5 -DUIP_URGDATA=0 -DUIP_CONF_BUFFER_SIZE=1514 -DUIP_ARCH_CHKSUM=0 \r
 CDEFS += -DUIP_CONF_LL_802154=0 -DUIP_CONF_LL_80211=0 -DUIP_CONF_ROUTER=0 -DUIP_CONF_ICMP6=0\r
 CDEFS += -DUIP_ARCH_ADD32=0 -DUIP_CONF_ICMP_DEST_UNREACH=1 -DUIP_NEIGHBOR_CONF_ADDRTYPE=0\r
 CDEFS += -DUIP_CONF_MAX_LISTENPORTS=5 -DUIP_URGDATA=0 -DUIP_CONF_BUFFER_SIZE=1514 -DUIP_ARCH_CHKSUM=0 \r
 CDEFS += -DUIP_CONF_LL_802154=0 -DUIP_CONF_LL_80211=0 -DUIP_CONF_ROUTER=0 -DUIP_CONF_ICMP6=0\r
 CDEFS += -DUIP_ARCH_ADD32=0 -DUIP_CONF_ICMP_DEST_UNREACH=1 -DUIP_NEIGHBOR_CONF_ADDRTYPE=0\r