summaryrefslogtreecommitdiff
path: root/nuttx/examples/thttpd/main.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-03-12 16:33:55 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-03-12 16:33:55 +0000
commitd9580c5a997f0d33b216956db4a05ad784aaa065 (patch)
tree32169240d5ecd36f538df1ec91089c52e96f0c68 /nuttx/examples/thttpd/main.c
parente6f93f774080d42c3f954a862709d047df2d7e7a (diff)
downloadpx4-nuttx-d9580c5a997f0d33b216956db4a05ad784aaa065.tar.gz
px4-nuttx-d9580c5a997f0d33b216956db4a05ad784aaa065.tar.bz2
px4-nuttx-d9580c5a997f0d33b216956db4a05ad784aaa065.zip
Add SLIP test configuration
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3371 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/examples/thttpd/main.c')
-rw-r--r--nuttx/examples/thttpd/main.c49
1 files changed, 43 insertions, 6 deletions
diff --git a/nuttx/examples/thttpd/main.c b/nuttx/examples/thttpd/main.c
index 9bdc44eac..b7c040cdb 100644
--- a/nuttx/examples/thttpd/main.c
+++ b/nuttx/examples/thttpd/main.c
@@ -1,7 +1,7 @@
/****************************************************************************
* examples/thttpd/main.c
*
- * Copyright (C) 2009-2010 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2009-2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -57,6 +57,9 @@
#include <nuttx/ramdisk.h>
#include <nuttx/binfmt.h>
#include <nuttx/nxflat.h>
+#ifdef CONFIG_NET_SLIP
+# include <nuttx/net.h>
+#endif
#include "content/romfs.h"
#include "content/symtab.h"
@@ -89,6 +92,29 @@
# error "You must not disable loadable modules via CONFIG_BINFMT_DISABLE in your configuration file"
#endif
+/* SLIP-specific configuration */
+
+#ifdef CONFIG_NET_SLIP
+
+ /* No MAC address operations */
+
+# undef CONFIG_EXAMPLE_THTTPD_NOMAC
+
+ /* TTY device to use */
+
+# ifndef CONFIG_NET_SLIPTTY
+# define CONFIG_NET_SLIPTTY "/dev/ttyS1"
+# endif
+
+# define SLIP_DEVNO 0
+# define NET_DEVNAME "slip0"
+#else
+
+ /* Otherwise, use the standard ethernet device name */
+
+# define NET_DEVNAME "eth0"
+#endif
+
/* Describe the ROMFS file system */
#define SECTORSIZE 512
@@ -175,24 +201,35 @@ int user_start(int argc, char *argv[])
mac[3] = 0x0b;
mac[4] = 0xba;
mac[5] = 0xbe;
- uip_setmacaddr("eth0", mac);
+ uip_setmacaddr(NET_DEVNAME, mac);
+#endif
+
+ /* Configure SLIP */
+
+#ifdef CONFIG_NET_SLIP
+ ret = slip_initialize(SLIP_DEVNO, CONFIG_NET_SLIPTTY);
+ if (ret < 0)
+ {
+ message("ERROR: SLIP initialization failed: %d\n", ret);
+ exit(1);
+ }
#endif
/* Set up our host address */
message("Setup network addresses\n");
addr.s_addr = HTONL(CONFIG_THTTPD_IPADDR);
- uip_sethostaddr("eth0", &addr);
+ uip_sethostaddr(NET_DEVNAME, &addr);
/* Set up the default router address */
addr.s_addr = HTONL(CONFIG_EXAMPLE_THTTPD_DRIPADDR);
- uip_setdraddr("eth0", &addr);
+ uip_setdraddr(NET_DEVNAME, &addr);
/* Setup the subnet mask */
addr.s_addr = HTONL(CONFIG_EXAMPLE_THTTPD_NETMASK);
- uip_setnetmask("eth0", &addr);
+ uip_setnetmask(NET_DEVNAME, &addr);
/* Initialize the NXFLAT binary loader */
@@ -201,7 +238,7 @@ int user_start(int argc, char *argv[])
if (ret < 0)
{
message("ERROR: Initialization of the NXFLAT loader failed: %d\n", ret);
- exit(1);
+ exit(2);
}
/* Create a ROM disk for the ROMFS filesystem */