{"action":"created","issue":{"url":"https://api.github.com/repos/esp8266/Arduino/issues/4536","repository_url":"https://api.github.com/repos/esp8266/Arduino","labels_url":"https://api.github.com/repos/esp8266/Arduino/issues/4536/labels{/name}","comments_url":"https://api.github.com/repos/esp8266/Arduino/issues/4536/comments","events_url":"https://api.github.com/repos/esp8266/Arduino/issues/4536/events","html_url":"https://github.com/esp8266/Arduino/pull/4536","id":306680870,"number":4536,"title":"uart: fix wdt input overrun","user":{"login":"d-a-v","id":4800356,"avatar_url":"https://avatars3.githubusercontent.com/u/4800356?v=4","gravatar_id":"","url":"https://api.github.com/users/d-a-v","html_url":"https://github.com/d-a-v","followers_url":"https://api.github.com/users/d-a-v/followers","following_url":"https://api.github.com/users/d-a-v/following{/other_user}","gists_url":"https://api.github.com/users/d-a-v/gists{/gist_id}","starred_url":"https://api.github.com/users/d-a-v/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/d-a-v/subscriptions","organizations_url":"https://api.github.com/users/d-a-v/orgs","repos_url":"https://api.github.com/users/d-a-v/repos","events_url":"https://api.github.com/users/d-a-v/events{/privacy}","received_events_url":"https://api.github.com/users/d-a-v/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-03-20T00:00:46Z","updated_at":"2018-03-20T23:45:51Z","closed_at":null,"author_association":"COLLABORATOR","pull_request":{"url":"https://api.github.com/repos/esp8266/Arduino/pulls/4536","html_url":"https://github.com/esp8266/Arduino/pull/4536","diff_url":"https://github.com/esp8266/Arduino/pull/4536.diff","patch_url":"https://github.com/esp8266/Arduino/pull/4536.patch"},"body":"WDT is triggerred when uart is flooded but not read (quickly enough) by user.\r\nHere's a fix with a message on debug console (generally same uart though).\r\n\r\nMCVE:\r\n```\r\n#define PRINT_INTV_MS 5000\r\n\r\nunsigned long next;\r\n\r\nvoid setup() {\r\n  Serial.setRxBufferSize(8);\r\n  Serial.begin(115200);\r\n  Serial.setDebugOutput(true);\r\n  Serial.println(\"please type in chars\");\r\n  next = millis() + PRINT_INTV_MS;\r\n}\r\n\r\nvoid loop() {\r\n  static int last = 0;\r\n  int avail = Serial.available();\r\n  if (last != avail)\r\n  {\r\n    last = avail;\r\n    Serial.printf(\"available: %i\\n\", avail);\r\n  }\r\n\r\n  if (millis() > next)\r\n  {\r\n    Serial.print(\"reading serial: \");\r\n    while (Serial.available())\r\n      Serial.print((char)Serial.read());\r\n    Serial.println();\r\n    next += PRINT_INTV_MS;\r\n  }\r\n}\r\n```\r\n\r\nA choice has to be made when receive buffer is full:\r\ndiscard oldest data, or newest data ?\r\nCurrent master tries to discard newest data (with the wdt bug)\r\nThis PR has the two (fixed) ways, I personally prefer discarding the oldest\r\n(with this scheme, I may not be the last leaving among you :)\r\n\r\nnewest discarded (input is '1234567890'):\r\n```\r\n00:42:35.122 -> SDK:2.2.1(cfd48f3)/Core:2.4.1-32-g546c8b7/lwIP:2.0.3(STABLE-2_0_3_RELEASE/glue:arduino-2.4.1)\r\n00:42:35.122 -> please type in chars\r\n00:42:38.464 -> available: 1\r\n00:42:38.465 -> available: 4\r\n00:42:38.465 -> available: 5\r\n00:42:38.497 -> available: 6\r\n00:42:38.497 -> available: 7\r\n00:42:38.497 -> available: 8\r\n00:42:38.497 -> available: 9\r\n00:42:38.497 -> available: 10\r\n00:42:38.497 -> available: 11\r\n00:42:38.497 -> uart input full!\r\n00:42:38.497 -> available: 7\r\n00:42:40.139 -> reading serial: 1234567\r\n00:42:40.139 -> available: 0\r\n```\r\n\r\noldest discarded (input is '1234567890'):\r\n```\r\n00:49:12.791 -> SDK:2.2.1(cfd48f3)/Core:2.4.1-32-g546c8b7/lwIP:2.0.3(STABLE-2_0_3_RELEASE/glue:arduino-2.4.1)\r\n00:49:12.794 -> please type in chars\r\n00:49:15.531 -> available: 1\r\n00:49:15.532 -> available: 4\r\n00:49:15.532 -> available: 5\r\n00:49:15.532 -> available: 6\r\n00:49:15.533 -> available: 7\r\n00:49:15.533 -> available: 8\r\n00:49:15.534 -> available: 9\r\n00:49:15.534 -> available: 10\r\n00:49:15.534 -> available: 11\r\n00:49:15.535 -> uart input full!\r\n00:49:15.535 -> available: 7\r\n00:49:17.796 -> reading serial: 567890\r\n00:49:17.796 -> \r\n00:49:17.796 -> available: 0\r\n00:49:22.770 -> reading serial: \r\n00:49:27.779 -> reading serial: \r\n00:49:32.791 -> reading serial: \r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/esp8266/Arduino/issues/comments/374795174","html_url":"https://github.com/esp8266/Arduino/pull/4536#issuecomment-374795174","issue_url":"https://api.github.com/repos/esp8266/Arduino/issues/4536","id":374795174,"user":{"login":"devyte","id":16824838,"avatar_url":"https://avatars0.githubusercontent.com/u/16824838?v=4","gravatar_id":"","url":"https://api.github.com/users/devyte","html_url":"https://github.com/devyte","followers_url":"https://api.github.com/users/devyte/followers","following_url":"https://api.github.com/users/devyte/following{/other_user}","gists_url":"https://api.github.com/users/devyte/gists{/gist_id}","starred_url":"https://api.github.com/users/devyte/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devyte/subscriptions","organizations_url":"https://api.github.com/users/devyte/orgs","repos_url":"https://api.github.com/users/devyte/repos","events_url":"https://api.github.com/users/devyte/events{/privacy}","received_events_url":"https://api.github.com/users/devyte/received_events","type":"User","site_admin":false},"created_at":"2018-03-20T23:45:51Z","updated_at":"2018-03-20T23:45:51Z","author_association":"COLLABORATOR","body":"I prefer discard newest data, because it keeps the data stream contiguous, but I'm ok with either option."}}
{"actor":{"display_login":"devyte"}}