{"action":"closed","issue":{"url":"https://api.github.com/repos/arduino/Arduino/issues/1049","repository_url":"https://api.github.com/repos/arduino/Arduino","labels_url":"https://api.github.com/repos/arduino/Arduino/issues/1049/labels{/name}","comments_url":"https://api.github.com/repos/arduino/Arduino/issues/1049/comments","events_url":"https://api.github.com/repos/arduino/Arduino/issues/1049/events","html_url":"https://github.com/arduino/Arduino/issues/1049","id":8397818,"number":1049,"title":"Ethernet library can hang during data transmission (in socket.cpp: send() ) [imported]","user":{"login":"cmaglie","id":423515,"avatar_url":"https://avatars.githubusercontent.com/u/423515?v=3","gravatar_id":"","url":"https://api.github.com/users/cmaglie","html_url":"https://github.com/cmaglie","followers_url":"https://api.github.com/users/cmaglie/followers","following_url":"https://api.github.com/users/cmaglie/following{/other_user}","gists_url":"https://api.github.com/users/cmaglie/gists{/gist_id}","starred_url":"https://api.github.com/users/cmaglie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmaglie/subscriptions","organizations_url":"https://api.github.com/users/cmaglie/orgs","repos_url":"https://api.github.com/users/cmaglie/repos","events_url":"https://api.github.com/users/cmaglie/events{/privacy}","received_events_url":"https://api.github.com/users/cmaglie/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/arduino/Arduino/labels/Library:%20Ethernet","name":"Library: Ethernet","color":"000000"}],"state":"closed","locked":false,"assignee":{"login":"cmaglie","id":423515,"avatar_url":"https://avatars.githubusercontent.com/u/423515?v=3","gravatar_id":"","url":"https://api.github.com/users/cmaglie","html_url":"https://github.com/cmaglie","followers_url":"https://api.github.com/users/cmaglie/followers","following_url":"https://api.github.com/users/cmaglie/following{/other_user}","gists_url":"https://api.github.com/users/cmaglie/gists{/gist_id}","starred_url":"https://api.github.com/users/cmaglie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmaglie/subscriptions","organizations_url":"https://api.github.com/users/cmaglie/orgs","repos_url":"https://api.github.com/users/cmaglie/repos","events_url":"https://api.github.com/users/cmaglie/events{/privacy}","received_events_url":"https://api.github.com/users/cmaglie/received_events","type":"User","site_admin":false},"assignees":[{"login":"cmaglie","id":423515,"avatar_url":"https://avatars.githubusercontent.com/u/423515?v=3","gravatar_id":"","url":"https://api.github.com/users/cmaglie","html_url":"https://github.com/cmaglie","followers_url":"https://api.github.com/users/cmaglie/followers","following_url":"https://api.github.com/users/cmaglie/following{/other_user}","gists_url":"https://api.github.com/users/cmaglie/gists{/gist_id}","starred_url":"https://api.github.com/users/cmaglie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmaglie/subscriptions","organizations_url":"https://api.github.com/users/cmaglie/orgs","repos_url":"https://api.github.com/users/cmaglie/repos","events_url":"https://api.github.com/users/cmaglie/events{/privacy}","received_events_url":"https://api.github.com/users/cmaglie/received_events","type":"User","site_admin":false}],"milestone":null,"comments":1,"created_at":"2012-11-15T19:03:11Z","updated_at":"2016-07-12T13:24:17Z","closed_at":"2016-07-12T13:24:17Z","body":"This is [Issue 1049](http://code.google.com/p/arduino/issues/detail?id=1049) moved from a Google Code project.\nAdded by 2012-09-25T02:13:55.000Z by [townsh...@gmail.com](http://code.google.com/u/107224959442840033725/).\nPlease review that bug for more context and additional comments, but update this bug.\n\n\nOriginal labels: Type-Defect, Priority-Medium\n\n### Original description\n\n**What steps will reproduce the problem?**\nDifficult to catch the problem since it depends on timing of sending data from the shield while incoming data.  Appears to be a coincidence issue on the exact timing.   I'm getting it to happen by continually sending data at the fastest rate possible on a TCP socket while the arduino program sends back replies using a sliding window.   Even at that, the problem takes several hours to hit, but when it does it is catastrophic.\n\n**What version of the Arduino software are you using? On what operating**\n**system?  Which Arduino board are you using?**\nArduino 1.01 with a Mega 2560 and ethernet shield (W5100).\n\n**Please provide any additional information below.**\nI've traced the problem to socket.cpp:send() by putting debug outputs to the serial port if it gets stuck in a loop there.   Here's the instrumented code:\n\nuint16_t send(SOCKET s, const uint8_t * buf, uint16_t len)\n{\n  uint8_t status=0;\n  uint16_t ret=0;\n  uint16_t freesize=0;\n\n  if (len > W5100.SSIZE) \n    ret = W5100.SSIZE; // check size not to exceed MAX size.\n  else \n    ret = len;\n\n  Serial.print('$');\n\n  // if freebuf is available, start.\n  int loopcnt=0;\n  do \n  {\n    freesize = W5100.getTXFreeSize(s);\n    status = W5100.readSnSR(s);\n    if ((status != SnSR::ESTABLISHED) && (status != SnSR::CLOSE_WAIT))\n    {\n      ret = 0; \n      break;\n    }\n    loopcnt++;\n    if (loopcnt==10)\n\tSerial.println(\"send.1\");\n  } \n  while (freesize < ret);\n\n  // copy data\n  W5100.send_data_processing(s, (uint8_t *)buf, ret);\n  W5100.execCmdSn(s, Sock_SEND);\n\n  /* +2008.01 bj */\n  loopcnt=0;\n  while ( (W5100.readSnIR(s) & SnIR::SEND_OK) != SnIR::SEND_OK ) \n  {\n    /* m2008.01 [bj] : reduce code */\n    if ( W5100.readSnSR(s) == SnSR::CLOSED )\n    {\n      close(s);\n      return 0;\n    }\n    loopcnt++;\n    if (loopcnt==1000) {\n\tSerial.print(\"send.2, SnSR=0x\");\n\tSerial.print(W5100.readSnSR(s),HEX);\n\tSerial.print(\", SnIR=0x\");\n\tSerial.print(W5100.readSnIR(s),HEX);\n\tSerial.print(\", TX_WR=0x\");\n\tSerial.print(W5100.readSnTX_WR(s),HEX);\n\tSerial.print(\", TX_RD=0x\");\n\tSerial.print(W5100.readSnTX_RD(s),HEX);\n\tSerial.println(\".\");\n\tclose(s);\n\treturn 0;\n    }\n  }\n  /* +2008.01 bj */\n  W5100.writeSnIR(s, SnIR::SEND_OK);\n  return ret;\n}\n\nThe addition to the code is the loop counter in the second loop that detects the condition.   It then prints out the values of various status registers which results in:\n\nsend.2, SnSR=0x17, SnIR=0x5, TX_WR=0x92A5, TX_RD=0x92A5.\n\nThus, it looks like everything is OK, except that the SEND bit is never signalled in the SnIR register:\nSnSR  0x17 = ESTABLISHED\nSnIR 0x5 = RECV|CON\nTX_WR==TX_RD indicates all data sent (I think??)\n\nIt seems that this may be an instance of the reported errata to the 5100 (see http://www.techw.co.jp/Download/3150A_5100_errata1_Eng.pdf )\n\n"}}
{"actor":{"display_login":"agdl"}}