Giter Site home page Giter Site logo

iolibrary_driver's People

Contributors

bangbh81 avatar bingdo avatar bjnhur avatar coolizard avatar drojf avatar fetzerch avatar fishjimi avatar giungkim avatar hkjung avatar hubertxie avatar hubmartin avatar irinakim12 avatar javakys avatar joon8787 avatar kaizen8501 avatar khj098765 avatar koynovstas avatar matthew1205 avatar midnightcow avatar mrdiba avatar newam avatar scarletwiz avatar teddywiz avatar wizbecky avatar wiznet-mason avatar yaozhiman avatar yous avatar zhouchuanfu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

iolibrary_driver's Issues

Integer conversion warning

Hi,

first I will thank you for the great work. ioLibrary_Driver is realy a great lib!

I got a warning in the TI compiler in the socket.c file. Currently it is line 436

else if(tmp & Sn_IR_TIMEOUT)
{
setSn_IR(sn, Sn_IR_TIMEOUT);
len = SOCKERR_TIMEOUT;
break;
}

which ended up in a warning like this

"#69-D integer conversion resulted in a change of sign socket.c"

I think it is not only a warning, because SOCKERR_TIMEOUT is negative (-13) and len is an unit16_t, so it is a bug.

Kind regards

Indentation

This project has a mixture of spaces and tabs for indention an no .editorconfig file. This makes the source code hard to read both in an editor and on the github website.

problem about httpserver

Hello,

I am using your httpserver source files,here is some of my code to use the httpserver:

uint8_t http_server_tx_buf[2048] = {0,},http_server_rx_buf[2048] = {0,},socknumlist[] {SOCK_HTTP_SERVER};
    uint8_t *html = "<html>test</html>";
    uint8_t *name = "index.html";
    reg_httpServer_webContent(name, html);
    httpServer_init(http_server_tx_buf, http_server_rx_buf, 1, socknumlist);

Then i run a httpserver task per second in freeRTOS:

void http_server_task(void *pvParameters)
{
    while(1)
    {
        httpServer_run(SOCK_HTTP_SERVER);
        vTaskDelay(1000);
    }
}

Then i request the webpage via chrome several times:

1 request-> test

2 request-> (blank)

3 request-> (blank)

4 request>-> �狚髌��H唿A驁0�

5 request>-> ð?ýôçntp task

6 request>-> � �ø��o ý÷�ù�à

... only the first time i got a correct response

then i debug the code in send_http_response_body function(start at line 457):

	if(send_len) send(s, buf, send_len);
	else flag_datasend_end = 1;

	if(flag_datasend_end)
	{
		HTTPSock_Status[get_seqnum].file_start = 0;
		HTTPSock_Status[get_seqnum].file_len = 0;
		HTTPSock_Status[get_seqnum].file_offset = 0;
		flag_datasend_end = 0;
	}
	else
	{
		HTTPSock_Status[get_seqnum].file_offset += send_len;
#ifdef _HTTPSERVER_DEBUG_
		printf("> HTTPSocket[%d] : HTTP Response body - offset [ %ld ]\r\n", s, HTTPSock_Status[get_seqnum].file_offset);
#endif
	}

it can never achieve flag_datasend_end =1,so HTTPSock_Status[get_seqnum].file_offset += send_len runs every request, next time i request the webpage,i guess this offsetpoint to a wrong address.so i can't get correct response.

Thank you for your help.

Potentially incorrect Host Name during DHCP

Hi.
There are following lines of code inside module dhcp.c in functions send_DHCP_DISCOVER() and send_DHCP_REQUEST() :

	// host name
	pDHCPMSG->OPT[k++] = hostName;
	pDHCPMSG->OPT[k++] = 0;          // fill zero length of hostname
	for(i = 0 ; HOST_NAME[i] != 0; i++)
   	pDHCPMSG->OPT[k++] = HOST_NAME[i];
	pDHCPMSG->OPT[k++] = DHCP_CHADDR[3];
	pDHCPMSG->OPT[k++] = DHCP_CHADDR[4];
	pDHCPMSG->OPT[k++] = DHCP_CHADDR[5];
	pDHCPMSG->OPT[k - (i+3+1)] = i+3; // length of hostname

