]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/commitdiff
rpp_eth_portStrToInt function added
authorJan Dolezal <pm.jenik@gmail.com>
Mon, 12 Aug 2013 11:39:04 +0000 (13:39 +0200)
committerJan Dolezal <pm.jenik@gmail.com>
Mon, 12 Aug 2013 11:39:04 +0000 (13:39 +0200)
lwip
rpp/include/rpp/eth.h
rpp/src/rpp/eth.c

diff --git a/lwip b/lwip
index 0a46511e16bcb0e54f9268eb527d095c90b83f6e..aa55eaa1dbe279f238232c3f1e2ca6c3ca74ec19 160000 (submodule)
--- a/lwip
+++ b/lwip
@@ -1 +1 @@
-Subproject commit 0a46511e16bcb0e54f9268eb527d095c90b83f6e
+Subproject commit aa55eaa1dbe279f238232c3f1e2ca6c3ca74ec19
index a6365a8ace7040f13ba595c845dd1dde2a3eae38..9b6ea4906d060cc1200047994cf282f750dc3d47 100644 (file)
@@ -18,6 +18,8 @@
 #include "os/os.h"
 #include "lwip/netif.h"
 
+#define TICKS_PHY_AUTONEG  4000
+
 /* this MAC address is used when user put NULL on the right place when calling postInit function */
 #define RPP_MAC_ADDR {0x12,0x34,0x56,0x78,0x9a,0xbc}
 #if STATIC_IP_ADDRESS
@@ -65,6 +67,7 @@ int8_t rpp_eth_init();
  * @param waitTicksForPHYAneg maximum amount of ticks it will wait for autonegotiation
  *
  * @return SUCCESS if init successful.
+ *         FAILURE if module was already initialized
  *         NETIF_ADD_ERR if lwip netif was not succesfully initialized or on low hw init error.
  *         DHCP_MEM_ERR if DHCP unsuccesfull.
  *         DHCP_BIND_TIMEOUT
@@ -119,6 +122,16 @@ inline void rpp_eth_getIPDecimalStr(ip_addr_t ip, uint8_t *ipStr);
  */
 err_t rpp_eth_stringToIP(ip_addr_t * ip, uint8_t * ipstr);
 
+/**
+ * Converts given null terminated string containing number to number in
+ * range <1-65535>
+ *
+ * @param string to be converted
+ * @return 0 on error
+ *         port number otherwise
+ */
+uint16_t rpp_eth_portStrToInt(uint8_t *string);
+
 /**
  * Returns struct describing network interface
  *
index 68f7e2937d9abbd377c71ee9bf2bb9ddc996c7d1..7d6622c51dffe4efdbed8438a0a6348b74d0f58f 100644 (file)
@@ -328,6 +328,23 @@ err_t rpp_eth_stringToIP(ip_addr_t * ip, uint8_t * ipstr)
        return SUCCESS;
 }
 
+/* returns number in range 0-65535 where 0 is error */
+uint16_t rpp_eth_portStrToInt(uint8_t *string)
+{
+       uint8_t index;
+       uint16_t portNO = 0;
+       for(index = 0;string[index] != '\0';index++)
+       {
+               if(string[index] < '0' || string[index] > '9')
+               {
+                       portNO = 0;
+                       break;
+               }
+               portNO = portNO * 10 + string[index] - '0';
+       }
+       return portNO;
+}
+
 struct netif *rpp_eth_get_netif(uint32_t instNum)
 {
        return &hdkNetIF[instNum];
@@ -504,7 +521,7 @@ int8_t rpp_eth_init_postInit(uint32_t instNum, uint8_t *macArray)
 
     if(rpp_eth_phylinkstat(hdkif->inst_num))
     {
-       rpp_debug_printf((const char *)"cable connected\r\n");
+       rpp_debug_printf((const char *)"cable connected ... setting IP params\r\n");
 #if STATIC_IP_ADDRESS
        netif_set_up(netif);
 #elif LWIP_DHCP /* STATIC_IP_ADDRESS-LWIP_DHCP */
@@ -564,7 +581,7 @@ err_t rpp_eth_lwip_init(struct netif *netif)
     netif->name[1] = IFNAME1;
 
 
-    hdkif->waitTicksForPHYAneg = 4000;
+    hdkif->waitTicksForPHYAneg = TICKS_PHY_AUTONEG;
 
     /*
      * Initialize the snmp variables and counters inside the struct netif.
@@ -763,14 +780,8 @@ err_t rpp_eth_hw_init_postInit(struct netif *netif)
        }
 
        last_rxbd->next = NULL;
-#ifdef DEBUG
-       rpp_debug_printf((const char *) "last_rxbd: 0x%x\r\n",last_rxbd);
-#endif
        rxch->active_tail = last_rxbd;
        num_bd = (((uint32_t)rxch->active_tail - (uint32_t)rxch->active_head) / sizeof(struct emac_rx_bd) + 1);
-#ifdef DEBUG
-       rpp_debug_printf((const char *) "num of filled bds: %d\r\nnum of pbufs: %d\r\n", num_bd, pbuf_cnt);
-#endif
 
 
        /* for flow control - there could be set an interrupt when we reach preset amount of receive descriptors remaining - see RXBUFFERFLOWEN */