{"action":"created","issue":{"url":"https://api.github.com/repos/NordicSemiconductor/pc-ble-driver-js/issues/28","repository_url":"https://api.github.com/repos/NordicSemiconductor/pc-ble-driver-js","labels_url":"https://api.github.com/repos/NordicSemiconductor/pc-ble-driver-js/issues/28/labels{/name}","comments_url":"https://api.github.com/repos/NordicSemiconductor/pc-ble-driver-js/issues/28/comments","events_url":"https://api.github.com/repos/NordicSemiconductor/pc-ble-driver-js/issues/28/events","html_url":"https://github.com/NordicSemiconductor/pc-ble-driver-js/issues/28","id":175811216,"number":28,"title":"Stability issues on Ubuntu","user":{"login":"ksachdeva","id":127006,"avatar_url":"https://avatars.githubusercontent.com/u/127006?v=3","gravatar_id":"","url":"https://api.github.com/users/ksachdeva","html_url":"https://github.com/ksachdeva","followers_url":"https://api.github.com/users/ksachdeva/followers","following_url":"https://api.github.com/users/ksachdeva/following{/other_user}","gists_url":"https://api.github.com/users/ksachdeva/gists{/gist_id}","starred_url":"https://api.github.com/users/ksachdeva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ksachdeva/subscriptions","organizations_url":"https://api.github.com/users/ksachdeva/orgs","repos_url":"https://api.github.com/users/ksachdeva/repos","events_url":"https://api.github.com/users/ksachdeva/events{/privacy}","received_events_url":"https://api.github.com/users/ksachdeva/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/NordicSemiconductor/pc-ble-driver-js/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-09-08T17:18:18Z","updated_at":"2016-10-26T08:13:44Z","closed_at":null,"body":"Hi,\r\n\r\nMy primary development machine has been OS X and things have worked quite well. However my app is to be deployed on Ubuntu and am facing lot of stability issues when opening the adapter.\r\n\r\nWhen adapter.open() is called then a lot of time I end up with below mentioned error message\r\n\r\nFailed to open the nRF5 BLE driver.\r\nnode: ../deps/uv/src/unix/core.c:168: uv_close: Assertion `0' failed.\r\n\r\nEven connecting/disconnecting the DK does not help. Some times rebooting the Ubuntu helps\r\n\r\nAny help/guidance on what may be wrong and if any workaround will be very helpful\r\n\r\nRegards & thanks\r\nKapil\r\n"},"comment":{"url":"https://api.github.com/repos/NordicSemiconductor/pc-ble-driver-js/issues/comments/256279268","html_url":"https://github.com/NordicSemiconductor/pc-ble-driver-js/issues/28#issuecomment-256279268","issue_url":"https://api.github.com/repos/NordicSemiconductor/pc-ble-driver-js/issues/28","id":256279268,"user":{"login":"rosek86","id":10393406,"avatar_url":"https://avatars.githubusercontent.com/u/10393406?v=3","gravatar_id":"","url":"https://api.github.com/users/rosek86","html_url":"https://github.com/rosek86","followers_url":"https://api.github.com/users/rosek86/followers","following_url":"https://api.github.com/users/rosek86/following{/other_user}","gists_url":"https://api.github.com/users/rosek86/gists{/gist_id}","starred_url":"https://api.github.com/users/rosek86/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rosek86/subscriptions","organizations_url":"https://api.github.com/users/rosek86/orgs","repos_url":"https://api.github.com/users/rosek86/repos","events_url":"https://api.github.com/users/rosek86/events{/privacy}","received_events_url":"https://api.github.com/users/rosek86/received_events","type":"User","site_admin":false},"created_at":"2016-10-26T08:13:43Z","updated_at":"2016-10-26T08:13:43Z","body":"Hi @ksachdeva, @bihanssen \r\n\r\nAfter longer testing time, I've started to get exactly the same issue as @ksachdeva shown above. I investigated this further and it seems to me that this is a race condition problem in h5_transport in the pc-ble-driver.\r\n\r\nThe H5Transport::open runs UartBoost::open and then sets _exitCriterias->isOpened to true when port is successfully opened. However startStateMachine() starts new thread which sets _exitCriterias->isOpened to false by executing exit->reset() method. If state machine thread runs first everything works well but if H5Transport::open sets isOpened first, the program fails.\r\n\r\nI've added a few debug messages and logged program flow for expected and unexpected STATE_START initialization.\r\n\r\nExepcted STATE_START initialization \r\n\r\n> logMessage: STATE_START:init\r\n> logMessage: STATE_START:exit->reset(); // isOpened is set to false\r\n> logMessage: STATE_START:while (!exit->isFullfilled()) {...} // thread waits for isOpened == true\r\n> logMessage: Successfully opened /dev/ttyACM0. Baud rate: 115200. Flow control: none. Parity: none.\r\n> logMessage: _exitCriterias->isOpened = true\r\n> logMessage: waitForState(STATE_ACTIVE, OPEN_WAIT_TIMEOUT)\r\n> logMessage: STATE_START:ok\r\n> logMessage: STATE_RESET:init\r\n\r\nUnexpected STATE_START initialization\r\n\r\n> logMessage: Successfully opened /dev/ttyACM0. Baud rate: 115200. Flow control: none. Parity: none.\r\n> logMessage: _exitCriterias->isOpened = true\r\n> logMessage: waitForState(STATE_ACTIVE, OPEN_WAIT_TIMEOUT)\r\n> logMessage: STATE_START:init\r\n> logMessage: STATE_START:exit->reset(); // isOpened is set to false\r\n> logMessage: STATE_START:while (!exit->isFullfilled()) {...} // thread waits for isOpened == true\r\n\r\nFor now I applied a nasty work around as I don't have time to look into this further. I simply added 500 ms delay before setting isOpened to true in H5Transport::open method.\r\n\r\nSimply add the following line in L135 of h5_transport.cpp.\r\n`std::this_thread::sleep_for(std::chrono::milliseconds(500));`\r\n\r\nhttps://github.com/NordicSemiconductor/pc-ble-driver/blob/3b805a32e64759c308ad04c0b89faaf82bfed95f/src/transport/h5_transport.cpp#L135\r\n\r\n@ksachdeva are you able to check if the work around works for you too? \r\n\r\nI may look into this properly later.\r\n\r\nBR,\r\nKrzysztof\r\n"}}
{"actor":{"display_login":"rosek86"}}