This code adds the last three bytes of the MAC address to the constant DCHP_HOST_NAME, which in sum forms the full DHCP host name. The problem may occur if MAC address contains bytes smaller than 0x20. Some routers (for example, Zyxel Keenetic Omni II) in this case cease to display the page with DHCP clients list at all.
I propose to replace the above code with the following:

	// host name
	pDHCPMSG->OPT[k++] = hostName;
	pDHCPMSG->OPT[k++] = 0;          // fill zero length of hostname
	for(i = 0 ; HOST_NAME[i] != 0; i++)
   	pDHCPMSG->OPT[k++] = HOST_NAME[i];
	pDHCPMSG->OPT[k++] = NibbleToHex(DHCP_CHADDR[3] >> 4); 
	pDHCPMSG->OPT[k++] = NibbleToHex(DHCP_CHADDR[3]);
	pDHCPMSG->OPT[k++] = NibbleToHex(DHCP_CHADDR[4] >> 4); 
	pDHCPMSG->OPT[k++] = NibbleToHex(DHCP_CHADDR[4]);
	pDHCPMSG->OPT[k++] = NibbleToHex(DHCP_CHADDR[5] >> 4); 
	pDHCPMSG->OPT[k++] = NibbleToHex(DHCP_CHADDR[5]);
	pDHCPMSG->OPT[k - (i+6+1)] = i+6; // length of hostname

and to add function NibbleToHex():

char NibbleToHex(uint8_t nibble)
{
  nibble &= 0x0F;
  if (nibble <= 9)
    return nibble + '0';
  else 
    return nibble + ('A'-0x0A);
}

DHCP client stops working sometimes

Hello,
I am using your DHCP client source files. The problem is that DHCP client stops working sometimes. The program still waits if the socket is closed (file: socket.c, line: 193 - while(getSn_SR(sn) == SOCK_CLOSED); ).
I would understand that this problem can happen when the ethernet cable is disconnected (but this situation should be caught). But this situation happends when the cable is connected for all the time.

Thank you for your help.

How to compile w5500 driver for android.

Dear,

I want to poring it to android. How to compile w5500 driver for andrioid? I see w5300 code at path "kernel/drivers/net/ethernet/wiznet". Why not add w5500 code into kernel driver?.
Thanks.

strindex unused

strindex is unused in MQTTFormat_toClientString and MQTTFormat_toServerString.

compiler warnings are generated because of this.

ioLibrary_Driver/Internet/MQTT/MQTTPacket/src/MQTTFormat.c: In function 'MQTTFormat_toClientString':
ioLibrary_Driver/Internet/MQTT/MQTTPacket/src/MQTTFormat.c:122:6: warning: variable 'strindex' set but not used [-Wunused-but-set-variable]
  int strindex = 0;
      ^
ioLibrary_Driver/Internet/MQTT/MQTTPacket/src/MQTTFormat.c: In function 'MQTTFormat_toServerString':
ioLibrary_Driver/Internet/MQTT/MQTTPacket/src/MQTTFormat.c:190:6: warning: variable 'strindex' set but not used [-Wunused-but-set-variable]
  int strindex = 0;
      ^

Network_init(); not setting the Mac, IP, Subnet , Gw, DNS

while using the network_init(); function the mac, ip, subnet, gw, dns do not get set while using this library.

`void network_init(void)
{
uint8_t tmpstr[6];
ctlnetwork(CN_SET_NETINFO, (void*)&gWIZNETINFO);
ctlnetwork(CN_GET_NETINFO, (void*)&gWIZNETINFO);

// Display Network Information
ctlwizchip(CW_GET_ID,(void*)tmpstr);
printf("\r\n=== %s NET CONF ===\r\n",(char*)tmpstr);
printf("MAC: %02X:%02X:%02X:%02X:%02X:%02X\r\n",gWIZNETINFO.mac[0],gWIZNETINFO.mac[1],gWIZNETINFO.mac[2],
	  gWIZNETINFO.mac[3],gWIZNETINFO.mac[4],gWIZNETINFO.mac[5]);
printf("SIP: %d.%d.%d.%d\r\n", gWIZNETINFO.ip[0],gWIZNETINFO.ip[1],gWIZNETINFO.ip[2],gWIZNETINFO.ip[3]);
printf("GAR: %d.%d.%d.%d\r\n", gWIZNETINFO.gw[0],gWIZNETINFO.gw[1],gWIZNETINFO.gw[2],gWIZNETINFO.gw[3]);
printf("SUB: %d.%d.%d.%d\r\n", gWIZNETINFO.sn[0],gWIZNETINFO.sn[1],gWIZNETINFO.sn[2],gWIZNETINFO.sn[3]);
printf("DNS: %d.%d.%d.%d\r\n", gWIZNETINFO.dns[0],gWIZNETINFO.dns[1],gWIZNETINFO.dns[2],gWIZNETINFO.dns[3]);
printf("======================\r\n");

}
`

