mirror of
https://github.com/apache/nuttx.git
synced 2026-05-27 11:26:12 +08:00
Fixing LM3S httpd example (still broken)
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2390 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -658,12 +658,13 @@ static void lm3s_receive(struct lm3s_driver_s *priv)
|
|||||||
pktlen = (int)(regval & 0x0000ffff);
|
pktlen = (int)(regval & 0x0000ffff);
|
||||||
nllvdbg("Receiving packet, pktlen: %d\n", pktlen);
|
nllvdbg("Receiving packet, pktlen: %d\n", pktlen);
|
||||||
|
|
||||||
/* Check if the pktlen is valid. It should be large enough to
|
/* Check if the pktlen is valid. It should be large enough to hold
|
||||||
* hold an Ethernet header and small enough to fit entirely in
|
* an Ethernet header and small enough to fit entirely in the I/O
|
||||||
* the I/O buffer.
|
* buffer. Six is subtracted to acount for the 2-byte length/type
|
||||||
|
* and 4 byte FCS that are not copied into the uIP packet.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (pktlen > CONFIG_NET_BUFSIZE || pktlen <= UIP_LLH_LEN)
|
if (pktlen > (CONFIG_NET_BUFSIZE + 6) || pktlen <= (UIP_LLH_LEN + 6))
|
||||||
{
|
{
|
||||||
int wordlen;
|
int wordlen;
|
||||||
|
|
||||||
@@ -697,10 +698,10 @@ static void lm3s_receive(struct lm3s_driver_s *priv)
|
|||||||
|
|
||||||
/* Read all of the whole, 32-bit values in the middle of the packet.
|
/* Read all of the whole, 32-bit values in the middle of the packet.
|
||||||
* We've already read the length (2 bytes) plus the first two bytes
|
* We've already read the length (2 bytes) plus the first two bytes
|
||||||
* of data
|
* of data.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
for (bytesleft = pktlen - 4; bytesleft > 3; bytesleft -= 4, dbuf += 4)
|
for (bytesleft = pktlen - 4; bytesleft > 7; bytesleft -= 4, dbuf += 4)
|
||||||
{
|
{
|
||||||
/* Transfer a whole word to the user buffer. Note, the user
|
/* Transfer a whole word to the user buffer. Note, the user
|
||||||
* buffer may be un-aligned.
|
* buffer may be un-aligned.
|
||||||
@@ -709,36 +710,38 @@ static void lm3s_receive(struct lm3s_driver_s *priv)
|
|||||||
*(uint32_t*)dbuf = lm3s_ethin(priv, LM3S_MAC_DATA_OFFSET);
|
*(uint32_t*)dbuf = lm3s_ethin(priv, LM3S_MAC_DATA_OFFSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle the last, partial word in the FIFO */
|
/* Handle the last, partial word in the FIFO (0-3 bytes) and discard
|
||||||
|
* the 4-byte FCS.
|
||||||
|
*/
|
||||||
|
|
||||||
if (bytesleft > 0)
|
for (; bytesleft > 0; bytesleft -= 4)
|
||||||
{
|
{
|
||||||
/* Read the last word */
|
/* Read the last word. And transfer all but the last four
|
||||||
|
* bytes of the FCS into the user buffer.
|
||||||
|
*/
|
||||||
|
|
||||||
regval = lm3s_ethin(priv, LM3S_MAC_DATA_OFFSET);
|
regval = lm3s_ethin(priv, LM3S_MAC_DATA_OFFSET);
|
||||||
switch (bytesleft)
|
switch (bytesleft)
|
||||||
{
|
{
|
||||||
case 0:
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 7:
|
||||||
dbuf[2] = (regval >> 16) & 0xff;
|
dbuf[2] = (regval >> 16) & 0xff;
|
||||||
case 2:
|
case 6:
|
||||||
dbuf[1] = (regval >> 8) & 0xff;
|
dbuf[1] = (regval >> 8) & 0xff;
|
||||||
case 1:
|
case 5:
|
||||||
dbuf[0] = regval & 0xff;
|
dbuf[0] = regval & 0xff;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lm3s_dumppacket("Received packet", priv->ld_dev.d_buf, pktlen);
|
|
||||||
|
|
||||||
/* Pass the packet length to uIP MINUS 2 bytes for the length and
|
/* Pass the packet length to uIP MINUS 2 bytes for the length and
|
||||||
* 4 bytes for the FCS.
|
* 4 bytes for the FCS.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
priv->ld_dev.d_len = pktlen - 6;
|
priv->ld_dev.d_len = pktlen - 6;
|
||||||
|
lm3s_dumppacket("Received packet", priv->ld_dev.d_buf, priv->ld_dev.d_len);
|
||||||
|
|
||||||
/* We only accept IP packets of the configured type and ARP packets */
|
/* We only accept IP packets of the configured type and ARP packets */
|
||||||
|
|
||||||
|
|||||||
@@ -99,14 +99,18 @@
|
|||||||
#ifdef CONFIG_CPP_HAVE_VARARGS
|
#ifdef CONFIG_CPP_HAVE_VARARGS
|
||||||
# ifdef CONFIG_DEBUG
|
# ifdef CONFIG_DEBUG
|
||||||
# define message(...) lib_lowprintf(__VA_ARGS__)
|
# define message(...) lib_lowprintf(__VA_ARGS__)
|
||||||
|
# define msgflush()
|
||||||
# else
|
# else
|
||||||
# define message(...) printf(__VA_ARGS__)
|
# define message(...) printf(__VA_ARGS__)
|
||||||
|
# define msgflush() fflush(stdout)
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
# ifdef CONFIG_DEBUG
|
# ifdef CONFIG_DEBUG
|
||||||
# define message lib_lowprintf
|
# define message lib_lowprintf
|
||||||
|
# define msgflush()
|
||||||
# else
|
# else
|
||||||
# define message (void)
|
# define message printf
|
||||||
|
# define msgflush() fflush(stdout)
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -230,7 +234,9 @@ int user_start(int argc, char *argv[])
|
|||||||
g_thttpdnsymbols = NEXPORTS;
|
g_thttpdnsymbols = NEXPORTS;
|
||||||
|
|
||||||
message("Starting THTTPD\n");
|
message("Starting THTTPD\n");
|
||||||
|
msgflush();
|
||||||
thttpd_main(1, &thttpd_argv);
|
thttpd_main(1, &thttpd_argv);
|
||||||
message("THTTPD terminated\n");
|
message("THTTPD terminated\n");
|
||||||
|
msgflush();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-3
@@ -158,10 +158,9 @@ static int accept_interrupt(struct uip_conn *listener, struct uip_conn *conn)
|
|||||||
pstate->acpt_newconn = conn;
|
pstate->acpt_newconn = conn;
|
||||||
pstate->acpt_result = OK;
|
pstate->acpt_result = OK;
|
||||||
|
|
||||||
/* Set a reference of one on the new connection */
|
/* There should be a reference of one on the new connection */
|
||||||
|
|
||||||
DEBUGASSERT(conn->crefs == 0);
|
DEBUGASSERT(conn->crefs == 1);
|
||||||
conn->crefs = 1;
|
|
||||||
|
|
||||||
/* Wake-up the waiting caller thread */
|
/* Wake-up the waiting caller thread */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user