{"action":"created","comment":{"url":"https://api.github.com/repos/uw-midsun/firmware/pulls/comments/176943173","pull_request_review_id":106732791,"id":176943173,"diff_hunk":"@@ -0,0 +1,68 @@\n+#include \"generic_can_network.h\"\n+\n+#include <stddef.h>\n+#include <stdint.h>\n+#include <string.h>\n+\n+#include \"can.h\"\n+#include \"generic_can.h\"\n+#include \"generic_can_helpers.h\"\n+#include \"generic_can_msg.h\"\n+#include \"log.h\"\n+#include \"status.h\"\n+\n+static GenericCanInterface s_interface;\n+\n+// CanRxHandlerCb\n+static StatusCode prv_generic_can_network_rx_handler(const CANMessage *msg, void *context,\n+                                                     CANAckStatus *ack_reply) {\n+  (void)ack_reply;\n+  GenericCanNetwork *gcn = context;\n+  GenericCanMsg generic_msg = { 0 };\n+  can_message_to_generic_can_message(msg, &generic_msg);\n+  for (size_t i = 0; i < NUM_GENERIC_CAN_RX_HANDLERS; i++) {\n+    if (gcn->base.rx_storage[i].rx_handler != NULL &&\n+        (generic_msg.id & gcn->base.rx_storage[i].mask) == gcn->base.rx_storage[i].filter) {\n+      gcn->base.rx_storage[i].rx_handler(&generic_msg, gcn->base.rx_storage[i].context);\n+      break;\n+    }\n+  }\n+  return STATUS_CODE_OK;\n+}\n+\n+// tx\n+static StatusCode prv_tx(const GenericCan *can, const GenericCanMsg *msg) {\n+  GenericCanNetwork *gcn = (GenericCanNetwork *)can;\n+  if (gcn->base.interface != &s_interface) {\n+    return status_msg(STATUS_CODE_INVALID_ARGS, \"GenericCan not aligned to GenericCanNetwork.\");\n+  }\n+  CANMessage can_msg = { 0 };\n+  status_ok_or_return(generic_can_msg_to_can_message(msg, &can_msg));\n+\n+  return can_transmit(&can_msg, NULL);\n+}\n+\n+// register_rx\n+static StatusCode prv_register_rx(GenericCan *can, GenericCanRx rx_handler, uint32_t mask,\n+                                  uint32_t filter, bool extended, void *context) {\n+  GenericCanNetwork *gcn = (GenericCanNetwork *)can;\n+  if (gcn->base.interface != &s_interface) {\n+    return status_msg(STATUS_CODE_INVALID_ARGS, \"GenericCan not aligned to GenericCanNetwork.\");\n+  } else if (extended) {\n+    return status_code(STATUS_CODE_INVALID_ARGS);\n+  }\n+  return generic_can_helpers_register_rx(can, rx_handler, mask, filter, context);\n+}\n+\n+StatusCode generic_can_network_init(GenericCanNetwork *can_network) {\n+  s_interface.tx = prv_tx;\n+  s_interface.register_rx = prv_register_rx;\n+\n+  memset(can_network->base.rx_storage, 0, sizeof(GenericCanRx) * NUM_GENERIC_CAN_RX_HANDLERS);\n+\n+  can_network->base.interface = &s_interface;\n+  status_ok_or_return(","path":"projects/charger/src/generic_can_network.c","position":null,"original_position":64,"commit_id":"7ecc1a3ac1e79207de259605a37d4eda488856ae","original_commit_id":"0c79dec1162bd2e4a13950e6df265abedda65400","user":{"login":"ckitagawa","id":9539007,"avatar_url":"https://avatars0.githubusercontent.com/u/9539007?v=4","gravatar_id":"","url":"https://api.github.com/users/ckitagawa","html_url":"https://github.com/ckitagawa","followers_url":"https://api.github.com/users/ckitagawa/followers","following_url":"https://api.github.com/users/ckitagawa/following{/other_user}","gists_url":"https://api.github.com/users/ckitagawa/gists{/gist_id}","starred_url":"https://api.github.com/users/ckitagawa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ckitagawa/subscriptions","organizations_url":"https://api.github.com/users/ckitagawa/orgs","repos_url":"https://api.github.com/users/ckitagawa/repos","events_url":"https://api.github.com/users/ckitagawa/events{/privacy}","received_events_url":"https://api.github.com/users/ckitagawa/received_events","type":"User","site_admin":false},"body":"N/A after below comment.","created_at":"2018-03-25T14:56:39Z","updated_at":"2018-03-25T14:56:39Z","html_url":"https://github.com/uw-midsun/firmware/pull/140#discussion_r176943173","pull_request_url":"https://api.github.com/repos/uw-midsun/firmware/pulls/140","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/uw-midsun/firmware/pulls/comments/176943173"},"html":{"href":"https://github.com/uw-midsun/firmware/pull/140#discussion_r176943173"},"pull_request":{"href":"https://api.github.com/repos/uw-midsun/firmware/pulls/140"}},"in_reply_to_id":176913718},"pull_request":{"url":"https://api.github.com/repos/uw-midsun/firmware/pulls/140","id":174199951,"html_url":"https://github.com/uw-midsun/firmware/pull/140","diff_url":"https://github.com/uw-midsun/firmware/pull/140.diff","patch_url":"https://github.com/uw-midsun/firmware/pull/140.patch","issue_url":"https://api.github.com/repos/uw-midsun/firmware/issues/140","number":140,"state":"open","locked":false,"title":"ELEC-355: Add generic can abstraction","user":{"login":"ckitagawa","id":9539007,"avatar_url":"https://avatars0.githubusercontent.com/u/9539007?v=4","gravatar_id":"","url":"https://api.github.com/users/ckitagawa","html_url":"https://github.com/ckitagawa","followers_url":"https://api.github.com/users/ckitagawa/followers","following_url":"https://api.github.com/users/ckitagawa/following{/other_user}","gists_url":"https://api.github.com/users/ckitagawa/gists{/gist_id}","starred_url":"https://api.github.com/users/ckitagawa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ckitagawa/subscriptions","organizations_url":"https://api.github.com/users/ckitagawa/orgs","repos_url":"https://api.github.com/users/ckitagawa/repos","events_url":"https://api.github.com/users/ckitagawa/events{/privacy}","received_events_url":"https://api.github.com/users/ckitagawa/received_events","type":"User","site_admin":false},"body":"An abstraction of CAN using dynamic dispatch to provide an interchangeable interface between CAN (Network layer), CAN HW and CAN UART.\r\n\r\nThis could be moved to `ms-helpers` depending on if others would use it. ","created_at":"2018-03-11T02:00:02Z","updated_at":"2018-03-25T14:56:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7837f32213819264dd6092bb6a7a1c85d560c8f9","assignee":null,"assignees":[],"requested_reviewers":[{"login":"karlding","id":6836385,"avatar_url":"https://avatars2.githubusercontent.com/u/6836385?v=4","gravatar_id":"","url":"https://api.github.com/users/karlding","html_url":"https://github.com/karlding","followers_url":"https://api.github.com/users/karlding/followers","following_url":"https://api.github.com/users/karlding/following{/other_user}","gists_url":"https://api.github.com/users/karlding/gists{/gist_id}","starred_url":"https://api.github.com/users/karlding/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karlding/subscriptions","organizations_url":"https://api.github.com/users/karlding/orgs","repos_url":"https://api.github.com/users/karlding/repos","events_url":"https://api.github.com/users/karlding/events{/privacy}","received_events_url":"https://api.github.com/users/karlding/received_events","type":"User","site_admin":false},{"login":"a3farmah","id":32603090,"avatar_url":"https://avatars1.githubusercontent.com/u/32603090?v=4","gravatar_id":"","url":"https://api.github.com/users/a3farmah","html_url":"https://github.com/a3farmah","followers_url":"https://api.github.com/users/a3farmah/followers","following_url":"https://api.github.com/users/a3farmah/following{/other_user}","gists_url":"https://api.github.com/users/a3farmah/gists{/gist_id}","starred_url":"https://api.github.com/users/a3farmah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/a3farmah/subscriptions","organizations_url":"https://api.github.com/users/a3farmah/orgs","repos_url":"https://api.github.com/users/a3farmah/repos","events_url":"https://api.github.com/users/a3farmah/events{/privacy}","received_events_url":"https://api.github.com/users/a3farmah/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/uw-midsun/firmware/pulls/140/commits","review_comments_url":"https://api.github.com/repos/uw-midsun/firmware/pulls/140/comments","review_comment_url":"https://api.github.com/repos/uw-midsun/firmware/pulls/comments{/number}","comments_url":"https://api.github.com/repos/uw-midsun/firmware/issues/140/comments","statuses_url":"https://api.github.com/repos/uw-midsun/firmware/statuses/7ecc1a3ac1e79207de259605a37d4eda488856ae","head":{"label":"uw-midsun:elec_355_generic_can","ref":"elec_355_generic_can","sha":"7ecc1a3ac1e79207de259605a37d4eda488856ae","user":{"login":"uw-midsun","id":14828575,"avatar_url":"https://avatars1.githubusercontent.com/u/14828575?v=4","gravatar_id":"","url":"https://api.github.com/users/uw-midsun","html_url":"https://github.com/uw-midsun","followers_url":"https://api.github.com/users/uw-midsun/followers","following_url":"https://api.github.com/users/uw-midsun/following{/other_user}","gists_url":"https://api.github.com/users/uw-midsun/gists{/gist_id}","starred_url":"https://api.github.com/users/uw-midsun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uw-midsun/subscriptions","organizations_url":"https://api.github.com/users/uw-midsun/orgs","repos_url":"https://api.github.com/users/uw-midsun/repos","events_url":"https://api.github.com/users/uw-midsun/events{/privacy}","received_events_url":"https://api.github.com/users/uw-midsun/received_events","type":"Organization","site_admin":false},"repo":{"id":69197028,"name":"firmware","full_name":"uw-midsun/firmware","owner":{"login":"uw-midsun","id":14828575,"avatar_url":"https://avatars1.githubusercontent.com/u/14828575?v=4","gravatar_id":"","url":"https://api.github.com/users/uw-midsun","html_url":"https://github.com/uw-midsun","followers_url":"https://api.github.com/users/uw-midsun/followers","following_url":"https://api.github.com/users/uw-midsun/following{/other_user}","gists_url":"https://api.github.com/users/uw-midsun/gists{/gist_id}","starred_url":"https://api.github.com/users/uw-midsun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uw-midsun/subscriptions","organizations_url":"https://api.github.com/users/uw-midsun/orgs","repos_url":"https://api.github.com/users/uw-midsun/repos","events_url":"https://api.github.com/users/uw-midsun/events{/privacy}","received_events_url":"https://api.github.com/users/uw-midsun/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/uw-midsun/firmware","description":"Firmware for MSXII","fork":false,"url":"https://api.github.com/repos/uw-midsun/firmware","forks_url":"https://api.github.com/repos/uw-midsun/firmware/forks","keys_url":"https://api.github.com/repos/uw-midsun/firmware/keys{/key_id}","collaborators_url":"https://api.github.com/repos/uw-midsun/firmware/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/uw-midsun/firmware/teams","hooks_url":"https://api.github.com/repos/uw-midsun/firmware/hooks","issue_events_url":"https://api.github.com/repos/uw-midsun/firmware/issues/events{/number}","events_url":"https://api.github.com/repos/uw-midsun/firmware/events","assignees_url":"https://api.github.com/repos/uw-midsun/firmware/assignees{/user}","branches_url":"https://api.github.com/repos/uw-midsun/firmware/branches{/branch}","tags_url":"https://api.github.com/repos/uw-midsun/firmware/tags","blobs_url":"https://api.github.com/repos/uw-midsun/firmware/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/uw-midsun/firmware/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/uw-midsun/firmware/git/refs{/sha}","trees_url":"https://api.github.com/repos/uw-midsun/firmware/git/trees{/sha}","statuses_url":"https://api.github.com/repos/uw-midsun/firmware/statuses/{sha}","languages_url":"https://api.github.com/repos/uw-midsun/firmware/languages","stargazers_url":"https://api.github.com/repos/uw-midsun/firmware/stargazers","contributors_url":"https://api.github.com/repos/uw-midsun/firmware/contributors","subscribers_url":"https://api.github.com/repos/uw-midsun/firmware/subscribers","subscription_url":"https://api.github.com/repos/uw-midsun/firmware/subscription","commits_url":"https://api.github.com/repos/uw-midsun/firmware/commits{/sha}","git_commits_url":"https://api.github.com/repos/uw-midsun/firmware/git/commits{/sha}","comments_url":"https://api.github.com/repos/uw-midsun/firmware/comments{/number}","issue_comment_url":"https://api.github.com/repos/uw-midsun/firmware/issues/comments{/number}","contents_url":"https://api.github.com/repos/uw-midsun/firmware/contents/{+path}","compare_url":"https://api.github.com/repos/uw-midsun/firmware/compare/{base}...{head}","merges_url":"https://api.github.com/repos/uw-midsun/firmware/merges","archive_url":"https://api.github.com/repos/uw-midsun/firmware/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/uw-midsun/firmware/downloads","issues_url":"https://api.github.com/repos/uw-midsun/firmware/issues{/number}","pulls_url":"https://api.github.com/repos/uw-midsun/firmware/pulls{/number}","milestones_url":"https://api.github.com/repos/uw-midsun/firmware/milestones{/number}","notifications_url":"https://api.github.com/repos/uw-midsun/firmware/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/uw-midsun/firmware/labels{/name}","releases_url":"https://api.github.com/repos/uw-midsun/firmware/releases{/id}","deployments_url":"https://api.github.com/repos/uw-midsun/firmware/deployments","created_at":"2016-09-25T23:38:58Z","updated_at":"2018-03-24T17:21:47Z","pushed_at":"2018-03-25T14:56:35Z","git_url":"git://github.com/uw-midsun/firmware.git","ssh_url":"git@github.com:uw-midsun/firmware.git","clone_url":"https://github.com/uw-midsun/firmware.git","svn_url":"https://github.com/uw-midsun/firmware","homepage":"","size":2660,"stargazers_count":3,"watchers_count":3,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":9,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":2,"open_issues":9,"watchers":3,"default_branch":"master"}},"base":{"label":"uw-midsun:master","ref":"master","sha":"4306b7959eb0747c52f6f541f56e868b0596abcf","user":{"login":"uw-midsun","id":14828575,"avatar_url":"https://avatars1.githubusercontent.com/u/14828575?v=4","gravatar_id":"","url":"https://api.github.com/users/uw-midsun","html_url":"https://github.com/uw-midsun","followers_url":"https://api.github.com/users/uw-midsun/followers","following_url":"https://api.github.com/users/uw-midsun/following{/other_user}","gists_url":"https://api.github.com/users/uw-midsun/gists{/gist_id}","starred_url":"https://api.github.com/users/uw-midsun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uw-midsun/subscriptions","organizations_url":"https://api.github.com/users/uw-midsun/orgs","repos_url":"https://api.github.com/users/uw-midsun/repos","events_url":"https://api.github.com/users/uw-midsun/events{/privacy}","received_events_url":"https://api.github.com/users/uw-midsun/received_events","type":"Organization","site_admin":false},"repo":{"id":69197028,"name":"firmware","full_name":"uw-midsun/firmware","owner":{"login":"uw-midsun","id":14828575,"avatar_url":"https://avatars1.githubusercontent.com/u/14828575?v=4","gravatar_id":"","url":"https://api.github.com/users/uw-midsun","html_url":"https://github.com/uw-midsun","followers_url":"https://api.github.com/users/uw-midsun/followers","following_url":"https://api.github.com/users/uw-midsun/following{/other_user}","gists_url":"https://api.github.com/users/uw-midsun/gists{/gist_id}","starred_url":"https://api.github.com/users/uw-midsun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uw-midsun/subscriptions","organizations_url":"https://api.github.com/users/uw-midsun/orgs","repos_url":"https://api.github.com/users/uw-midsun/repos","events_url":"https://api.github.com/users/uw-midsun/events{/privacy}","received_events_url":"https://api.github.com/users/uw-midsun/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/uw-midsun/firmware","description":"Firmware for MSXII","fork":false,"url":"https://api.github.com/repos/uw-midsun/firmware","forks_url":"https://api.github.com/repos/uw-midsun/firmware/forks","keys_url":"https://api.github.com/repos/uw-midsun/firmware/keys{/key_id}","collaborators_url":"https://api.github.com/repos/uw-midsun/firmware/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/uw-midsun/firmware/teams","hooks_url":"https://api.github.com/repos/uw-midsun/firmware/hooks","issue_events_url":"https://api.github.com/repos/uw-midsun/firmware/issues/events{/number}","events_url":"https://api.github.com/repos/uw-midsun/firmware/events","assignees_url":"https://api.github.com/repos/uw-midsun/firmware/assignees{/user}","branches_url":"https://api.github.com/repos/uw-midsun/firmware/branches{/branch}","tags_url":"https://api.github.com/repos/uw-midsun/firmware/tags","blobs_url":"https://api.github.com/repos/uw-midsun/firmware/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/uw-midsun/firmware/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/uw-midsun/firmware/git/refs{/sha}","trees_url":"https://api.github.com/repos/uw-midsun/firmware/git/trees{/sha}","statuses_url":"https://api.github.com/repos/uw-midsun/firmware/statuses/{sha}","languages_url":"https://api.github.com/repos/uw-midsun/firmware/languages","stargazers_url":"https://api.github.com/repos/uw-midsun/firmware/stargazers","contributors_url":"https://api.github.com/repos/uw-midsun/firmware/contributors","subscribers_url":"https://api.github.com/repos/uw-midsun/firmware/subscribers","subscription_url":"https://api.github.com/repos/uw-midsun/firmware/subscription","commits_url":"https://api.github.com/repos/uw-midsun/firmware/commits{/sha}","git_commits_url":"https://api.github.com/repos/uw-midsun/firmware/git/commits{/sha}","comments_url":"https://api.github.com/repos/uw-midsun/firmware/comments{/number}","issue_comment_url":"https://api.github.com/repos/uw-midsun/firmware/issues/comments{/number}","contents_url":"https://api.github.com/repos/uw-midsun/firmware/contents/{+path}","compare_url":"https://api.github.com/repos/uw-midsun/firmware/compare/{base}...{head}","merges_url":"https://api.github.com/repos/uw-midsun/firmware/merges","archive_url":"https://api.github.com/repos/uw-midsun/firmware/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/uw-midsun/firmware/downloads","issues_url":"https://api.github.com/repos/uw-midsun/firmware/issues{/number}","pulls_url":"https://api.github.com/repos/uw-midsun/firmware/pulls{/number}","milestones_url":"https://api.github.com/repos/uw-midsun/firmware/milestones{/number}","notifications_url":"https://api.github.com/repos/uw-midsun/firmware/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/uw-midsun/firmware/labels{/name}","releases_url":"https://api.github.com/repos/uw-midsun/firmware/releases{/id}","deployments_url":"https://api.github.com/repos/uw-midsun/firmware/deployments","created_at":"2016-09-25T23:38:58Z","updated_at":"2018-03-24T17:21:47Z","pushed_at":"2018-03-25T14:56:35Z","git_url":"git://github.com/uw-midsun/firmware.git","ssh_url":"git@github.com:uw-midsun/firmware.git","clone_url":"https://github.com/uw-midsun/firmware.git","svn_url":"https://github.com/uw-midsun/firmware","homepage":"","size":2660,"stargazers_count":3,"watchers_count":3,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":9,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":2,"open_issues":9,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/uw-midsun/firmware/pulls/140"},"html":{"href":"https://github.com/uw-midsun/firmware/pull/140"},"issue":{"href":"https://api.github.com/repos/uw-midsun/firmware/issues/140"},"comments":{"href":"https://api.github.com/repos/uw-midsun/firmware/issues/140/comments"},"review_comments":{"href":"https://api.github.com/repos/uw-midsun/firmware/pulls/140/comments"},"review_comment":{"href":"https://api.github.com/repos/uw-midsun/firmware/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/uw-midsun/firmware/pulls/140/commits"},"statuses":{"href":"https://api.github.com/repos/uw-midsun/firmware/statuses/7ecc1a3ac1e79207de259605a37d4eda488856ae"}},"author_association":"OWNER"}}
{"actor":{"display_login":"ckitagawa"}}