{"action":"created","comment":{"url":"https://api.github.com/repos/cleanflight/cleanflight/pulls/comments/49263577","id":49263577,"diff_hunk":"@@ -970,6 +973,61 @@ static void cliSerial(char *cmdline)\n \n }\n \n+static void cliSerialPassthrough(char *cmdline)\n+{\n+    if (isEmpty(cmdline)) {\n+        cliShowParseError();\n+        return;\n+    }\n+\n+    int id = -1;\n+    unsigned baud = 0;\n+    char* tok = strtok(cmdline, \" \");\n+    int index = 0;\n+\n+    while (tok != NULL) {\n+        switch(index) {\n+            case 0:\n+                id = atoi(tok);\n+                break;\n+            case 1:\n+                baud = atoi(tok);\n+                break;\n+        }\n+        index++;\n+        tok = strtok(NULL, \" \");\n+    }\n+\n+    serialPort_t *passThroughPort;\n+    serialPortUsage_t *passThroughPortUsage = findSerialPortUsageByIdentifier(id);\n+    if (!passThroughPortUsage || passThroughPortUsage->serialPort == NULL) {\n+        if (!baud)\n+        {\n+            printf(\"Port %d is not open, you must specify baud\\r\\n\", id);\n+            return;\n+        }\n+\n+        passThroughPort = openSerialPort(id, FUNCTION_PASSTHROUGH, NULL,\n+                                         baudRates[baud], MODE_RXTX,\n+                                         SERIAL_NOT_INVERTED);\n+        if (!passThroughPort) {\n+            printf(\"Port %d could not be opened\\r\\n\", id);\n+            return;\n+        }\n+        printf(\"Port %d opened, baud=%d\\r\\n\", id, baudRates[baud]);\n+    } else {\n+        passThroughPort = passThroughPortUsage->serialPort;\n+        if (!(passThroughPort->mode & MODE_TX))","path":"src/main/io/serial_cli.c","position":65,"original_position":65,"commit_id":"7e12a75616ab4e05ac02527162c268ab9925d602","original_commit_id":"7e12a75616ab4e05ac02527162c268ab9925d602","user":{"login":"ledvinap","id":2318015,"avatar_url":"https://avatars.githubusercontent.com/u/2318015?v=3","gravatar_id":"","url":"https://api.github.com/users/ledvinap","html_url":"https://github.com/ledvinap","followers_url":"https://api.github.com/users/ledvinap/followers","following_url":"https://api.github.com/users/ledvinap/following{/other_user}","gists_url":"https://api.github.com/users/ledvinap/gists{/gist_id}","starred_url":"https://api.github.com/users/ledvinap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ledvinap/subscriptions","organizations_url":"https://api.github.com/users/ledvinap/orgs","repos_url":"https://api.github.com/users/ledvinap/repos","events_url":"https://api.github.com/users/ledvinap/events{/privacy}","received_events_url":"https://api.github.com/users/ledvinap/received_events","type":"User","site_admin":false},"body":"Also it would be nice to explicitly call serialSetMode only once (only one `if` will trigger in reality, but the code just looks 'wrong')","created_at":"2016-01-09T12:12:06Z","updated_at":"2016-01-09T12:12:06Z","html_url":"https://github.com/cleanflight/cleanflight/pull/1620#discussion_r49263577","pull_request_url":"https://api.github.com/repos/cleanflight/cleanflight/pulls/1620","_links":{"self":{"href":"https://api.github.com/repos/cleanflight/cleanflight/pulls/comments/49263577"},"html":{"href":"https://github.com/cleanflight/cleanflight/pull/1620#discussion_r49263577"},"pull_request":{"href":"https://api.github.com/repos/cleanflight/cleanflight/pulls/1620"}}},"pull_request":{"url":"https://api.github.com/repos/cleanflight/cleanflight/pulls/1620","id":54441090,"html_url":"https://github.com/cleanflight/cleanflight/pull/1620","diff_url":"https://github.com/cleanflight/cleanflight/pull/1620.diff","patch_url":"https://github.com/cleanflight/cleanflight/pull/1620.patch","issue_url":"https://api.github.com/repos/cleanflight/cleanflight/issues/1620","number":1620,"state":"open","locked":false,"title":"A rough implementation of serial passthrough.","user":{"login":"btimby","id":669270,"avatar_url":"https://avatars.githubusercontent.com/u/669270?v=3","gravatar_id":"","url":"https://api.github.com/users/btimby","html_url":"https://github.com/btimby","followers_url":"https://api.github.com/users/btimby/followers","following_url":"https://api.github.com/users/btimby/following{/other_user}","gists_url":"https://api.github.com/users/btimby/gists{/gist_id}","starred_url":"https://api.github.com/users/btimby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/btimby/subscriptions","organizations_url":"https://api.github.com/users/btimby/orgs","repos_url":"https://api.github.com/users/btimby/repos","events_url":"https://api.github.com/users/btimby/events{/privacy}","received_events_url":"https://api.github.com/users/btimby/received_events","type":"User","site_admin":false},"body":"Meant to be used for accessing the OSD without removing it.\r\n\r\nI folded the gps passthrough functionality into this as the two are similar.\r\n\r\nI need some review and comments from a more experienced developer. I am not sure I grok the serial system, mostly I have questions about config and how one goes about locating available serial ports etc. Pointers to example code are welcome.\r\n\r\nMy attempt to fix #1587 \r\n","created_at":"2015-12-23T05:22:06Z","updated_at":"2016-01-09T12:12:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"aa6bdb7c9251e7817c59c3ea2af87fabe43f5c15","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/cleanflight/cleanflight/pulls/1620/commits","review_comments_url":"https://api.github.com/repos/cleanflight/cleanflight/pulls/1620/comments","review_comment_url":"https://api.github.com/repos/cleanflight/cleanflight/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cleanflight/cleanflight/issues/1620/comments","statuses_url":"https://api.github.com/repos/cleanflight/cleanflight/statuses/7e12a75616ab4e05ac02527162c268ab9925d602","head":{"label":"btimby:master","ref":"master","sha":"7e12a75616ab4e05ac02527162c268ab9925d602","user":{"login":"btimby","id":669270,"avatar_url":"https://avatars.githubusercontent.com/u/669270?v=3","gravatar_id":"","url":"https://api.github.com/users/btimby","html_url":"https://github.com/btimby","followers_url":"https://api.github.com/users/btimby/followers","following_url":"https://api.github.com/users/btimby/following{/other_user}","gists_url":"https://api.github.com/users/btimby/gists{/gist_id}","starred_url":"https://api.github.com/users/btimby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/btimby/subscriptions","organizations_url":"https://api.github.com/users/btimby/orgs","repos_url":"https://api.github.com/users/btimby/repos","events_url":"https://api.github.com/users/btimby/events{/privacy}","received_events_url":"https://api.github.com/users/btimby/received_events","type":"User","site_admin":false},"repo":{"id":47351367,"name":"cleanflight","full_name":"btimby/cleanflight","owner":{"login":"btimby","id":669270,"avatar_url":"https://avatars.githubusercontent.com/u/669270?v=3","gravatar_id":"","url":"https://api.github.com/users/btimby","html_url":"https://github.com/btimby","followers_url":"https://api.github.com/users/btimby/followers","following_url":"https://api.github.com/users/btimby/following{/other_user}","gists_url":"https://api.github.com/users/btimby/gists{/gist_id}","starred_url":"https://api.github.com/users/btimby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/btimby/subscriptions","organizations_url":"https://api.github.com/users/btimby/orgs","repos_url":"https://api.github.com/users/btimby/repos","events_url":"https://api.github.com/users/btimby/events{/privacy}","received_events_url":"https://api.github.com/users/btimby/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/btimby/cleanflight","description":"Clean-code version of the baseflight flight controller firmware","fork":true,"url":"https://api.github.com/repos/btimby/cleanflight","forks_url":"https://api.github.com/repos/btimby/cleanflight/forks","keys_url":"https://api.github.com/repos/btimby/cleanflight/keys{/key_id}","collaborators_url":"https://api.github.com/repos/btimby/cleanflight/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/btimby/cleanflight/teams","hooks_url":"https://api.github.com/repos/btimby/cleanflight/hooks","issue_events_url":"https://api.github.com/repos/btimby/cleanflight/issues/events{/number}","events_url":"https://api.github.com/repos/btimby/cleanflight/events","assignees_url":"https://api.github.com/repos/btimby/cleanflight/assignees{/user}","branches_url":"https://api.github.com/repos/btimby/cleanflight/branches{/branch}","tags_url":"https://api.github.com/repos/btimby/cleanflight/tags","blobs_url":"https://api.github.com/repos/btimby/cleanflight/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/btimby/cleanflight/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/btimby/cleanflight/git/refs{/sha}","trees_url":"https://api.github.com/repos/btimby/cleanflight/git/trees{/sha}","statuses_url":"https://api.github.com/repos/btimby/cleanflight/statuses/{sha}","languages_url":"https://api.github.com/repos/btimby/cleanflight/languages","stargazers_url":"https://api.github.com/repos/btimby/cleanflight/stargazers","contributors_url":"https://api.github.com/repos/btimby/cleanflight/contributors","subscribers_url":"https://api.github.com/repos/btimby/cleanflight/subscribers","subscription_url":"https://api.github.com/repos/btimby/cleanflight/subscription","commits_url":"https://api.github.com/repos/btimby/cleanflight/commits{/sha}","git_commits_url":"https://api.github.com/repos/btimby/cleanflight/git/commits{/sha}","comments_url":"https://api.github.com/repos/btimby/cleanflight/comments{/number}","issue_comment_url":"https://api.github.com/repos/btimby/cleanflight/issues/comments{/number}","contents_url":"https://api.github.com/repos/btimby/cleanflight/contents/{+path}","compare_url":"https://api.github.com/repos/btimby/cleanflight/compare/{base}...{head}","merges_url":"https://api.github.com/repos/btimby/cleanflight/merges","archive_url":"https://api.github.com/repos/btimby/cleanflight/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/btimby/cleanflight/downloads","issues_url":"https://api.github.com/repos/btimby/cleanflight/issues{/number}","pulls_url":"https://api.github.com/repos/btimby/cleanflight/pulls{/number}","milestones_url":"https://api.github.com/repos/btimby/cleanflight/milestones{/number}","notifications_url":"https://api.github.com/repos/btimby/cleanflight/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/btimby/cleanflight/labels{/name}","releases_url":"https://api.github.com/repos/btimby/cleanflight/releases{/id}","created_at":"2015-12-03T18:23:09Z","updated_at":"2015-12-03T18:23:15Z","pushed_at":"2016-01-09T03:39:47Z","git_url":"git://github.com/btimby/cleanflight.git","ssh_url":"git@github.com:btimby/cleanflight.git","clone_url":"https://github.com/btimby/cleanflight.git","svn_url":"https://github.com/btimby/cleanflight","homepage":"http://cleanflight.com","size":34223,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"cleanflight:master","ref":"master","sha":"eb9a401ec6746ea37e38834499803550c4f9dbac","user":{"login":"cleanflight","id":8776523,"avatar_url":"https://avatars.githubusercontent.com/u/8776523?v=3","gravatar_id":"","url":"https://api.github.com/users/cleanflight","html_url":"https://github.com/cleanflight","followers_url":"https://api.github.com/users/cleanflight/followers","following_url":"https://api.github.com/users/cleanflight/following{/other_user}","gists_url":"https://api.github.com/users/cleanflight/gists{/gist_id}","starred_url":"https://api.github.com/users/cleanflight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cleanflight/subscriptions","organizations_url":"https://api.github.com/users/cleanflight/orgs","repos_url":"https://api.github.com/users/cleanflight/repos","events_url":"https://api.github.com/users/cleanflight/events{/privacy}","received_events_url":"https://api.github.com/users/cleanflight/received_events","type":"Organization","site_admin":false},"repo":{"id":9066347,"name":"cleanflight","full_name":"cleanflight/cleanflight","owner":{"login":"cleanflight","id":8776523,"avatar_url":"https://avatars.githubusercontent.com/u/8776523?v=3","gravatar_id":"","url":"https://api.github.com/users/cleanflight","html_url":"https://github.com/cleanflight","followers_url":"https://api.github.com/users/cleanflight/followers","following_url":"https://api.github.com/users/cleanflight/following{/other_user}","gists_url":"https://api.github.com/users/cleanflight/gists{/gist_id}","starred_url":"https://api.github.com/users/cleanflight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cleanflight/subscriptions","organizations_url":"https://api.github.com/users/cleanflight/orgs","repos_url":"https://api.github.com/users/cleanflight/repos","events_url":"https://api.github.com/users/cleanflight/events{/privacy}","received_events_url":"https://api.github.com/users/cleanflight/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cleanflight/cleanflight","description":"Clean-code version of the baseflight flight controller firmware","fork":false,"url":"https://api.github.com/repos/cleanflight/cleanflight","forks_url":"https://api.github.com/repos/cleanflight/cleanflight/forks","keys_url":"https://api.github.com/repos/cleanflight/cleanflight/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cleanflight/cleanflight/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cleanflight/cleanflight/teams","hooks_url":"https://api.github.com/repos/cleanflight/cleanflight/hooks","issue_events_url":"https://api.github.com/repos/cleanflight/cleanflight/issues/events{/number}","events_url":"https://api.github.com/repos/cleanflight/cleanflight/events","assignees_url":"https://api.github.com/repos/cleanflight/cleanflight/assignees{/user}","branches_url":"https://api.github.com/repos/cleanflight/cleanflight/branches{/branch}","tags_url":"https://api.github.com/repos/cleanflight/cleanflight/tags","blobs_url":"https://api.github.com/repos/cleanflight/cleanflight/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cleanflight/cleanflight/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cleanflight/cleanflight/git/refs{/sha}","trees_url":"https://api.github.com/repos/cleanflight/cleanflight/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cleanflight/cleanflight/statuses/{sha}","languages_url":"https://api.github.com/repos/cleanflight/cleanflight/languages","stargazers_url":"https://api.github.com/repos/cleanflight/cleanflight/stargazers","contributors_url":"https://api.github.com/repos/cleanflight/cleanflight/contributors","subscribers_url":"https://api.github.com/repos/cleanflight/cleanflight/subscribers","subscription_url":"https://api.github.com/repos/cleanflight/cleanflight/subscription","commits_url":"https://api.github.com/repos/cleanflight/cleanflight/commits{/sha}","git_commits_url":"https://api.github.com/repos/cleanflight/cleanflight/git/commits{/sha}","comments_url":"https://api.github.com/repos/cleanflight/cleanflight/comments{/number}","issue_comment_url":"https://api.github.com/repos/cleanflight/cleanflight/issues/comments{/number}","contents_url":"https://api.github.com/repos/cleanflight/cleanflight/contents/{+path}","compare_url":"https://api.github.com/repos/cleanflight/cleanflight/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cleanflight/cleanflight/merges","archive_url":"https://api.github.com/repos/cleanflight/cleanflight/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cleanflight/cleanflight/downloads","issues_url":"https://api.github.com/repos/cleanflight/cleanflight/issues{/number}","pulls_url":"https://api.github.com/repos/cleanflight/cleanflight/pulls{/number}","milestones_url":"https://api.github.com/repos/cleanflight/cleanflight/milestones{/number}","notifications_url":"https://api.github.com/repos/cleanflight/cleanflight/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cleanflight/cleanflight/labels{/name}","releases_url":"https://api.github.com/repos/cleanflight/cleanflight/releases{/id}","created_at":"2013-03-27T23:49:19Z","updated_at":"2016-01-09T10:46:46Z","pushed_at":"2016-01-09T10:37:32Z","git_url":"git://github.com/cleanflight/cleanflight.git","ssh_url":"git@github.com:cleanflight/cleanflight.git","clone_url":"https://github.com/cleanflight/cleanflight.git","svn_url":"https://github.com/cleanflight/cleanflight","homepage":"http://cleanflight.com","size":87710,"stargazers_count":748,"watchers_count":748,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":764,"mirror_url":null,"open_issues_count":383,"forks":764,"open_issues":383,"watchers":748,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cleanflight/cleanflight/pulls/1620"},"html":{"href":"https://github.com/cleanflight/cleanflight/pull/1620"},"issue":{"href":"https://api.github.com/repos/cleanflight/cleanflight/issues/1620"},"comments":{"href":"https://api.github.com/repos/cleanflight/cleanflight/issues/1620/comments"},"review_comments":{"href":"https://api.github.com/repos/cleanflight/cleanflight/pulls/1620/comments"},"review_comment":{"href":"https://api.github.com/repos/cleanflight/cleanflight/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cleanflight/cleanflight/pulls/1620/commits"},"statuses":{"href":"https://api.github.com/repos/cleanflight/cleanflight/statuses/7e12a75616ab4e05ac02527162c268ab9925d602"}}}}