{"action":"created","issue":{"url":"https://api.github.com/repos/arduino/Arduino/issues/3947","labels_url":"https://api.github.com/repos/arduino/Arduino/issues/3947/labels{/name}","comments_url":"https://api.github.com/repos/arduino/Arduino/issues/3947/comments","events_url":"https://api.github.com/repos/arduino/Arduino/issues/3947/events","html_url":"https://github.com/arduino/Arduino/issues/3947","id":110724630,"number":3947,"title":"Feature Request: Callback for \"Buffer near full\" for HardwareSerial class or HW-Flow-Control implementation","user":{"login":"Apollon77","id":11976694,"avatar_url":"https://avatars.githubusercontent.com/u/11976694?v=3","gravatar_id":"","url":"https://api.github.com/users/Apollon77","html_url":"https://github.com/Apollon77","followers_url":"https://api.github.com/users/Apollon77/followers","following_url":"https://api.github.com/users/Apollon77/following{/other_user}","gists_url":"https://api.github.com/users/Apollon77/gists{/gist_id}","starred_url":"https://api.github.com/users/Apollon77/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Apollon77/subscriptions","organizations_url":"https://api.github.com/users/Apollon77/orgs","repos_url":"https://api.github.com/users/Apollon77/repos","events_url":"https://api.github.com/users/Apollon77/events{/privacy}","received_events_url":"https://api.github.com/users/Apollon77/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-10-09T19:45:07Z","updated_at":"2015-10-13T07:03:43Z","closed_at":null,"body":"I currently try to integrate an ESP8266 together with Arduino MEga2560 in a project and the most common problem with ESP8266 (especially for Non-Mega devices) is that it sends data when they are available - and the TX buffer in ESP8266 is bigger then the RX buffer in the standard HardwareSerial class.\r\nSome ideas in the net are  to change the buffer size on Arduino and so modifying the classes. This is an option but when the device has more to do in the loop it may be not enough to read the data before ESP has send so many data that RX buffer in Arduino is overload.\r\n\r\nESP8266 supports hardware flow control in general so it should be able to control the data that will be sended ... but we need a trigger.\r\n\r\nMy idea was to add some kind of optional callback call/interrupt as soon as the RX buffer is filled to to (e.g.) 80% or such, so that the device can react on it and use the flow control to stop data sending before buffer overflows in a first step till it's avble to handle that ...\r\n\r\nWhat do you think of such an idea?!\r\n\r\nThe alternative (or real solution) would be to support HW Flow Control (CTS/RTS) in HW-Serial, so no buffer overflow ever can happen  ...\r\n\r\nIngo"},"comment":{"url":"https://api.github.com/repos/arduino/Arduino/issues/comments/147625206","html_url":"https://github.com/arduino/Arduino/issues/3947#issuecomment-147625206","issue_url":"https://api.github.com/repos/arduino/Arduino/issues/3947","id":147625206,"user":{"login":"Apollon77","id":11976694,"avatar_url":"https://avatars.githubusercontent.com/u/11976694?v=3","gravatar_id":"","url":"https://api.github.com/users/Apollon77","html_url":"https://github.com/Apollon77","followers_url":"https://api.github.com/users/Apollon77/followers","following_url":"https://api.github.com/users/Apollon77/following{/other_user}","gists_url":"https://api.github.com/users/Apollon77/gists{/gist_id}","starred_url":"https://api.github.com/users/Apollon77/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Apollon77/subscriptions","organizations_url":"https://api.github.com/users/Apollon77/orgs","repos_url":"https://api.github.com/users/Apollon77/repos","events_url":"https://api.github.com/users/Apollon77/events{/privacy}","received_events_url":"https://api.github.com/users/Apollon77/received_events","type":"User","site_admin":false},"created_at":"2015-10-13T07:03:43Z","updated_at":"2015-10-13T07:03:43Z","body":"Adding flow control in general (for HW-Serial and maybe also New-Soft-Serial) would be awesome because it will be the \"real\" solution in my eyes. I have found that for Teensy something like This was added to code by PaulStoffregen (https://forum.pjrc.com/threads/29446-Teensy-Hardware-Flow-Control-RTS-CTS  --> https://github.com/PaulStoffregen/cores/commit/c2f550d3780cba3c49cfc34bab724b268a11b7a6), but only the possibility to set the pins and to allowit in general I saw there. So there is no automatic buffer-fill-status depending logic what would be the real solution in my eyes ...\r\n\r\nThe second option would not help me in my special case because I can not guarantee that the check in \"loop\" will be fast enough to detect it before the buffer overflows. That's why the \"callback/interrupt\" idea ... the interrupt logic would be very simple: set the flow control pin to HIGH and set a boolean flag for \"data available\" so that the next loop run can handle the data and reset the control pin to get all the other data ..."}}