{"action":"created","issue":{"url":"https://api.github.com/repos/lancaster-university/microbit-dal/issues/125","repository_url":"https://api.github.com/repos/lancaster-university/microbit-dal","labels_url":"https://api.github.com/repos/lancaster-university/microbit-dal/issues/125/labels{/name}","comments_url":"https://api.github.com/repos/lancaster-university/microbit-dal/issues/125/comments","events_url":"https://api.github.com/repos/lancaster-university/microbit-dal/issues/125/events","html_url":"https://github.com/lancaster-university/microbit-dal/issues/125","id":149150731,"number":125,"title":"UART service readUntil not working as expected when specified buffer size fully used","user":{"login":"bluetooth-mdw","id":8341666,"avatar_url":"https://avatars.githubusercontent.com/u/8341666?v=3","gravatar_id":"","url":"https://api.github.com/users/bluetooth-mdw","html_url":"https://github.com/bluetooth-mdw","followers_url":"https://api.github.com/users/bluetooth-mdw/followers","following_url":"https://api.github.com/users/bluetooth-mdw/following{/other_user}","gists_url":"https://api.github.com/users/bluetooth-mdw/gists{/gist_id}","starred_url":"https://api.github.com/users/bluetooth-mdw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bluetooth-mdw/subscriptions","organizations_url":"https://api.github.com/users/bluetooth-mdw/orgs","repos_url":"https://api.github.com/users/bluetooth-mdw/repos","events_url":"https://api.github.com/users/bluetooth-mdw/events{/privacy}","received_events_url":"https://api.github.com/users/bluetooth-mdw/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-04-18T13:29:00Z","updated_at":"2016-04-18T13:44:32Z","closed_at":null,"body":"With this code:\r\n\r\n```\r\n  uBit.messageBus.listen(MICROBIT_ID_BLE, MICROBIT_BLE_EVT_CONNECTED, onConnected);\r\n  uBit.messageBus.listen(MICROBIT_ID_BLE, MICROBIT_BLE_EVT_DISCONNECTED, onDisconnected);\r\n uart = new MicroBitUARTService(*uBit.ble, 32, 32); \r\n```\r\n\r\nand\r\n\r\n```\r\nvoid onConnected(MicroBitEvent e)\r\n{\r\n    \r\n    uBit.display.scroll(\"C\");\r\n    \r\n    // my client will send ASCII strings terminated with the colon character\r\n    ManagedString eom(\":\");\r\n    \r\n    while(1) {\r\n        ManagedString msg = uart->readUntil(eom);\r\n        uBit.display.scroll(msg);\r\n    }   \r\n}\r\n```\r\n\r\nUsing nRF Master Control Panel to write to the RX characteristic (i.e. sending data to the micro:bit)\r\n\r\n1. Testing with 4 x RX writes from the client app of-> 1234567890 then 1234567890 then 1234567890 then  : \r\n\r\ni.e. final write is a single colon character which is my message terminator for readUntil \r\n\r\nThis works. I see nothing on the micro:bit display until the final colon is received and then the whole message, sent in those 4 BLE writes scrolls across the display without the terminating colon. \r\n\r\n\r\nHowever...\r\n\r\n2. Test with 4 x RX writes: 1234567890 1234567890 1234567890 1: does not work. \r\n\r\ni.e. here I'm sending a total of 32 octets, the last one being my terminator. I don't see the message 1234567890123456789012345678901 scrolling across the screen. Assume the terminator is not making it into the 32 octet buffer or something like that.\r\n\r\nWhole micro:bit app fyi:\r\n\r\n```\r\nMicroBit uBit;\r\nMicroBitUARTService *uart;\r\n\r\nvoid onConnected(MicroBitEvent e)\r\n{\r\n    \r\n    uBit.display.scroll(\"C\");\r\n    \r\n    // my client will send ASCII strings terminated with the colon character\r\n    ManagedString eom(\":\");\r\n    \r\n    while(1) {\r\n        ManagedString msg = uart->readUntil(eom);\r\n        uBit.display.scroll(msg);\r\n    }\r\n    \r\n}\r\n\r\nvoid onDisconnected(MicroBitEvent e)\r\n{\r\n    uBit.display.scroll(\"D\");\r\n}\r\n\r\nint main()\r\n{\r\n    // Initialise the micro:bit runtime.\r\n    uBit.init();\r\n\r\n    uBit.messageBus.listen(MICROBIT_ID_BLE, MICROBIT_BLE_EVT_CONNECTED, onConnected);\r\n    uBit.messageBus.listen(MICROBIT_ID_BLE, MICROBIT_BLE_EVT_DISCONNECTED, onDisconnected);\r\n       \r\n    // Note GATT table size increased from default in MicroBitConfig.h\r\n    // #define MICROBIT_SD_GATT_TABLE_SIZE             0x500\r\n    uart = new MicroBitUARTService(*uBit.ble, 32, 32); \r\n    uBit.display.scroll(\"UART ready\");\r\n\r\n    // If main exits, there may still be other fibers running or registered event handlers etc.\r\n    // Simply release this fiber, which will mean we enter the scheduler. Worse case, we then\r\n    // sit in the idle task forever, in a power efficient sleep.\r\n    release_fiber();\r\n}\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/lancaster-university/microbit-dal/issues/comments/211385520","html_url":"https://github.com/lancaster-university/microbit-dal/issues/125#issuecomment-211385520","issue_url":"https://api.github.com/repos/lancaster-university/microbit-dal/issues/125","id":211385520,"user":{"login":"bluetooth-mdw","id":8341666,"avatar_url":"https://avatars.githubusercontent.com/u/8341666?v=3","gravatar_id":"","url":"https://api.github.com/users/bluetooth-mdw","html_url":"https://github.com/bluetooth-mdw","followers_url":"https://api.github.com/users/bluetooth-mdw/followers","following_url":"https://api.github.com/users/bluetooth-mdw/following{/other_user}","gists_url":"https://api.github.com/users/bluetooth-mdw/gists{/gist_id}","starred_url":"https://api.github.com/users/bluetooth-mdw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bluetooth-mdw/subscriptions","organizations_url":"https://api.github.com/users/bluetooth-mdw/orgs","repos_url":"https://api.github.com/users/bluetooth-mdw/repos","events_url":"https://api.github.com/users/bluetooth-mdw/events{/privacy}","received_events_url":"https://api.github.com/users/bluetooth-mdw/received_events","type":"User","site_admin":false},"created_at":"2016-04-18T13:44:32Z","updated_at":"2016-04-18T13:44:32Z","body":"Arrrggghh. Double negatives :-)\r\n\r\nTo be clear these were two separate tests with a reset in between. So in each test I reset then connect over BLE (and you see \"C\" displayed)... the code then blocks in readUntil whilst I send sub-strings in discreet BLE writes from nRFMaster Controller. In test 1 when I perform the 4th write containing only the \":\" end of message character, as expected I see the buffered 123456789012345678901234567890 displayed. In test 2 after a reset, same procedure just one extra character so 32 (buffer size) in total and I see no displayed text."}}