{"action":"created","comment":{"url":"https://api.github.com/repos/GomSpace/libcsp/pulls/comments/36619129","id":36619129,"diff_hunk":"@@ -82,17 +83,44 @@ typedef struct {\n \tstruct can_frame frame;\t/** CAN Frame */\n } mbox_t;\n \n-/* List of mailboxes */\n-static mbox_t mbox[MBOX_NUM];\n+typedef struct {\n+\tint can_socket;         /** SocketCAN socket handle */\n+\tmbox_t mbox[MBOX_NUM];  /* List of mailboxes */\n+\tsem_t mbox_sem;         /** Mailbox pool semaphore */\n+\tcsp_iface_t *csp_if_can;\n+} can_socket_info_t;\n+\n+can_socket_info_t can_socket_info[MAX_SUPPORTED_CAN_INSTANCES];","path":"src/drivers/can/can_socketcan.c","position":25,"original_position":25,"commit_id":"2a41b193893566a12c4de0bde4f6556f53ffd05e","original_commit_id":"2a41b193893566a12c4de0bde4f6556f53ffd05e","user":{"login":"johandc","id":545264,"avatar_url":"https://avatars.githubusercontent.com/u/545264?v=3","gravatar_id":"","url":"https://api.github.com/users/johandc","html_url":"https://github.com/johandc","followers_url":"https://api.github.com/users/johandc/followers","following_url":"https://api.github.com/users/johandc/following{/other_user}","gists_url":"https://api.github.com/users/johandc/gists{/gist_id}","starred_url":"https://api.github.com/users/johandc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johandc/subscriptions","organizations_url":"https://api.github.com/users/johandc/orgs","repos_url":"https://api.github.com/users/johandc/repos","events_url":"https://api.github.com/users/johandc/events{/privacy}","received_events_url":"https://api.github.com/users/johandc/received_events","type":"User","site_admin":false},"body":"What about putting the iface ptr and the semaphore pointer into the mbox structure itself?\r\nSame argumentation as before with the queue elements.","created_at":"2015-08-10T10:41:35Z","updated_at":"2015-08-10T10:41:35Z","html_url":"https://github.com/GomSpace/libcsp/pull/55#discussion_r36619129","pull_request_url":"https://api.github.com/repos/GomSpace/libcsp/pulls/55","_links":{"self":{"href":"https://api.github.com/repos/GomSpace/libcsp/pulls/comments/36619129"},"html":{"href":"https://github.com/GomSpace/libcsp/pull/55#discussion_r36619129"},"pull_request":{"href":"https://api.github.com/repos/GomSpace/libcsp/pulls/55"}}},"pull_request":{"url":"https://api.github.com/repos/GomSpace/libcsp/pulls/55","id":40269160,"html_url":"https://github.com/GomSpace/libcsp/pull/55","diff_url":"https://github.com/GomSpace/libcsp/pull/55.diff","patch_url":"https://github.com/GomSpace/libcsp/pull/55.patch","issue_url":"https://api.github.com/repos/GomSpace/libcsp/issues/55","number":55,"state":"open","locked":false,"title":"Can multiple interfaces support","user":{"login":"nicob87","id":13121406,"avatar_url":"https://avatars.githubusercontent.com/u/13121406?v=3","gravatar_id":"","url":"https://api.github.com/users/nicob87","html_url":"https://github.com/nicob87","followers_url":"https://api.github.com/users/nicob87/followers","following_url":"https://api.github.com/users/nicob87/following{/other_user}","gists_url":"https://api.github.com/users/nicob87/gists{/gist_id}","starred_url":"https://api.github.com/users/nicob87/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicob87/subscriptions","organizations_url":"https://api.github.com/users/nicob87/orgs","repos_url":"https://api.github.com/users/nicob87/repos","events_url":"https://api.github.com/users/nicob87/events{/privacy}","received_events_url":"https://api.github.com/users/nicob87/received_events","type":"User","site_admin":false},"body":"Hi! \r\nThis pull request suppose to fix #52 . That is, support multiple can interfaces. In addition to that, add support for multiple instances to the socketcan driver.\r\n\r\nAs @johandc told me, I have taken a look to the kiss interface, I have seen there you are using the \"driver\" pointer. I think this case is not exactly the same, because here, we just need to be able to tell the driver \"which\" interface we want to use, but not necessarily using different drivers. \r\n\r\nMy first goal was to ensure that all my work would be \"backward\" compatible, so if you call the \"csp_can_init\" function as usual, everything works, and the old global interface is used.\r\n\r\n   If you want to use the multiple interfaces support new feature, you call \"csp_can_init_ifc\" for each interface, rather than \"csp_can_init\". (see example!).\r\n\r\n-Now driver functions: \"can_init\", \"can_send\" and callbacks should receive the \"interface\" as argument.\r\n\r\n- I have added support for the multiple instance only for \"socketcan\" driver, and that is what I have tested in the example. To make this I have connected two of this: \"http://www.8devices.com/usb2can\" in loopback.\r\n\r\n- For all the other drivers (\"can_at90can128.c\",\"can_at91sam7a1.c\",\"can_at91sam7a3.c\") I have only made the necessary modifications to make them \"backward compatible\", this is, just passing NULL as argument for the interface pointer in callbacks and functions. I have not been able to test this because I don't have the hardware for that, but, I have compiled them successfully, and I have done the same test with our driver, in \"backward compatible\" mode and worked just fine. So I think everything is ok.\r\n\r\nPlease ask me any question you want, and tell me any critique or modification you want me to do. :-)\r\n\r\nThanks for all the work you are sharing here! It is being really helpful to us, and I hope my work would be useful for you too.\r\n\r\nBest Regards, Nicolás. \r\n\r\n\r\n","created_at":"2015-07-17T20:37:48Z","updated_at":"2015-08-10T10:41:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"aa8ee6f7ce5eca56fb374b8976062d37cb3ad165","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/GomSpace/libcsp/pulls/55/commits","review_comments_url":"https://api.github.com/repos/GomSpace/libcsp/pulls/55/comments","review_comment_url":"https://api.github.com/repos/GomSpace/libcsp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GomSpace/libcsp/issues/55/comments","statuses_url":"https://api.github.com/repos/GomSpace/libcsp/statuses/2a41b193893566a12c4de0bde4f6556f53ffd05e","head":{"label":"nicob87:can_multiple_interfaces_support","ref":"can_multiple_interfaces_support","sha":"2a41b193893566a12c4de0bde4f6556f53ffd05e","user":{"login":"nicob87","id":13121406,"avatar_url":"https://avatars.githubusercontent.com/u/13121406?v=3","gravatar_id":"","url":"https://api.github.com/users/nicob87","html_url":"https://github.com/nicob87","followers_url":"https://api.github.com/users/nicob87/followers","following_url":"https://api.github.com/users/nicob87/following{/other_user}","gists_url":"https://api.github.com/users/nicob87/gists{/gist_id}","starred_url":"https://api.github.com/users/nicob87/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicob87/subscriptions","organizations_url":"https://api.github.com/users/nicob87/orgs","repos_url":"https://api.github.com/users/nicob87/repos","events_url":"https://api.github.com/users/nicob87/events{/privacy}","received_events_url":"https://api.github.com/users/nicob87/received_events","type":"User","site_admin":false},"repo":{"id":38320899,"name":"libcsp","full_name":"nicob87/libcsp","owner":{"login":"nicob87","id":13121406,"avatar_url":"https://avatars.githubusercontent.com/u/13121406?v=3","gravatar_id":"","url":"https://api.github.com/users/nicob87","html_url":"https://github.com/nicob87","followers_url":"https://api.github.com/users/nicob87/followers","following_url":"https://api.github.com/users/nicob87/following{/other_user}","gists_url":"https://api.github.com/users/nicob87/gists{/gist_id}","starred_url":"https://api.github.com/users/nicob87/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicob87/subscriptions","organizations_url":"https://api.github.com/users/nicob87/orgs","repos_url":"https://api.github.com/users/nicob87/repos","events_url":"https://api.github.com/users/nicob87/events{/privacy}","received_events_url":"https://api.github.com/users/nicob87/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nicob87/libcsp","description":"Cubesat Space Protocol - A small network-layer delivery protocol designed for Cubesats","fork":true,"url":"https://api.github.com/repos/nicob87/libcsp","forks_url":"https://api.github.com/repos/nicob87/libcsp/forks","keys_url":"https://api.github.com/repos/nicob87/libcsp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nicob87/libcsp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nicob87/libcsp/teams","hooks_url":"https://api.github.com/repos/nicob87/libcsp/hooks","issue_events_url":"https://api.github.com/repos/nicob87/libcsp/issues/events{/number}","events_url":"https://api.github.com/repos/nicob87/libcsp/events","assignees_url":"https://api.github.com/repos/nicob87/libcsp/assignees{/user}","branches_url":"https://api.github.com/repos/nicob87/libcsp/branches{/branch}","tags_url":"https://api.github.com/repos/nicob87/libcsp/tags","blobs_url":"https://api.github.com/repos/nicob87/libcsp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nicob87/libcsp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nicob87/libcsp/git/refs{/sha}","trees_url":"https://api.github.com/repos/nicob87/libcsp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nicob87/libcsp/statuses/{sha}","languages_url":"https://api.github.com/repos/nicob87/libcsp/languages","stargazers_url":"https://api.github.com/repos/nicob87/libcsp/stargazers","contributors_url":"https://api.github.com/repos/nicob87/libcsp/contributors","subscribers_url":"https://api.github.com/repos/nicob87/libcsp/subscribers","subscription_url":"https://api.github.com/repos/nicob87/libcsp/subscription","commits_url":"https://api.github.com/repos/nicob87/libcsp/commits{/sha}","git_commits_url":"https://api.github.com/repos/nicob87/libcsp/git/commits{/sha}","comments_url":"https://api.github.com/repos/nicob87/libcsp/comments{/number}","issue_comment_url":"https://api.github.com/repos/nicob87/libcsp/issues/comments{/number}","contents_url":"https://api.github.com/repos/nicob87/libcsp/contents/{+path}","compare_url":"https://api.github.com/repos/nicob87/libcsp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nicob87/libcsp/merges","archive_url":"https://api.github.com/repos/nicob87/libcsp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nicob87/libcsp/downloads","issues_url":"https://api.github.com/repos/nicob87/libcsp/issues{/number}","pulls_url":"https://api.github.com/repos/nicob87/libcsp/pulls{/number}","milestones_url":"https://api.github.com/repos/nicob87/libcsp/milestones{/number}","notifications_url":"https://api.github.com/repos/nicob87/libcsp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nicob87/libcsp/labels{/name}","releases_url":"https://api.github.com/repos/nicob87/libcsp/releases{/id}","created_at":"2015-06-30T16:41:10Z","updated_at":"2015-06-30T16:41:10Z","pushed_at":"2015-07-28T20:05:54Z","git_url":"git://github.com/nicob87/libcsp.git","ssh_url":"git@github.com:nicob87/libcsp.git","clone_url":"https://github.com/nicob87/libcsp.git","svn_url":"https://github.com/nicob87/libcsp","homepage":"http://www.libcsp.org","size":1823,"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":"GomSpace:master","ref":"master","sha":"48937b1f9f19431df3854485d195f9dbf4d9576b","user":{"login":"GomSpace","id":545266,"avatar_url":"https://avatars.githubusercontent.com/u/545266?v=3","gravatar_id":"","url":"https://api.github.com/users/GomSpace","html_url":"https://github.com/GomSpace","followers_url":"https://api.github.com/users/GomSpace/followers","following_url":"https://api.github.com/users/GomSpace/following{/other_user}","gists_url":"https://api.github.com/users/GomSpace/gists{/gist_id}","starred_url":"https://api.github.com/users/GomSpace/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GomSpace/subscriptions","organizations_url":"https://api.github.com/users/GomSpace/orgs","repos_url":"https://api.github.com/users/GomSpace/repos","events_url":"https://api.github.com/users/GomSpace/events{/privacy}","received_events_url":"https://api.github.com/users/GomSpace/received_events","type":"Organization","site_admin":false},"repo":{"id":2531772,"name":"libcsp","full_name":"GomSpace/libcsp","owner":{"login":"GomSpace","id":545266,"avatar_url":"https://avatars.githubusercontent.com/u/545266?v=3","gravatar_id":"","url":"https://api.github.com/users/GomSpace","html_url":"https://github.com/GomSpace","followers_url":"https://api.github.com/users/GomSpace/followers","following_url":"https://api.github.com/users/GomSpace/following{/other_user}","gists_url":"https://api.github.com/users/GomSpace/gists{/gist_id}","starred_url":"https://api.github.com/users/GomSpace/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GomSpace/subscriptions","organizations_url":"https://api.github.com/users/GomSpace/orgs","repos_url":"https://api.github.com/users/GomSpace/repos","events_url":"https://api.github.com/users/GomSpace/events{/privacy}","received_events_url":"https://api.github.com/users/GomSpace/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GomSpace/libcsp","description":"Cubesat Space Protocol - A small network-layer delivery protocol designed for Cubesats","fork":false,"url":"https://api.github.com/repos/GomSpace/libcsp","forks_url":"https://api.github.com/repos/GomSpace/libcsp/forks","keys_url":"https://api.github.com/repos/GomSpace/libcsp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GomSpace/libcsp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GomSpace/libcsp/teams","hooks_url":"https://api.github.com/repos/GomSpace/libcsp/hooks","issue_events_url":"https://api.github.com/repos/GomSpace/libcsp/issues/events{/number}","events_url":"https://api.github.com/repos/GomSpace/libcsp/events","assignees_url":"https://api.github.com/repos/GomSpace/libcsp/assignees{/user}","branches_url":"https://api.github.com/repos/GomSpace/libcsp/branches{/branch}","tags_url":"https://api.github.com/repos/GomSpace/libcsp/tags","blobs_url":"https://api.github.com/repos/GomSpace/libcsp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GomSpace/libcsp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GomSpace/libcsp/git/refs{/sha}","trees_url":"https://api.github.com/repos/GomSpace/libcsp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GomSpace/libcsp/statuses/{sha}","languages_url":"https://api.github.com/repos/GomSpace/libcsp/languages","stargazers_url":"https://api.github.com/repos/GomSpace/libcsp/stargazers","contributors_url":"https://api.github.com/repos/GomSpace/libcsp/contributors","subscribers_url":"https://api.github.com/repos/GomSpace/libcsp/subscribers","subscription_url":"https://api.github.com/repos/GomSpace/libcsp/subscription","commits_url":"https://api.github.com/repos/GomSpace/libcsp/commits{/sha}","git_commits_url":"https://api.github.com/repos/GomSpace/libcsp/git/commits{/sha}","comments_url":"https://api.github.com/repos/GomSpace/libcsp/comments{/number}","issue_comment_url":"https://api.github.com/repos/GomSpace/libcsp/issues/comments{/number}","contents_url":"https://api.github.com/repos/GomSpace/libcsp/contents/{+path}","compare_url":"https://api.github.com/repos/GomSpace/libcsp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GomSpace/libcsp/merges","archive_url":"https://api.github.com/repos/GomSpace/libcsp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GomSpace/libcsp/downloads","issues_url":"https://api.github.com/repos/GomSpace/libcsp/issues{/number}","pulls_url":"https://api.github.com/repos/GomSpace/libcsp/pulls{/number}","milestones_url":"https://api.github.com/repos/GomSpace/libcsp/milestones{/number}","notifications_url":"https://api.github.com/repos/GomSpace/libcsp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GomSpace/libcsp/labels{/name}","releases_url":"https://api.github.com/repos/GomSpace/libcsp/releases{/id}","created_at":"2011-10-07T10:35:34Z","updated_at":"2015-08-05T04:41:25Z","pushed_at":"2015-08-04T08:22:42Z","git_url":"git://github.com/GomSpace/libcsp.git","ssh_url":"git@github.com:GomSpace/libcsp.git","clone_url":"https://github.com/GomSpace/libcsp.git","svn_url":"https://github.com/GomSpace/libcsp","homepage":"http://www.libcsp.org","size":2531,"stargazers_count":64,"watchers_count":64,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":38,"mirror_url":null,"open_issues_count":15,"forks":38,"open_issues":15,"watchers":64,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GomSpace/libcsp/pulls/55"},"html":{"href":"https://github.com/GomSpace/libcsp/pull/55"},"issue":{"href":"https://api.github.com/repos/GomSpace/libcsp/issues/55"},"comments":{"href":"https://api.github.com/repos/GomSpace/libcsp/issues/55/comments"},"review_comments":{"href":"https://api.github.com/repos/GomSpace/libcsp/pulls/55/comments"},"review_comment":{"href":"https://api.github.com/repos/GomSpace/libcsp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GomSpace/libcsp/pulls/55/commits"},"statuses":{"href":"https://api.github.com/repos/GomSpace/libcsp/statuses/2a41b193893566a12c4de0bde4f6556f53ffd05e"}}}}