HTTP POST & Get

Dear Wiznet,

I would like to create a HTTP post & get message to a server. I am using the Wiznet5100.
How would I start with this using the HTTP library included.

Thanks a lot for any help,

Mark

See I have a problem with the code display or download, for ioLibrary_Driver/Ethernet/wizchip_conf.h

line 36-line 44
//! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
//! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
//! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
//! INTERRUPTION) HOWEVER CAUSED AND#ifdef __cplusplus
extern ¡°C¡± {
#endif ON ANY THEORY OF LIABILITY, WHETHER IN
//! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
//! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
//! THE POSSIBILITY OF SUCH DAMAGE.

//! is missing for some lines

Ethernet/socket.c:520:36: error: suggest parentheses around comparison in operand of '&' [-Werror=parentheses]

This file cannot be build with -Werror

Ethernet/socket.c: In function 'sendto':
Ethernet/socket.c:520:36: error: suggest parentheses around comparison in operand of '&' [-Werror=parentheses]
if((taddr == 0) && (getSn_MR(sn)&Sn_MR_MACRAW != Sn_MR_MACRAW)) return SOCKERR_IPINVALID;
^
Ethernet/socket.c:521:36: error: suggest parentheses around comparison in operand of '&' [-Werror=parentheses]
if((port == 0) && (getSn_MR(sn)&Sn_MR_MACRAW != Sn_MR_MACRAW)) return SOCKERR_PORTZERO;
^

flush udp buffer

Hi all, is the flush/clear/refresh udp socket buffer function implemented in the library? I couldn't find it. I'm using W5500 to communicate with a realtime controller. It is important to flush the buffer regularly.

Thanks.

Macro name error creating infinite loop

In the file wizchip_conf.c lines 442 and 476 there is : #if __WIZCHIP_ < W5200

But __WIZCHIP_ doesn't exist, it should be _WIZCHIP_, with only one underscore.

Because it doesn't exist, it's value is 0 so we always execute the content of the condition and this content create an infinite loop when we compile with an W5500.

Multibyte transactions with w5100

Hello!
While integrating your library into my AVR weather station project, I ran into an issue.
I'm not exactly sure if this is a bug, or if it's just a configuration issue.

Currently I struggle even to initialize the W5100 so that it responds to ping.
I was able to track down the problem to a change in V3.0 where in WIZCHIP_WRITE_BUF and WIZCHIP_READ_BUF the chip select and deselect calls have been moved out of the loop to be beginning and end of the function.

If I move them back into the loop so that the chip gets selected and deselected on every transaction, it suddenly works fine. What I understand from the datasheet is also that this is the correct way for the W5100 and that the multi byte transactions are only supported in the W5200 and later.

Can you confirm this? Or am I missing something?
Hardware wise wise I am using an Aukru W5100 Ethernet Shield and an ATMega328P.

Cheers,
Christian

IP Address set two times

Into dhcp.c lines 915 et 916 there are two call to setSIPR(zeroip);
I suppose that it is a mistake.

ioLibrary Licensing

There doesn't seem to be a Liscence.txt - what licence is this project under? Can it be used commercially without any fees?

_WIZCHIP_ < W5200 : wizchip_init : Infinite loop when buffer size is set to 0

There are 2 lines with an infinite loop when there is a socket buffer set with zero size.

https://github.com/Wiznet/ioLibrary_Driver/blob/master/Ethernet/wizchip_conf.c#L444
https://github.com/Wiznet/ioLibrary_Driver/blob/master/Ethernet/wizchip_conf.c#L478

Test case:

#define _WIZCHIP_ 5100
#include "wizchip_conf.h"

uint8_t bufSize[2][4] = { {8,0,0,0},{8,0,0,0}};
wizchip_init(bufSize[0], bufSize[1]);

A possible fix can be:

while((txsize[i] >> j != 1) && (txsize[i] != 0)){j++;}
while((rxsize[i] >> j != 1) && (rxsize[i] != 0)){j++;}

With the above, j=0, therefore
setSn_RXBUF_SIZE(i, j);
will set a zero buffer size for that socket.

  • Arjan

type can be returned unitialized

the variable type can be returned uninitialized, generates this warning.

ioLibrary_Driver/Internet/DHCP/dhcp.c: In function 'parseDHCPMSG':
ioLibrary_Driver/Internet/DHCP/dhcp.c:671:2: warning: 'type' may be used uninitialized in this function [-Wmaybe-uninitialized]
  return type;
  ^

Use of Malloc

httpServer.c uses Malloc to store strings. In smaller embedded targets (like AVR), malloc is problematic. Could we get rid of the malloc in favor of a fixed length string buffer or perhaps allow a #define?

In httpServer.c line 678.

Ethernet/wizchip_conf.c:837:10: error: unused variable 'k' [-Werror=unused-variable]

This file cannot be build with -Werror

Ethernet/wizchip_conf.c: In function 'wizchip_setnetinfo':
Ethernet/wizchip_conf.c:837:10: error: unused variable 'k' [-Werror=unused-variable]
int i,j,k;
^
Ethernet/wizchip_conf.c:837:8: error: unused variable 'j' [-Werror=unused-variable]
int i,j,k;
^
Ethernet/wizchip_conf.c:837:6: error: unused variable 'i' [-Werror=unused-variable]
int i,j,k;
^

Define what chip is used TODO

Dear Wiznet,

I am working with a Wiznet 5100 chip on a nRF52840.

ioLibrary Doxygen doument : Refer to TODO in this document
Define what chip is used in wizchip_conf.h
Define what Host I/F mode is used in wizchip_conf.

The above doxygen document does not open, and I do not know what I should change so that the program sees it as a W5100 chip.

Thanks

MQTT

Hello Sir,

It seems the latest version of Wiznet/ioLibrary_Driver from April 6 2018(W5500_PHY_LINK ) has few bugs in Internet/MQTT.

  1. Assignment from incompatible pointer type
    I have observed that w5x00_write() from mqtt_interface.c has been declared as having 3 arguments but has been assigned to a pointer mqttwrite with 4 arguments.
    line no 115 mqtt_interface.c:
    n->mqttwrite = w5x00_write;
    call from MQTTClient.c line no 36 has 4 arguments
    rc = c->ipstack->mqttwrite(c->ipstack, &c->buf[sent], length, TimerLeftMS(timer));

  2. same is the case with w5x00_read() from line no 114 in mqtt_interface.c.

  3. line no 165 from mqtt_interface.c
    uint8_t myport = 12345;
    should have been
    uint16_t myport = 12345;
    as "large integer is implicitly truncated to unsigned type"

When possibly can these bugs be fixed.

Can some body provide a temporary fix.

Thanks & Regards,
Sudhish

w550io + nrf51(pca10028) : Network initialization succeeds until first restart of host after it has been freshly flashed(programmed)

Dear all,
I was trying to add ethernet facility to my nrf51 board.
The following image should give an idea about the HW connections

imageedit_7_5302238974

The network initialization always succeeds in the case of a recently programmed host(nrf51). But when i restart the host, network initialization fails.

But if i reprogram(flash) the host with the same .hex file, network initialization succeds.......what could be the reason
After every reprogramming of the host nrf51, the network initialization of w550io succeeds

W5500 : Is not consistently able to assign GW, SUBM, IP, & MAC

I was trying to replicate the set up given in the following link:

http://wiznetmuseum.com/portfolio-items/ble-to-ethernet-thin-gateway/

connections between NRF51 and wiznet board are done as mentioned in the link.

I am using the same ioLibrary_Driver. Is not consistently able to assign GW, SUBM, IP, & MAC

But with DNS it has no problem. I am not able to figure out if the problem is with SET or GET

ctlnetwork(CN_SET_NETINFO, (void*)&gWIZNETINFO);

OR

ctlnetwork(CN_GET_NETINFO, (void*)&gWIZNETINFO);

GET gives me all zeros(00:00:00:00:00:00, 0.0.0.0) except for DNS. DNS assigns successfully

Occur a compile error in LPCXpresso IDE.

../src/ioLibrary/Ethernet/W5500/w5500.h:1179:49: error: 'struct _CRIS' has no member named '__sys_appexit'
#define WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit()

use w5500 find some thing wrong, need help,thanks

i use w5500,use iolibrary lastest from github, find some thing,

in the file "wizchip_conf.c", the function "int8_t wizphy_getphylink(void)"

#elif WIZCHIP == W5500
if(getPHYCFGR() & PHYCFGR_LNK_ON)
tmp = PHY_LINK_ON;
tmp = PHY_LINK_OFF;
#else

maybe should like this:

#elif WIZCHIP == W5500
if(getPHYCFGR() & PHYCFGR_LNK_ON)
tmp = PHY_LINK_ON;
else
tmp = PHY_LINK_OFF;
#else

if not will allway "PHY_LINK_OFF"
I'm not sure whether my idea is right or not
Maybe you can answer me
thank you very much

Issue in httpServer_run

When the remote PC closes the TCP connection while the status of the http-socket is not STATE_HTTP_RES_DONE, HTTPSock_Status[seqnum].sock_status is not reset.

Then when the TCP connection is re-established, the http socket is still in another state and therefore looses the next http request.

To solve this I added the following to "case SOCK_CLOSED" below line 233:
HTTPSock_Status[seqnum].file_len = 0;
HTTPSock_Status[seqnum].file_offset = 0;
HTTPSock_Status[seqnum].file_start = 0;
HTTPSock_Status[seqnum].sock_status = STATE_HTTP_IDLE;

Adding support for C++ (calling C functions)

It would be great when we can have C++ support with adding

#ifdef __cplusplus
extern “C” {
#endif

C prototypes

#ifdef __cplusplus
}
#endif

in .h files.

Many thanks in advance, Arjan

many compiler warnings in mqtt_interface

using gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.10) I see many compiler warnings with mqtt_interface

