summaryrefslogtreecommitdiff
path: root/nuttx/net/recvfrom.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-11-05 23:04:16 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-11-05 23:04:16 +0000
commit13a1d731ec51a27983bc9e6fcaa841607a090764 (patch)
tree93b32ce5f98ff118a21eb072cf111e164fd38686 /nuttx/net/recvfrom.c
parent4cfb76d4d59acfdadc0f50527533b9c129edde41 (diff)
downloadpx4-nuttx-13a1d731ec51a27983bc9e6fcaa841607a090764.tar.gz
px4-nuttx-13a1d731ec51a27983bc9e6fcaa841607a090764.tar.bz2
px4-nuttx-13a1d731ec51a27983bc9e6fcaa841607a090764.zip
Basic TCP send functional
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@371 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/net/recvfrom.c')
-rw-r--r--nuttx/net/recvfrom.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/nuttx/net/recvfrom.c b/nuttx/net/recvfrom.c
index 25dc1c4fb..1ea76981f 100644
--- a/nuttx/net/recvfrom.c
+++ b/nuttx/net/recvfrom.c
@@ -42,8 +42,11 @@
#include <sys/types.h>
#include <sys/socket.h>
+
#include <string.h>
#include <errno.h>
+#include <debug.h>
+
#include <arch/irq.h>
#include <nuttx/clock.h>
#include <net/uip/uip-arch.h>
@@ -104,6 +107,8 @@ static void recvfrom_interrupt(struct uip_driver_s *dev, void *private)
#endif
size_t recvlen;
+ vdbg("Interrupt uip_flags: %02x\n", uip_flags);
+
/* 'private' might be null in some race conditions (?) */
if (pstate)
@@ -116,9 +121,10 @@ static void recvfrom_interrupt(struct uip_driver_s *dev, void *private)
/* If new data is available, then complete the read action. */
- if (uip_newdata())
+ if (uip_newdata_event())
{
/* Get the length of the data to return */
+
if (dev->d_len > pstate->rf_buflen)
{
recvlen = pstate->rf_buflen;
@@ -131,6 +137,7 @@ static void recvfrom_interrupt(struct uip_driver_s *dev, void *private)
/* Copy the new appdata into the user buffer */
memcpy(pstate->rf_buffer, dev->d_appdata, recvlen);
+ vdbg("Received %d bytes (of %d)\n", recvlen, dev->d_len);
/* Update the accumulated size of the data read */
@@ -139,14 +146,16 @@ static void recvfrom_interrupt(struct uip_driver_s *dev, void *private)
pstate->rf_buflen -= recvlen;
/* Are we finished? If this is a UDP socket or if the user
- * buffer has been filled, then we are finished.
- */
+ * buffer has been filled, then we are finished.
+ */
#ifdef CONFIG_NET_UDP
if (psock->s_type == SOCK_DGRAM)
{
struct uip_udp_conn *udp_conn;
+ vdbg("UDP complete\n");
+
/* Don't allow any further UDP call backs. */
udp_conn = (struct uip_udp_conn *)psock->s_conn;
@@ -165,6 +174,8 @@ static void recvfrom_interrupt(struct uip_driver_s *dev, void *private)
{
struct uip_conn *conn;
+ vdbg("TCP complete\n");
+
/* The TCP receive buffer is full. Return now, perhaps truncating
* the received data (need to fix that).
*
@@ -183,8 +194,8 @@ static void recvfrom_interrupt(struct uip_driver_s *dev, void *private)
}
/* Reset the timeout. We will want a short timeout to terminate
- * the TCP receive.
- */
+ * the TCP receive.
+ */
#if defined(CONFIG_NET_SOCKOPTS) && !defined(CONFIG_DISABLE_CLOCK)
pstate->rf_starttime = g_system_timer;
@@ -195,6 +206,8 @@ static void recvfrom_interrupt(struct uip_driver_s *dev, void *private)
else if ((uip_flags & (UIP_CLOSE|UIP_ABORT|UIP_TIMEDOUT)) != 0)
{
+ vdbg("Receive error\n");
+
/* Stop further callbacks */
#ifdef CONFIG_NET_UDP
@@ -267,6 +280,8 @@ static void recvfrom_interrupt(struct uip_driver_s *dev, void *private)
{
struct uip_udp_conn *udp_conn;
+ vdbg("UDP timeout\n");
+
/* Stop further callbacks */
udp_conn = (struct uip_udp_conn *)psock->s_conn;
@@ -282,6 +297,8 @@ static void recvfrom_interrupt(struct uip_driver_s *dev, void *private)
{
struct uip_conn *conn;
+ vdbg("TCP timeout\n");
+
conn = (struct uip_conn *)psock->s_conn;
conn->data_private = NULL;
conn->data_event = NULL;
@@ -463,7 +480,9 @@ static ssize_t udp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
* and automatically re-enabled when the task restarts.
*/
+ vdbg("Receiving UDP ...\n");
ret = sem_wait(&state. rf_sem);
+ vdbg("Received\n");
/* Make sure that no further interrupts are processed */
@@ -540,7 +559,9 @@ static ssize_t tcp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
* and automatically re-enabled when the task restarts.
*/
+ vdbg("Receiving UDP ...\n");
ret = sem_wait(&state.rf_sem);
+ vdbg("Received\n");
/* Make sure that no further interrupts are processed */