From 34a175b6e82af32562b8c0eb05c905f55874035f Mon Sep 17 00:00:00 2001 From: Soohwan Kim Date: Mon, 30 Sep 2013 11:40:25 +0900 Subject: [PATCH 01/11] Fixed --- Ethernet/Ethernet.cpp | 53 ++++++++++++++++++++++--------------------- Ethernet/Ethernet.h | 18 ++++++++------- 2 files changed, 37 insertions(+), 34 deletions(-) diff --git a/Ethernet/Ethernet.cpp b/Ethernet/Ethernet.cpp index 460a829..f5582dc 100644 --- a/Ethernet/Ethernet.cpp +++ b/Ethernet/Ethernet.cpp @@ -9,15 +9,19 @@ uint8_t EthernetClass::_state[MAX_SOCK_NUM] = { 0, }; uint16_t EthernetClass::_server_port[MAX_SOCK_NUM] = { 0, }; -int EthernetClass::begin(uint8_t *mac_address) + + +#if defined(WIZ550io_WITH_MACADDRESS) +int EthernetClass::begin(void) { + byte mac_address[6] ={0,}; _dhcp = new DhcpClass(); // Initialise the basic info W5100.init(); - W5100.setMACAddress(mac_address); W5100.setIPAddress(IPAddress(0,0,0,0).raw_address()); - + W5100.getMACAddress(mac_address); + // Now try to get our config info from a DHCP server int ret = _dhcp->beginWithDHCP(mac_address); if(ret == 1) @@ -33,52 +37,48 @@ int EthernetClass::begin(uint8_t *mac_address) return ret; } -void EthernetClass::begin(uint8_t *mac_address, IPAddress local_ip) +void EthernetClass::begin(IPAddress local_ip) { // Assume the DNS server will be the machine on the same network as the local IP // but with last octet being '1' IPAddress dns_server = local_ip; dns_server[3] = 1; - begin(mac_address, local_ip, dns_server); + begin(local_ip, dns_server); } -void EthernetClass::begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server) +void EthernetClass::begin(IPAddress local_ip, IPAddress dns_server) { // Assume the gateway will be the machine on the same network as the local IP // but with last octet being '1' IPAddress gateway = local_ip; gateway[3] = 1; - begin(mac_address, local_ip, dns_server, gateway); + begin(local_ip, dns_server, gateway); } -void EthernetClass::begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server, IPAddress gateway) +void EthernetClass::begin(IPAddress local_ip, IPAddress dns_server, IPAddress gateway) { IPAddress subnet(255, 255, 255, 0); - begin(mac_address, local_ip, dns_server, gateway, subnet); + begin(local_ip, dns_server, gateway, subnet); } -void EthernetClass::begin(uint8_t *mac, IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet) +void EthernetClass::begin(IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet) { W5100.init(); - W5100.setMACAddress(mac); W5100.setIPAddress(local_ip._address); W5100.setGatewayIp(gateway._address); W5100.setSubnetMask(subnet._address); _dnsServerAddress = dns_server; } - -#if defined(WIZ550io_WITH_MACADDRESS) -int EthernetClass::begin(void) +#else +int EthernetClass::begin(uint8_t *mac_address) { - byte mac_address[6] ={0,}; _dhcp = new DhcpClass(); - // Initialise the basic info W5100.init(); + W5100.setMACAddress(mac_address); W5100.setIPAddress(IPAddress(0,0,0,0).raw_address()); - W5100.getMACAddress(mac_address); - + // Now try to get our config info from a DHCP server int ret = _dhcp->beginWithDHCP(mac_address); if(ret == 1) @@ -94,39 +94,40 @@ int EthernetClass::begin(void) return ret; } -void EthernetClass::begin(IPAddress local_ip) +void EthernetClass::begin(uint8_t *mac_address, IPAddress local_ip) { // Assume the DNS server will be the machine on the same network as the local IP // but with last octet being '1' IPAddress dns_server = local_ip; dns_server[3] = 1; - begin(local_ip, dns_server); + begin(mac_address, local_ip, dns_server); } -void EthernetClass::begin(IPAddress local_ip, IPAddress dns_server) +void EthernetClass::begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server) { // Assume the gateway will be the machine on the same network as the local IP // but with last octet being '1' IPAddress gateway = local_ip; gateway[3] = 1; - begin(local_ip, dns_server, gateway); + begin(mac_address, local_ip, dns_server, gateway); } -void EthernetClass::begin(IPAddress local_ip, IPAddress dns_server, IPAddress gateway) +void EthernetClass::begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server, IPAddress gateway) { IPAddress subnet(255, 255, 255, 0); - begin(local_ip, dns_server, gateway, subnet); + begin(mac_address, local_ip, dns_server, gateway, subnet); } -void EthernetClass::begin(IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet) +void EthernetClass::begin(uint8_t *mac, IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet) { - byte mac_address[6] ={0,}; W5100.init(); + W5100.setMACAddress(mac); W5100.setIPAddress(local_ip._address); W5100.setGatewayIp(gateway._address); W5100.setSubnetMask(subnet._address); _dnsServerAddress = dns_server; } + #endif int EthernetClass::maintain(){ diff --git a/Ethernet/Ethernet.h b/Ethernet/Ethernet.h index 3a444a0..a115ee6 100644 --- a/Ethernet/Ethernet.h +++ b/Ethernet/Ethernet.h @@ -21,14 +21,6 @@ class EthernetClass { public: static uint8_t _state[MAX_SOCK_NUM]; static uint16_t _server_port[MAX_SOCK_NUM]; - // Initialise the Ethernet shield to use the provided MAC address and gain the rest of the - // configuration through DHCP. - // Returns 0 if the DHCP configuration failed, and 1 if it succeeded - int begin(uint8_t *mac_address); - void begin(uint8_t *mac_address, IPAddress local_ip); - void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server); - void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server, IPAddress gateway); - void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet); #if defined(WIZ550io_WITH_MACADDRESS) // Initialize function when use the ioShield serise (included WIZ550io) @@ -40,6 +32,16 @@ class EthernetClass { void begin(IPAddress local_ip, IPAddress dns_server); void begin(IPAddress local_ip, IPAddress dns_server, IPAddress gateway); void begin(IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet); +#else + // Initialize the Ethernet shield to use the provided MAC address and gain the rest of the + // configuration through DHCP. + // Returns 0 if the DHCP configuration failed, and 1 if it succeeded + int begin(uint8_t *mac_address); + void begin(uint8_t *mac_address, IPAddress local_ip); + void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server); + void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server, IPAddress gateway); + void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet); + #endif int maintain(); From 9e79ea3a1210c2fbe159b9d1f42b44487827a1a4 Mon Sep 17 00:00:00 2001 From: Tobias Ebsen Date: Mon, 30 Sep 2013 18:50:25 +0200 Subject: [PATCH 02/11] Added functions to enable skipping in the Rx pointer --- Ethernet/utility/w5100.cpp | 8 ++++++++ Ethernet/utility/w5100.h | 7 +++++++ Ethernet/utility/w5200.cpp | 8 ++++++++ Ethernet/utility/w5200.h | 7 +++++++ Ethernet/utility/w5500.cpp | 8 ++++++++ Ethernet/utility/w5500.h | 7 +++++++ 6 files changed, 45 insertions(+) diff --git a/Ethernet/utility/w5100.cpp b/Ethernet/utility/w5100.cpp index 679504e..2e3bfd6 100644 --- a/Ethernet/utility/w5100.cpp +++ b/Ethernet/utility/w5100.cpp @@ -109,6 +109,14 @@ void W5100Class::recv_data_processing(SOCKET s, uint8_t *data, uint16_t len, uin } } +void W5100Class::skip(SOCKET s, uint16_t len) +{ + uint16_t ptr; + ptr = readSnRX_RD(s); + ptr += len; + writeSnRX_RD(s, ptr); +} + void W5100Class::read_data(SOCKET s, volatile uint8_t *src, volatile uint8_t *dst, uint16_t len) { uint16_t size; diff --git a/Ethernet/utility/w5100.h b/Ethernet/utility/w5100.h index 3bfb1aa..33c044f 100644 --- a/Ethernet/utility/w5100.h +++ b/Ethernet/utility/w5100.h @@ -183,6 +183,13 @@ class W5100Class { */ void recv_data_processing(SOCKET s, uint8_t *data, uint16_t len, uint8_t peek = 0); + /** + * @brief Moves the Rx read pointer forward + * + * This function allows you to skip a number of bytes in the Rx pointer register. + */ + void skip(SOCKET s, uint16_t len); + inline void setGatewayIp(uint8_t *_addr); inline void getGatewayIp(uint8_t *_addr); diff --git a/Ethernet/utility/w5200.cpp b/Ethernet/utility/w5200.cpp index 5e2aa8a..5adf4c1 100644 --- a/Ethernet/utility/w5200.cpp +++ b/Ethernet/utility/w5200.cpp @@ -109,6 +109,14 @@ void W5200Class::recv_data_processing(SOCKET s, uint8_t *data, uint16_t len, uin } } +void W5200Class::skip(SOCKET s, uint16_t len) +{ + uint16_t ptr; + ptr = readSnRX_RD(s); + ptr += len; + writeSnRX_RD(s, ptr); +} + void W5200Class::read_data(SOCKET s, volatile uint8_t *src, volatile uint8_t *dst, uint16_t len) { uint16_t size; diff --git a/Ethernet/utility/w5200.h b/Ethernet/utility/w5200.h index 22b1db6..a6d6e0a 100644 --- a/Ethernet/utility/w5200.h +++ b/Ethernet/utility/w5200.h @@ -163,6 +163,13 @@ class W5200Class { */ void recv_data_processing(SOCKET s, uint8_t *data, uint16_t len, uint8_t peek = 0); + /** + * @brief Moves the Rx read pointer forward + * + * This function allows you to skip a number of bytes in the Rx pointer register. + */ + void skip(SOCKET s, uint16_t len); + inline void setGatewayIp(uint8_t *_addr); inline void getGatewayIp(uint8_t *_addr); diff --git a/Ethernet/utility/w5500.cpp b/Ethernet/utility/w5500.cpp index 07694b9..a3e5a42 100644 --- a/Ethernet/utility/w5500.cpp +++ b/Ethernet/utility/w5500.cpp @@ -88,6 +88,14 @@ void W5500Class::recv_data_processing(SOCKET s, uint8_t *data, uint16_t len, uin } } +void W5500Class::skip(SOCKET s, uint16_t len) +{ + uint16_t ptr; + ptr = readSnRX_RD(s); + ptr += len; + writeSnRX_RD(s, ptr); +} + void W5500Class::read_data(SOCKET s, volatile uint8_t *src, volatile uint8_t *dst, uint16_t len) { uint8_t cntl_byte = (0x18+(s<<5)); diff --git a/Ethernet/utility/w5500.h b/Ethernet/utility/w5500.h index e1e0ce1..389d59d 100644 --- a/Ethernet/utility/w5500.h +++ b/Ethernet/utility/w5500.h @@ -166,6 +166,13 @@ class W5500Class { */ void recv_data_processing(SOCKET s, uint8_t *data, uint16_t len, uint8_t peek = 0); + /** + * @brief Moves the Rx read pointer forward + * + * This function allows you to skip a number of bytes in the Rx pointer register. + */ + void skip(SOCKET s, uint16_t len); + inline void setGatewayIp(uint8_t *_addr); inline void getGatewayIp(uint8_t *_addr); From bf9755aa8631ef86b00c8468087662c50df735ba Mon Sep 17 00:00:00 2001 From: Tobias Ebsen Date: Mon, 30 Sep 2013 18:53:55 +0200 Subject: [PATCH 03/11] Flush UDP by moving Rx pointer forward --- Ethernet/EthernetUdp.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Ethernet/EthernetUdp.cpp b/Ethernet/EthernetUdp.cpp index 3760052..123500b 100644 --- a/Ethernet/EthernetUdp.cpp +++ b/Ethernet/EthernetUdp.cpp @@ -210,9 +210,9 @@ void EthernetUDP::flush() // should only occur if recv fails after telling us the data is there, lets // hope the w5100 always behaves :) - while (_remaining) + if (_remaining) { - read(); + W5100.skip(_remaining); } } From cabef988e1995fd9d4a28cbfbbf96d730762d5dc Mon Sep 17 00:00:00 2001 From: Tobias Ebsen Date: Mon, 30 Sep 2013 20:34:41 +0200 Subject: [PATCH 04/11] Added tx/rx memory size functions --- Ethernet/utility/w5100.cpp | 57 +++++++++++++++++++++++++++++++------- Ethernet/utility/w5100.h | 10 ++++--- Ethernet/utility/w5200.cpp | 43 +++++++++++++++++++++------- Ethernet/utility/w5200.h | 10 ++++--- Ethernet/utility/w5500.cpp | 20 +++++++++++-- Ethernet/utility/w5500.h | 6 ++-- 6 files changed, 114 insertions(+), 32 deletions(-) diff --git a/Ethernet/utility/w5100.cpp b/Ethernet/utility/w5100.cpp index 679504e..cef52b1 100644 --- a/Ethernet/utility/w5100.cpp +++ b/Ethernet/utility/w5100.cpp @@ -34,12 +34,49 @@ void W5100Class::init(void) initSS(); writeMR(1<> 10; + uint8_t log2 = 0; + while (size >>= 1) ++log2; + msr |= log2 << (i * 2); + } + writeTMSR(msr); + + SMASK[0] = SSIZE[0] - 1; + SBASE[0] = TXBUF_BASE; + for (int i=1; i> 10; + uint8_t log2 = 0; + while (size >>= 1) ++log2; + msr |= log2 << (i * 2); + } + writeRMSR(msr); + + RMASK[0] = RSIZE[0] - 1; + RBASE[0] = RXBUF_BASE; + for (int i=1; i SSIZE) + if (offset + len > SSIZE[s]) { // Wrap around circular buffer - uint16_t size = SSIZE - offset; + uint16_t size = SSIZE[s] - offset; write(dstAddr, data, size); write(SBASE[s], data + size, len - size); } @@ -115,12 +152,12 @@ void W5100Class::read_data(SOCKET s, volatile uint8_t *src, volatile uint8_t *ds uint16_t src_mask; uint16_t src_ptr; - src_mask = (uint16_t)src & RMASK; + src_mask = (uint16_t)src & RMASK[s]; src_ptr = RBASE[s] + src_mask; - if( (src_mask + len) > RSIZE ) + if( (src_mask + len) > RSIZE[s] ) { - size = RSIZE - src_mask; + size = RSIZE[s] - src_mask; read(src_ptr, (uint8_t *)dst, size); dst += size; read(RBASE[s], (uint8_t *) dst, len - size); diff --git a/Ethernet/utility/w5100.h b/Ethernet/utility/w5100.h index 3bfb1aa..b856561 100644 --- a/Ethernet/utility/w5100.h +++ b/Ethernet/utility/w5100.h @@ -203,6 +203,8 @@ class W5100Class { uint16_t getTXFreeSize(SOCKET s); uint16_t getRXReceivedSize(SOCKET s); + void setTXMemorySizes(uint16_t * sizes); + void setRXMemorySizes(uint16_t * sizes); // W5100 Registers // --------------- @@ -327,12 +329,12 @@ class W5100Class { static const uint8_t RST = 7; // Reset BIT static const int SOCKETS = 4; - static const uint16_t SMASK = 0x07FF; // Tx buffer MASK - static const uint16_t RMASK = 0x07FF; // Rx buffer MASK + uint16_t SMASK[SOCKETS]; // Tx buffer MASK + uint16_t RMASK[SOCKETS]; // Rx buffer MASK public: - static const uint16_t SSIZE = 2048; // Max Tx buffer size + uint16_t SSIZE[SOCKETS]; // Max Tx buffer size private: - static const uint16_t RSIZE = 2048; // Max Rx buffer size + uint16_t RSIZE[SOCKETS]; // Max Rx buffer size uint16_t SBASE[SOCKETS]; // Tx buffer base address uint16_t RBASE[SOCKETS]; // Rx buffer base address diff --git a/Ethernet/utility/w5200.cpp b/Ethernet/utility/w5200.cpp index 5e2aa8a..f8b99d5 100644 --- a/Ethernet/utility/w5200.cpp +++ b/Ethernet/utility/w5200.cpp @@ -33,13 +33,36 @@ void W5200Class::init(void) writeMR(1<> 10); + } + SMASK[0] = SSIZE[0] - 1; + SBASE[0] = TXBUF_BASE; + for (int i=1; i> 10); + } + RMASK[0] = RSIZE[0] - 1; + RBASE[0] = RXBUF_BASE; + for (int i=1; i SSIZE) + if (offset + len > SSIZE[s]) { // Wrap around circular buffer - uint16_t size = SSIZE - offset; + uint16_t size = SSIZE[s] - offset; write(dstAddr, data, size); write(SBASE[s], data + size, len - size); } @@ -115,12 +138,12 @@ void W5200Class::read_data(SOCKET s, volatile uint8_t *src, volatile uint8_t *ds uint16_t src_mask; uint16_t src_ptr; - src_mask = (uint16_t)src & RMASK; + src_mask = (uint16_t)src & RMASK[s]; src_ptr = RBASE[s] + src_mask; - if( (src_mask + len) > RSIZE ) + if( (src_mask + len) > RSIZE[s] ) { - size = RSIZE - src_mask; + size = RSIZE[s] - src_mask; read(src_ptr, (uint8_t *)dst, size); dst += size; read(RBASE[s], (uint8_t *) dst, len - size); diff --git a/Ethernet/utility/w5200.h b/Ethernet/utility/w5200.h index 22b1db6..d6b3c3d 100644 --- a/Ethernet/utility/w5200.h +++ b/Ethernet/utility/w5200.h @@ -183,6 +183,8 @@ class W5200Class { uint16_t getTXFreeSize(SOCKET s); uint16_t getRXReceivedSize(SOCKET s); + void setTXMemorySizes(uint16_t * sizes); + void setRXMemorySizes(uint16_t * sizes); // W5100 Registers // --------------- @@ -303,12 +305,12 @@ class W5200Class { private: static const uint8_t RST = 7; // Reset BIT static const int SOCKETS = 8; - static const uint16_t SMASK = 0x07FF; // Tx buffer MASK - static const uint16_t RMASK = 0x07FF; // Rx buffer MASK + uint16_t SMASK[SOCKETS]; // Tx buffer MASK + uint16_t RMASK[SOCKETS]; // Rx buffer MASK public: - static const uint16_t SSIZE = 2048; // Max Tx buffer size + uint16_t SSIZE[SOCKETS]; // Max Tx buffer size private: - static const uint16_t RSIZE = 2048; // Max Rx buffer size + uint16_t RSIZE[SOCKETS]; // Max Rx buffer size uint16_t SBASE[SOCKETS]; // Tx buffer base address uint16_t RBASE[SOCKETS]; // Rx buffer base address diff --git a/Ethernet/utility/w5500.cpp b/Ethernet/utility/w5500.cpp index 07694b9..b5cc454 100644 --- a/Ethernet/utility/w5500.cpp +++ b/Ethernet/utility/w5500.cpp @@ -25,10 +25,26 @@ void W5500Class::init(void) delay(300); SPI.begin(); + uint16_t sizes[MAX_SOCK_NUM] = {2048,2048,2048,2048,2048,2048,2048,2048}; + setTXMemorySizes(sizes); + setRXMemorySizes(sizes); +} + +void W5500Class::setTXMemorySizes(uint16_t * sizes) +{ + for (int i=0; i> 10); //0x1F - Sn_TXBUF_SIZE + } +} + +void W5500Class::setRXMemorySizes(uint16_t * sizes) +{ for (int i=0; i> 10); //0x1E - Sn_RXBUF_SIZE } } diff --git a/Ethernet/utility/w5500.h b/Ethernet/utility/w5500.h index e1e0ce1..2deafae 100644 --- a/Ethernet/utility/w5500.h +++ b/Ethernet/utility/w5500.h @@ -186,6 +186,8 @@ class W5500Class { uint16_t getTXFreeSize(SOCKET s); uint16_t getRXReceivedSize(SOCKET s); + void setTXMemorySizes(uint16_t * sizes); + void setRXMemorySizes(uint16_t * sizes); // W5500 Registers // --------------- @@ -319,9 +321,9 @@ class W5500Class { static const int SOCKETS = 8; public: - static const uint16_t SSIZE = 2048; // Max Tx buffer size + static const uint16_t SSIZE[SOCKETS]; // Max Tx buffer size private: - static const uint16_t RSIZE = 2048; // Max Rx buffer size + static const uint16_t RSIZE[SOCKETS]; // Max Rx buffer size private: #if defined(REL_GR_KURUMI) || defined(REL_GR_KURUMI_PROTOTYPE) From 8dedde9b56814226e5c91b491bffbf5bf7b65729 Mon Sep 17 00:00:00 2001 From: Tobias Ebsen Date: Mon, 30 Sep 2013 21:04:13 +0200 Subject: [PATCH 05/11] Fixed some mistakes in tx/rx memory size handling --- Ethernet/utility/socket.cpp | 10 +++++----- Ethernet/utility/w5500.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Ethernet/utility/socket.cpp b/Ethernet/utility/socket.cpp index fd3e442..971c4bd 100644 --- a/Ethernet/utility/socket.cpp +++ b/Ethernet/utility/socket.cpp @@ -99,8 +99,8 @@ uint16_t send(SOCKET s, const uint8_t * buf, uint16_t len) uint16_t ret=0; uint16_t freesize=0; - if (len > W5100.SSIZE) - ret = W5100.SSIZE; // check size not to exceed MAX size. + if (len > W5100.SSIZE[s]) + ret = W5100.SSIZE[s]; // check size not to exceed MAX size. else ret = len; @@ -199,7 +199,7 @@ uint16_t sendto(SOCKET s, const uint8_t *buf, uint16_t len, uint8_t *addr, uint1 { uint16_t ret=0; - if (len > W5100.SSIZE) ret = W5100.SSIZE; // check size not to exceed MAX size. + if (len > W5100.SSIZE[s]) ret = W5100.SSIZE[s]; // check size not to exceed MAX size. else ret = len; if @@ -316,8 +316,8 @@ uint16_t igmpsend(SOCKET s, const uint8_t * buf, uint16_t len) uint8_t status=0; uint16_t ret=0; - if (len > W5100.SSIZE) - ret = W5100.SSIZE; // check size not to exceed MAX size. + if (len > W5100.SSIZE[s]) + ret = W5100.SSIZE[s]; // check size not to exceed MAX size. else ret = len; diff --git a/Ethernet/utility/w5500.h b/Ethernet/utility/w5500.h index 2deafae..1c54071 100644 --- a/Ethernet/utility/w5500.h +++ b/Ethernet/utility/w5500.h @@ -321,9 +321,9 @@ class W5500Class { static const int SOCKETS = 8; public: - static const uint16_t SSIZE[SOCKETS]; // Max Tx buffer size + uint16_t SSIZE[SOCKETS]; // Max Tx buffer size private: - static const uint16_t RSIZE[SOCKETS]; // Max Rx buffer size + uint16_t RSIZE[SOCKETS]; // Max Rx buffer size private: #if defined(REL_GR_KURUMI) || defined(REL_GR_KURUMI_PROTOTYPE) From b72191de89d59050da2febb6ab8483384dc7dac6 Mon Sep 17 00:00:00 2001 From: Tobias Ebsen Date: Tue, 1 Oct 2013 14:22:49 +0200 Subject: [PATCH 06/11] Use the W5200 chip --- Ethernet/utility/w5100.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Ethernet/utility/w5100.h b/Ethernet/utility/w5100.h index 3bfb1aa..f5726e5 100644 --- a/Ethernet/utility/w5100.h +++ b/Ethernet/utility/w5100.h @@ -16,8 +16,8 @@ typedef uint8_t SOCKET; //#define W5100_ETHERNET_SHIELD // Arduino Ethenret Shield and Compatibles ... -//#define W5200_ETHERNET_SHIELD // WIZ820io, W5200 Ethernet Shield -#define W5500_ETHERNET_SHIELD // WIZ550io, ioShield series of WIZnet +#define W5200_ETHERNET_SHIELD // WIZ820io, W5200 Ethernet Shield +//#define W5500_ETHERNET_SHIELD // WIZ550io, ioShield series of WIZnet #if defined(W5500_ETHERNET_SHIELD) #define WIZ550io_WITH_MACADDRESS // Use assigned MAC address of WIZ550io From bafb1a50d3b9178fe778ee1d098fe5949e6f9dc2 Mon Sep 17 00:00:00 2001 From: Tobias Ebsen Date: Tue, 1 Oct 2013 14:35:19 +0200 Subject: [PATCH 07/11] Fixed bug in UDP flush() --- Ethernet/EthernetUdp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ethernet/EthernetUdp.cpp b/Ethernet/EthernetUdp.cpp index 123500b..3d03788 100644 --- a/Ethernet/EthernetUdp.cpp +++ b/Ethernet/EthernetUdp.cpp @@ -212,7 +212,7 @@ void EthernetUDP::flush() if (_remaining) { - W5100.skip(_remaining); + W5100.skip(_sock, _remaining); } } From 98f93e96d37e714a1ccec52d8b6012aa96132415 Mon Sep 17 00:00:00 2001 From: Tobias Ebsen Date: Thu, 13 Feb 2014 15:45:24 +0100 Subject: [PATCH 08/11] Added keywords.txt --- Ethernet/keywords.txt | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Ethernet/keywords.txt diff --git a/Ethernet/keywords.txt b/Ethernet/keywords.txt new file mode 100644 index 0000000..a115ca9 --- /dev/null +++ b/Ethernet/keywords.txt @@ -0,0 +1,42 @@ +####################################### +# Syntax Coloring Map For Ethernet +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### + +Ethernet KEYWORD1 +EthernetClient KEYWORD1 +EthernetServer KEYWORD1 +IPAddress KEYWORD1 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### + +status KEYWORD2 +connect KEYWORD2 +write KEYWORD2 +available KEYWORD2 +read KEYWORD2 +peek KEYWORD2 +flush KEYWORD2 +stop KEYWORD2 +connected KEYWORD2 +begin KEYWORD2 +beginPacket KEYWORD2 +endPacket KEYWORD2 +parsePacket KEYWORD2 +remoteIP KEYWORD2 +remotePort KEYWORD2 +setRXMemorySizes KEYWORD2 +setTXMemorySizes KEYWORD2 + +####################################### +# Constants (LITERAL1) +####################################### + +W5100_ETHERNET_SHIELD LITERAL1 +W5200_ETHERNET_SHIELD LITERAL1 +W5500_ETHERNET_SHIELD LITERAL1 From 753e4fff2aa155560bf608d63ee3de037fc66e65 Mon Sep 17 00:00:00 2001 From: Tobias Ebsen Date: Wed, 19 Mar 2014 11:51:01 +0100 Subject: [PATCH 09/11] Fixed memory leak with multiple calls to Ethernet.begin(mac) --- Ethernet/Ethernet.cpp | 4 +++- Ethernet/Ethernet.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Ethernet/Ethernet.cpp b/Ethernet/Ethernet.cpp index f5582dc..b69e9c8 100644 --- a/Ethernet/Ethernet.cpp +++ b/Ethernet/Ethernet.cpp @@ -15,7 +15,9 @@ uint16_t EthernetClass::_server_port[MAX_SOCK_NUM] = { 0, }; int EthernetClass::begin(void) { byte mac_address[6] ={0,}; - _dhcp = new DhcpClass(); + + if(_dhcp == NULL) + _dhcp = new DhcpClass(); // Initialise the basic info W5100.init(); diff --git a/Ethernet/Ethernet.h b/Ethernet/Ethernet.h index a115ee6..9dba31f 100644 --- a/Ethernet/Ethernet.h +++ b/Ethernet/Ethernet.h @@ -19,6 +19,8 @@ class EthernetClass { IPAddress _dnsServerAddress; DhcpClass* _dhcp; public: + EthernetClass() : _dhcp(NULL) {} + static uint8_t _state[MAX_SOCK_NUM]; static uint16_t _server_port[MAX_SOCK_NUM]; From 1a5870bf431b6ca521ae559448d9309ba2e2a99a Mon Sep 17 00:00:00 2001 From: Tobias Ebsen Date: Fri, 9 May 2014 15:39:04 +0200 Subject: [PATCH 10/11] Removes a redundant SPI command and allows detection of broken socket --- Ethernet/EthernetUdp.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Ethernet/EthernetUdp.cpp b/Ethernet/EthernetUdp.cpp index 3d03788..6e35fa7 100644 --- a/Ethernet/EthernetUdp.cpp +++ b/Ethernet/EthernetUdp.cpp @@ -120,8 +120,6 @@ int EthernetUDP::parsePacket() // discard any remaining bytes in the last packet flush(); - if (W5100.getRXReceivedSize(_sock) > 0) - { //HACK - hand-parse the UDP packet using TCP recv method uint8_t tmpBuf[8]; int ret =0; @@ -139,9 +137,6 @@ int EthernetUDP::parsePacket() ret = _remaining; } return ret; - } - // There aren't any packets available - return 0; } int EthernetUDP::read() From 5bc89b337143b7c4055b548cce5629c46d2ca38a Mon Sep 17 00:00:00 2001 From: Tobias Ebsen Date: Fri, 9 May 2014 15:52:51 +0200 Subject: [PATCH 11/11] Moved files from Ethernet folder to root --- Ethernet/Dhcp.cpp => Dhcp.cpp | 0 Ethernet/Dhcp.h => Dhcp.h | 0 Ethernet/Dns.cpp => Dns.cpp | 0 Ethernet/Dns.h => Dns.h | 0 Ethernet/Ethernet.cpp => Ethernet.cpp | 0 Ethernet/Ethernet.h => Ethernet.h | 0 Ethernet/EthernetClient.cpp => EthernetClient.cpp | 0 Ethernet/EthernetClient.h => EthernetClient.h | 0 Ethernet/EthernetServer.cpp => EthernetServer.cpp | 0 Ethernet/EthernetServer.h => EthernetServer.h | 0 Ethernet/EthernetUdp.cpp => EthernetUdp.cpp | 0 Ethernet/EthernetUdp.h => EthernetUdp.h | 0 Ethernet/Twitter.cpp => Twitter.cpp | 0 Ethernet/Twitter.h => Twitter.h | 0 .../BarometricPressureWebServer/BarometricPressureWebServer.ino | 0 {Ethernet/examples => examples}/ChatServer/ChatServer.ino | 0 .../DhcpAddressPrinter/DhcpAddressPrinter.ino | 0 {Ethernet/examples => examples}/DhcpChatServer/DhcpChatServer.ino | 0 {Ethernet/examples => examples}/TelnetClient/TelnetClient.ino | 0 .../examples => examples}/Twitter_Serial_GW/Twitter_Serial_GW.ino | 0 .../Twitter_SimplePost/Twitter_SimplePost.ino | 0 .../UDPSendReceiveString/UDPSendReceiveString.ino | 0 {Ethernet/examples => examples}/UdpNtpClient/UdpNtpClient.ino | 0 {Ethernet/examples => examples}/WebClient/WebClient.ino | 0 .../WebClientRepeating/WebClientRepeating.ino | 0 {Ethernet/examples => examples}/WebServer/WebServer.ino | 0 {Ethernet/examples => examples}/XivelyClient/XivelyClient.ino | 0 .../XivelyClientString/XivelyClientString.ino | 0 Ethernet/keywords.txt => keywords.txt | 0 Ethernet/util.h => util.h | 0 {Ethernet/utility => utility}/socket.cpp | 0 {Ethernet/utility => utility}/socket.h | 0 {Ethernet/utility => utility}/w5100.cpp | 0 {Ethernet/utility => utility}/w5100.h | 0 {Ethernet/utility => utility}/w5200.cpp | 0 {Ethernet/utility => utility}/w5200.h | 0 {Ethernet/utility => utility}/w5500.cpp | 0 {Ethernet/utility => utility}/w5500.h | 0 38 files changed, 0 insertions(+), 0 deletions(-) rename Ethernet/Dhcp.cpp => Dhcp.cpp (100%) rename Ethernet/Dhcp.h => Dhcp.h (100%) rename Ethernet/Dns.cpp => Dns.cpp (100%) rename Ethernet/Dns.h => Dns.h (100%) rename Ethernet/Ethernet.cpp => Ethernet.cpp (100%) rename Ethernet/Ethernet.h => Ethernet.h (100%) rename Ethernet/EthernetClient.cpp => EthernetClient.cpp (100%) rename Ethernet/EthernetClient.h => EthernetClient.h (100%) rename Ethernet/EthernetServer.cpp => EthernetServer.cpp (100%) rename Ethernet/EthernetServer.h => EthernetServer.h (100%) rename Ethernet/EthernetUdp.cpp => EthernetUdp.cpp (100%) rename Ethernet/EthernetUdp.h => EthernetUdp.h (100%) rename Ethernet/Twitter.cpp => Twitter.cpp (100%) rename Ethernet/Twitter.h => Twitter.h (100%) rename {Ethernet/examples => examples}/BarometricPressureWebServer/BarometricPressureWebServer.ino (100%) rename {Ethernet/examples => examples}/ChatServer/ChatServer.ino (100%) rename {Ethernet/examples => examples}/DhcpAddressPrinter/DhcpAddressPrinter.ino (100%) rename {Ethernet/examples => examples}/DhcpChatServer/DhcpChatServer.ino (100%) rename {Ethernet/examples => examples}/TelnetClient/TelnetClient.ino (100%) rename {Ethernet/examples => examples}/Twitter_Serial_GW/Twitter_Serial_GW.ino (100%) rename {Ethernet/examples => examples}/Twitter_SimplePost/Twitter_SimplePost.ino (100%) rename {Ethernet/examples => examples}/UDPSendReceiveString/UDPSendReceiveString.ino (100%) rename {Ethernet/examples => examples}/UdpNtpClient/UdpNtpClient.ino (100%) rename {Ethernet/examples => examples}/WebClient/WebClient.ino (100%) rename {Ethernet/examples => examples}/WebClientRepeating/WebClientRepeating.ino (100%) rename {Ethernet/examples => examples}/WebServer/WebServer.ino (100%) rename {Ethernet/examples => examples}/XivelyClient/XivelyClient.ino (100%) rename {Ethernet/examples => examples}/XivelyClientString/XivelyClientString.ino (100%) rename Ethernet/keywords.txt => keywords.txt (100%) rename Ethernet/util.h => util.h (100%) rename {Ethernet/utility => utility}/socket.cpp (100%) rename {Ethernet/utility => utility}/socket.h (100%) rename {Ethernet/utility => utility}/w5100.cpp (100%) rename {Ethernet/utility => utility}/w5100.h (100%) rename {Ethernet/utility => utility}/w5200.cpp (100%) rename {Ethernet/utility => utility}/w5200.h (100%) rename {Ethernet/utility => utility}/w5500.cpp (100%) rename {Ethernet/utility => utility}/w5500.h (100%) diff --git a/Ethernet/Dhcp.cpp b/Dhcp.cpp similarity index 100% rename from Ethernet/Dhcp.cpp rename to Dhcp.cpp diff --git a/Ethernet/Dhcp.h b/Dhcp.h similarity index 100% rename from Ethernet/Dhcp.h rename to Dhcp.h diff --git a/Ethernet/Dns.cpp b/Dns.cpp similarity index 100% rename from Ethernet/Dns.cpp rename to Dns.cpp diff --git a/Ethernet/Dns.h b/Dns.h similarity index 100% rename from Ethernet/Dns.h rename to Dns.h diff --git a/Ethernet/Ethernet.cpp b/Ethernet.cpp similarity index 100% rename from Ethernet/Ethernet.cpp rename to Ethernet.cpp diff --git a/Ethernet/Ethernet.h b/Ethernet.h similarity index 100% rename from Ethernet/Ethernet.h rename to Ethernet.h diff --git a/Ethernet/EthernetClient.cpp b/EthernetClient.cpp similarity index 100% rename from Ethernet/EthernetClient.cpp rename to EthernetClient.cpp diff --git a/Ethernet/EthernetClient.h b/EthernetClient.h similarity index 100% rename from Ethernet/EthernetClient.h rename to EthernetClient.h diff --git a/Ethernet/EthernetServer.cpp b/EthernetServer.cpp similarity index 100% rename from Ethernet/EthernetServer.cpp rename to EthernetServer.cpp diff --git a/Ethernet/EthernetServer.h b/EthernetServer.h similarity index 100% rename from Ethernet/EthernetServer.h rename to EthernetServer.h diff --git a/Ethernet/EthernetUdp.cpp b/EthernetUdp.cpp similarity index 100% rename from Ethernet/EthernetUdp.cpp rename to EthernetUdp.cpp diff --git a/Ethernet/EthernetUdp.h b/EthernetUdp.h similarity index 100% rename from Ethernet/EthernetUdp.h rename to EthernetUdp.h diff --git a/Ethernet/Twitter.cpp b/Twitter.cpp similarity index 100% rename from Ethernet/Twitter.cpp rename to Twitter.cpp diff --git a/Ethernet/Twitter.h b/Twitter.h similarity index 100% rename from Ethernet/Twitter.h rename to Twitter.h diff --git a/Ethernet/examples/BarometricPressureWebServer/BarometricPressureWebServer.ino b/examples/BarometricPressureWebServer/BarometricPressureWebServer.ino similarity index 100% rename from Ethernet/examples/BarometricPressureWebServer/BarometricPressureWebServer.ino rename to examples/BarometricPressureWebServer/BarometricPressureWebServer.ino diff --git a/Ethernet/examples/ChatServer/ChatServer.ino b/examples/ChatServer/ChatServer.ino similarity index 100% rename from Ethernet/examples/ChatServer/ChatServer.ino rename to examples/ChatServer/ChatServer.ino diff --git a/Ethernet/examples/DhcpAddressPrinter/DhcpAddressPrinter.ino b/examples/DhcpAddressPrinter/DhcpAddressPrinter.ino similarity index 100% rename from Ethernet/examples/DhcpAddressPrinter/DhcpAddressPrinter.ino rename to examples/DhcpAddressPrinter/DhcpAddressPrinter.ino diff --git a/Ethernet/examples/DhcpChatServer/DhcpChatServer.ino b/examples/DhcpChatServer/DhcpChatServer.ino similarity index 100% rename from Ethernet/examples/DhcpChatServer/DhcpChatServer.ino rename to examples/DhcpChatServer/DhcpChatServer.ino diff --git a/Ethernet/examples/TelnetClient/TelnetClient.ino b/examples/TelnetClient/TelnetClient.ino similarity index 100% rename from Ethernet/examples/TelnetClient/TelnetClient.ino rename to examples/TelnetClient/TelnetClient.ino diff --git a/Ethernet/examples/Twitter_Serial_GW/Twitter_Serial_GW.ino b/examples/Twitter_Serial_GW/Twitter_Serial_GW.ino similarity index 100% rename from Ethernet/examples/Twitter_Serial_GW/Twitter_Serial_GW.ino rename to examples/Twitter_Serial_GW/Twitter_Serial_GW.ino diff --git a/Ethernet/examples/Twitter_SimplePost/Twitter_SimplePost.ino b/examples/Twitter_SimplePost/Twitter_SimplePost.ino similarity index 100% rename from Ethernet/examples/Twitter_SimplePost/Twitter_SimplePost.ino rename to examples/Twitter_SimplePost/Twitter_SimplePost.ino diff --git a/Ethernet/examples/UDPSendReceiveString/UDPSendReceiveString.ino b/examples/UDPSendReceiveString/UDPSendReceiveString.ino similarity index 100% rename from Ethernet/examples/UDPSendReceiveString/UDPSendReceiveString.ino rename to examples/UDPSendReceiveString/UDPSendReceiveString.ino diff --git a/Ethernet/examples/UdpNtpClient/UdpNtpClient.ino b/examples/UdpNtpClient/UdpNtpClient.ino similarity index 100% rename from Ethernet/examples/UdpNtpClient/UdpNtpClient.ino rename to examples/UdpNtpClient/UdpNtpClient.ino diff --git a/Ethernet/examples/WebClient/WebClient.ino b/examples/WebClient/WebClient.ino similarity index 100% rename from Ethernet/examples/WebClient/WebClient.ino rename to examples/WebClient/WebClient.ino diff --git a/Ethernet/examples/WebClientRepeating/WebClientRepeating.ino b/examples/WebClientRepeating/WebClientRepeating.ino similarity index 100% rename from Ethernet/examples/WebClientRepeating/WebClientRepeating.ino rename to examples/WebClientRepeating/WebClientRepeating.ino diff --git a/Ethernet/examples/WebServer/WebServer.ino b/examples/WebServer/WebServer.ino similarity index 100% rename from Ethernet/examples/WebServer/WebServer.ino rename to examples/WebServer/WebServer.ino diff --git a/Ethernet/examples/XivelyClient/XivelyClient.ino b/examples/XivelyClient/XivelyClient.ino similarity index 100% rename from Ethernet/examples/XivelyClient/XivelyClient.ino rename to examples/XivelyClient/XivelyClient.ino diff --git a/Ethernet/examples/XivelyClientString/XivelyClientString.ino b/examples/XivelyClientString/XivelyClientString.ino similarity index 100% rename from Ethernet/examples/XivelyClientString/XivelyClientString.ino rename to examples/XivelyClientString/XivelyClientString.ino diff --git a/Ethernet/keywords.txt b/keywords.txt similarity index 100% rename from Ethernet/keywords.txt rename to keywords.txt diff --git a/Ethernet/util.h b/util.h similarity index 100% rename from Ethernet/util.h rename to util.h diff --git a/Ethernet/utility/socket.cpp b/utility/socket.cpp similarity index 100% rename from Ethernet/utility/socket.cpp rename to utility/socket.cpp diff --git a/Ethernet/utility/socket.h b/utility/socket.h similarity index 100% rename from Ethernet/utility/socket.h rename to utility/socket.h diff --git a/Ethernet/utility/w5100.cpp b/utility/w5100.cpp similarity index 100% rename from Ethernet/utility/w5100.cpp rename to utility/w5100.cpp diff --git a/Ethernet/utility/w5100.h b/utility/w5100.h similarity index 100% rename from Ethernet/utility/w5100.h rename to utility/w5100.h diff --git a/Ethernet/utility/w5200.cpp b/utility/w5200.cpp similarity index 100% rename from Ethernet/utility/w5200.cpp rename to utility/w5200.cpp diff --git a/Ethernet/utility/w5200.h b/utility/w5200.h similarity index 100% rename from Ethernet/utility/w5200.h rename to utility/w5200.h diff --git a/Ethernet/utility/w5500.cpp b/utility/w5500.cpp similarity index 100% rename from Ethernet/utility/w5500.cpp rename to utility/w5500.cpp diff --git a/Ethernet/utility/w5500.h b/utility/w5500.h similarity index 100% rename from Ethernet/utility/w5500.h rename to utility/w5500.h