From 7506c552caceee913d936fde61c22ecb6ecc96c7 Mon Sep 17 00:00:00 2001 From: patacongo Date: Tue, 15 Mar 2011 01:54:49 +0000 Subject: Basic SLIP functionality -- but there are issues git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3382 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/configs/olimex-lpc1766stk/README.txt | 6 +++++- .../configs/olimex-lpc1766stk/slip-httpd/defconfig | 2 +- nuttx/drivers/net/skeleton.c | 4 ++-- nuttx/drivers/net/slip.c | 19 ++++++++--------- nuttx/examples/thttpd/main.c | 24 +++++++++++----------- nuttx/net/netdev_register.c | 8 +++++++- 6 files changed, 36 insertions(+), 27 deletions(-) diff --git a/nuttx/configs/olimex-lpc1766stk/README.txt b/nuttx/configs/olimex-lpc1766stk/README.txt index 72340ffff..5a30ab9f1 100755 --- a/nuttx/configs/olimex-lpc1766stk/README.txt +++ b/nuttx/configs/olimex-lpc1766stk/README.txt @@ -811,11 +811,15 @@ Where is one of the following: 3. Reset on the target side and attach SLIP on the Linux side: $ modprobe slip - $ slattach -p slip -s 57600 /dev/ttyS0 & + $ slattach -L -p slip -s 57600 /dev/ttyS0 & This should create an interface with a name like sl0, or sl1, etc. Add -d to get debug output. This will show the interface name. + NOTE: The -L option is included to suppress use of hardware flow + control. This is necessary because I haven't figure out how to + use the UART1 hardwar flow control yet. + NOTE: The Linux slip module hard-codes its MTU size to 296. So you might as well set CONFIG_NET_BUFSIZE to 296 as well. diff --git a/nuttx/configs/olimex-lpc1766stk/slip-httpd/defconfig b/nuttx/configs/olimex-lpc1766stk/slip-httpd/defconfig index c4fd1a6d0..324207e8a 100755 --- a/nuttx/configs/olimex-lpc1766stk/slip-httpd/defconfig +++ b/nuttx/configs/olimex-lpc1766stk/slip-httpd/defconfig @@ -152,7 +152,7 @@ CONFIG_UART1_SERIAL_CONSOLE=n CONFIG_UART2_SERIAL_CONSOLE=n CONFIG_UART3_SERIAL_CONSOLE=n -CONFIG_UART1_FLOWCONTROL=y +CONFIG_UART1_FLOWCONTROL=n CONFIG_UART0_TXBUFSIZE=256 CONFIG_UART1_TXBUFSIZE=256 diff --git a/nuttx/drivers/net/skeleton.c b/nuttx/drivers/net/skeleton.c index 16aab6d87..5956f72c6 100644 --- a/nuttx/drivers/net/skeleton.c +++ b/nuttx/drivers/net/skeleton.c @@ -663,8 +663,8 @@ int skel_initialize(int intf) /* Initialize the driver structure */ memset(priv, 0, sizeof(struct skel_driver_s)); - priv->sk_dev.d_ifup = skel_ifup; /* I/F down callback */ - priv->sk_dev.d_ifdown = skel_ifdown; /* I/F up (new IP address) callback */ + priv->sk_dev.d_ifup = skel_ifup; /* I/F up (new IP address) callback */ + priv->sk_dev.d_ifdown = skel_ifdown; /* I/F down callback */ priv->sk_dev.d_txavail = skel_txavail; /* New TX data callback */ #ifdef CONFIG_NET_IGMP priv->sk_dev.d_addmac = skel_addmac; /* Add multicast MAC address */ diff --git a/nuttx/drivers/net/slip.c b/nuttx/drivers/net/slip.c index 6fedb829a..fd38c5f32 100644 --- a/nuttx/drivers/net/slip.c +++ b/nuttx/drivers/net/slip.c @@ -83,15 +83,17 @@ #endif #ifndef CONFIG_SLIP_STACKSIZE -# define CONFIG_SLIP_STACKSIZE 1024 +# define CONFIG_SLIP_STACKSIZE 2048 #endif #ifndef CONFIG_SLIP_DEFPRIO # define CONFIG_SLIP_DEFPRIO 128 #endif -/* The Linux slip module hard-codes its MTU size to 296. So you - might as well set CONFIG_NET_BUFSIZE to 296 as well. +/* The Linux slip module hard-codes its MTU size to 296. So you might as + * well set CONFIG_NET_BUFSIZE to 296 as well. + */ + #if CONFIG_NET_BUFSIZE < 296 # error "CONFIG_NET_BUFSIZE >= 296 is required" #elif CONFIG_NET_BUFSIZE > 296 @@ -278,7 +280,7 @@ static inline void slip_write(FAR struct slip_driver_s *priv, static inline void slip_putc(FAR struct slip_driver_s *priv, int ch) { -#if CONFIG_DEBUG +#if 0 // CONFIG_DEBUG int ret = putc(ch, priv->stream); DEBUGASSERT(ret == ch); #else @@ -385,7 +387,7 @@ static int slip_transmit(FAR struct slip_driver_s *priv) src++; } - /* We have looked at every charcter in the packet. Now flush any unsent + /* We have looked at every character in the packet. Now flush any unsent * data */ @@ -919,8 +921,8 @@ int slip_initialize(int intf, const char *devname) /* Initialize the driver structure */ memset(priv, 0, sizeof(struct slip_driver_s)); - priv->dev.d_ifup = slip_ifup; /* I/F down callback */ - priv->dev.d_ifdown = slip_ifdown; /* I/F up (new IP address) callback */ + priv->dev.d_ifup = slip_ifup; /* I/F up (new IP address) callback */ + priv->dev.d_ifdown = slip_ifdown; /* I/F down callback */ priv->dev.d_txavail = slip_txavail; /* New TX data callback */ #ifdef CONFIG_NET_IGMP priv->dev.d_addmac = slip_addmac; /* Add multicast MAC address */ @@ -976,9 +978,6 @@ int slip_initialize(int intf, const char *devname) /* Register the device with the OS so that socket IOCTLs can be performed */ -#if CONFIG_NSOCKET_DESCRIPTORS > 0 - snprintf(priv->dev.d_ifname, IFNAMSIZ, "slip%d", intf); -#endif (void)netdev_register(&priv->dev); return OK; } diff --git a/nuttx/examples/thttpd/main.c b/nuttx/examples/thttpd/main.c index b7c040cdb..f9d0ee055 100644 --- a/nuttx/examples/thttpd/main.c +++ b/nuttx/examples/thttpd/main.c @@ -107,7 +107,7 @@ # endif # define SLIP_DEVNO 0 -# define NET_DEVNAME "slip0" +# define NET_DEVNAME "sl0" #else /* Otherwise, use the standard ethernet device name */ @@ -190,6 +190,17 @@ int user_start(int argc, char *argv[]) char *thttpd_argv = "thttpd"; int ret; + /* 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 + /* Many embedded network interfaces must have a software assigned MAC */ #ifdef CONFIG_EXAMPLE_THTTPD_NOMAC @@ -204,17 +215,6 @@ int user_start(int argc, char *argv[]) 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"); diff --git a/nuttx/net/netdev_register.c b/nuttx/net/netdev_register.c index 7283574dd..d9387c796 100644 --- a/nuttx/net/netdev_register.c +++ b/nuttx/net/netdev_register.c @@ -58,6 +58,12 @@ * Definitions ****************************************************************************/ +#ifdef CONFIG_NET_SLIP +# define NETDEV_FORMAT "sl%d" +#else +# define NETDEV_FORMAT "eth%d" +#endif + /**************************************************************************** * Priviate Types ****************************************************************************/ @@ -134,7 +140,7 @@ int netdev_register(FAR struct uip_driver_s *dev) /* Assign a device name to the interface */ devnum = g_next_devnum++; - snprintf( dev->d_ifname, IFNAMSIZ, "eth%d", devnum ); + snprintf( dev->d_ifname, IFNAMSIZ, NETDEV_FORMAT, devnum ); /* Add the device to the list of known network devices */ -- cgit v1.2.3