{"action":"created","issue":{"url":"https://api.github.com/repos/peterhinch/Micropython-scheduler/issues/2","repository_url":"https://api.github.com/repos/peterhinch/Micropython-scheduler","labels_url":"https://api.github.com/repos/peterhinch/Micropython-scheduler/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/peterhinch/Micropython-scheduler/issues/2/comments","events_url":"https://api.github.com/repos/peterhinch/Micropython-scheduler/issues/2/events","html_url":"https://github.com/peterhinch/Micropython-scheduler/issues/2","id":168280471,"number":2,"title":"How to modify the adapt to used in serial  communication.TKS!","user":{"login":"skylin008","id":3345980,"avatar_url":"https://avatars.githubusercontent.com/u/3345980?v=3","gravatar_id":"","url":"https://api.github.com/users/skylin008","html_url":"https://github.com/skylin008","followers_url":"https://api.github.com/users/skylin008/followers","following_url":"https://api.github.com/users/skylin008/following{/other_user}","gists_url":"https://api.github.com/users/skylin008/gists{/gist_id}","starred_url":"https://api.github.com/users/skylin008/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skylin008/subscriptions","organizations_url":"https://api.github.com/users/skylin008/orgs","repos_url":"https://api.github.com/users/skylin008/repos","events_url":"https://api.github.com/users/skylin008/events{/privacy}","received_events_url":"https://api.github.com/users/skylin008/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-07-29T08:58:37Z","updated_at":"2016-07-29T14:55:36Z","closed_at":null,"body":""},"comment":{"url":"https://api.github.com/repos/peterhinch/Micropython-scheduler/issues/comments/236202770","html_url":"https://github.com/peterhinch/Micropython-scheduler/issues/2#issuecomment-236202770","issue_url":"https://api.github.com/repos/peterhinch/Micropython-scheduler/issues/2","id":236202770,"user":{"login":"peterhinch","id":8437477,"avatar_url":"https://avatars.githubusercontent.com/u/8437477?v=3","gravatar_id":"","url":"https://api.github.com/users/peterhinch","html_url":"https://github.com/peterhinch","followers_url":"https://api.github.com/users/peterhinch/followers","following_url":"https://api.github.com/users/peterhinch/following{/other_user}","gists_url":"https://api.github.com/users/peterhinch/gists{/gist_id}","starred_url":"https://api.github.com/users/peterhinch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peterhinch/subscriptions","organizations_url":"https://api.github.com/users/peterhinch/orgs","repos_url":"https://api.github.com/users/peterhinch/repos","events_url":"https://api.github.com/users/peterhinch/events{/privacy}","received_events_url":"https://api.github.com/users/peterhinch/received_events","type":"User","site_admin":false},"created_at":"2016-07-29T14:55:36Z","updated_at":"2016-07-29T14:55:36Z","body":"It shouldn't need modification. On the assumption that you're using a Pyboard, I would create two threads, one for tx and the other for rx. There would be a tx queue and an rx queue (implemented as lists). Other threads would populate the tx queue (append) and remove strings from the rx queue (pop(0)) as they become available.\r\n\r\nThe tx thread would loop forever checking if there are strings queued. If there are, it would pop(0) to get the oldest, transmit it, and loop until all bytes were written (remembering to yield in each loop) before reverting to the outer loop.\r\n\r\nThe rx thread is slightly more tricky. You don't want a timeout as it would lock the scheduler for the duration so you need to loop on any() and only read characters up to the number present, appending them to a temporary string. How you append data to the rx queue depends on the nature of the data. Fixed length records are easy. Otherwise if your data is in lines, you need to check for an end of line character and break the incoming data accordingly.\r\n\r\nAll manageable with care. I've just written something similar, but not using the UART so I can't offer any actual code."}}
{"actor":{"display_login":"peterhinch"}}