ioLibrary_Driver/Internet/MQTT/mqtt_interface.c: In function 'w5x00_read':
ioLibrary_Driver/Internet/MQTT/mqtt_interface.c:130:3: warning: implicit declaration of function 'recv' [-Wimplicit-function-declaration]
   return recv(n->my_socket, buffer, len);
   ^
ioLibrary_Driver/Internet/MQTT/mqtt_interface.c: In function 'w5x00_write':
ioLibrary_Driver/Internet/MQTT/mqtt_interface.c:143:3: warning: implicit declaration of function 'send' [-Wimplicit-function-declaration]
   return send(n->my_socket, buffer, len);
   ^
ioLibrary_Driver/Internet/MQTT/mqtt_interface.c: In function 'w5x00_disconnect':
ioLibrary_Driver/Internet/MQTT/mqtt_interface.c:153:2: warning: implicit declaration of function 'disconnect' [-Wimplicit-function-declaration]
  disconnect(n->my_socket);
  ^
ioLibrary_Driver/Internet/MQTT/mqtt_interface.c: In function 'ConnectNetwork':
ioLibrary_Driver/Internet/MQTT/mqtt_interface.c:167:2: warning: implicit declaration of function 'socket' [-Wimplicit-function-declaration]
  socket(n->my_socket,Sn_MR_TCP,myport,0);
  ^
ioLibrary_Driver/Internet/MQTT/mqtt_interface.c:168:2: warning: implicit declaration of function 'connect' [-Wimplicit-function-declaration]
  connect(n->my_socket,ip,port);
  ^
ioLibrary_Driver/Internet/MQTT/mqtt_interface.c: In function 'w5x00_read':
ioLibrary_Driver/Internet/MQTT/mqtt_interface.c:131:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
ioLibrary_Driver/Internet/MQTT/mqtt_interface.c: In function 'w5x00_write':
ioLibrary_Driver/Internet/MQTT/mqtt_interface.c:144:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
ioLibrary_Driver/Internet/MQTT/mqtt_interface.c: In function 'ConnectNetwork':
ioLibrary_Driver/Internet/MQTT/mqtt_interface.c:169:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
ioLibrary_Driver/Internet/MQTT/mqtt_interface.c: In function 'ConnectNetwork':
ioLibrary_Driver/Internet/MQTT/mqtt_interface.c:175:23: warning: pointer targets in passing argument 2 of 'connect' differ in signedness [-Wpointer-sign]
  connect(n->my_socket,ip,port);

NTP_SOCKET is not initialized

Hi,
I found a little problem.

In sntp.c, NTP_SOCKET should be initialized in SNTP_init, but there is no operation.

Code compatibility problem W5500 <-> W5200 and some more warnings

Hi again,

found another issue in the current master brunch.

My code is running fine with the W5500 chip initialized. If I change the wizchip_conf.h define WIZCHIP to be 5200 my code compiles without any error. But.....

I'm setting the socket interrupt mask register (SIMR) to 0x01 for socket 0 interrupts.
In the current code setSIMR of W5200 is pointing to setIMR2. But this is not correct!

I found out that
W5500 <-> W5200
IR <-> IR
IMR <-> IMR2
SIR <-> IR2
SIMR <-> IMR
Sn_IR <-> Sn_IR
Sn_IMR <-> SnIMR

This means setSIMR() should point to setIMR() and not to setIMR2()!
For SIR <-> IR2 this is correct.
The last problem is that setIMR() should point to setIMR2() but, because of the first assignement this is not possible, isn't it?

The above issue is for set and get functions.

I also get some warnigs that a comma in the typedef enums for e.g. sockint_kind at last entry is not standard! Maybe someone can fix this also.
#230-D trailing comma is nonstandard socket.h

Kind regards

Fix in DNS client

Need add reset to zero vars "retry_count" and "dns_1s_tick" everytime on DNS_init call.

diff --git a/Internet/DNS/dns.c b/Internet/DNS/dns.c
index d4e5806..b412fc2 100644
--- a/Internet/DNS/dns.c
+++ b/Internet/DNS/dns.c
@@ -120,6 +120,7 @@ uint8_t  DNS_SOCKET;    // SOCKET number for DNS
 uint16_t DNS_MSGID;     // DNS message ID
 
 uint32_t dns_1s_tick;   // for timout of DNS processing
+static uint8_t retry_count;
 
 /* converts uint16_t from network buffer to a host byte order integer. */
 uint16_t get16(uint8_t * s)
@@ -472,7 +473,6 @@ int16_t dns_makequery(uint16_t op, char * name, uint8_t * buf, uint16_t len)
 
 int8_t check_DNS_timeout(void)
 {
-	static uint8_t retry_count;
 
 	if(dns_1s_tick >= DNS_WAIT_TIME)
 	{
@@ -496,6 +496,8 @@ void DNS_init(uint8_t s, uint8_t * buf)
 	DNS_SOCKET = s; // SOCK_DNS
 	pDNSMSG = buf; // User's shared buffer
 	DNS_MSGID = DNS_MSG_ID;
+	retry_count = 0;
+	dns_1s_tick = 0;
 }
 
 /* DNS CLIENT RUN */

Missing braces

if((taddr == 0) && (getSn_MR(sn)&Sn_MR_MACRAW != Sn_MR_MACRAW)) return SOCKERR_IPINVALID;

Lines 520 and 521 generate a compiler warning for missing braces. I think the intention was to do the bitwise AND before the logical comparison:

if((taddr == 0) && ((getSn_MR(sn) & Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_IPINVALID; if((port == 0) && ((getSn_MR(sn) & Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_PORTZERO;

fix getsockopt() SO_REMAINSIZE then set SF_TCP_NODELAY

Wrong getsockopt() SO_REMAINSIZE result if socket flag is Sn_MR_TCP and SF_TCP_NODELAY

diff --git a/Ethernet/socket.c b/Ethernet/socket.c
index 995e98e..f5bc5fb 100644
--- a/Ethernet/socket.c
+++ b/Ethernet/socket.c
@@ -910,7 +910,7 @@ int8_t  getsockopt(uint8_t sn, sockopt_type sotype, void* arg)
          *(uint8_t*) arg = getSn_SR(sn);
          break;
       case SO_REMAINSIZE:
-         if(getSn_MR(sn) == Sn_MR_TCP)
+         if(getSn_MR(sn) & Sn_MR_TCP)
             *(uint16_t*)arg = getSn_RX_RSR(sn);
          else
             *(uint16_t*)arg = sock_remained_size[sn];

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.