{"action":"created","comment":{"url":"https://api.github.com/repos/swift-nav/piksi_firmware/pulls/comments/60294362","id":60294362,"diff_hunk":"@@ -0,0 +1,145 @@\n+/*\n+ * Copyright (C) 2016 Swift Navigation Inc.\n+ * Contact: Roman Gezikov <rgezikov@exafore.com>\n+ *\n+ * This source is subject to the license found in the file 'LICENSE' which must\n+ * be be distributed together with this source. All other rights reserved.\n+ *\n+ * THIS CODE AND INFORMATION IS PROVIDED \"AS IS\" WITHOUT WARRANTY OF ANY KIND,\n+ * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED\n+ * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.\n+ */\n+\n+#ifndef SRC_NDB_H_\n+#define SRC_NDB_H_\n+\n+#include <libswiftnav/common.h>\n+#include <libswiftnav/ephemeris.h>\n+#include <libswiftnav/almanac.h>\n+#include <libswiftnav/signal.h>\n+#include <ch.h>\n+#include <cfs/cfs-coffee.h>\n+#include <cfs/cfs.h>\n+#include \"signal.h\"\n+\n+enum ndb_op_code\n+{\n+  NDB_ERR_NONE = 0, /**< No error */\n+  NDB_ERR_MISSING_IE, /**< DB doesn't contain value of this IE */\n+  NDB_ERR_UNSUPPORTED,\n+  NDB_ERR_FILE_IO,\n+  NDB_ERR_INIT_DONE,\n+  NDB_ERR_BAD_PARAM,\n+  NDB_ERR_TIMEOUT,\n+  NDB_ERR_UNRELIABLE_DATA,\n+  NDB_ERR_ALGORITHM_ERROR\n+};\n+\n+enum ndb_data_source\n+{\n+  NDB_DS_UNDEFINED = 0,\n+  NDB_DS_INIT,\n+  NDB_DS_RECEIVER,\n+  NDB_DS_SBP\n+};\n+\n+#define MAX_NDB_FILE_VERSION_LEN 64\n+#define ndb_file_version GIT_VERSION\n+\n+/** NDB IE update counter type */\n+typedef u8 ndb_update_counter_t;\n+/** NDB file handler */\n+typedef int ndb_file_handle_t;\n+/** NDB Timestamp */\n+typedef systime_t ndb_timestamp_t;\n+/* Information element size */\n+typedef u16 ndb_ie_size_t;\n+/* Information element index in the array */\n+typedef u8 ndb_ie_index_t;\n+\n+/** NDB File */\n+typedef struct __attribute__((packed)) {\n+  char* name; /**< Name of the file */\n+  ndb_file_handle_t fh; /**< File handle */\n+  u32 expected_size; /**< Expected file size */\n+} ndb_file_t;\n+\n+typedef union\n+{\n+  ephemeris_t ephe;\n+  almanac_t alma;\n+  u32 l2c_capabilities;\n+} ndb_element_t;\n+\n+/* Maximum waiting time for write request, milliseconds */\n+#define NV_WRITE_REQ_TIMEOUT 100\n+\n+#define NDB_IE_DIRTY (1 << 0) /**< needs to be written to NVM */\n+#define NDB_IE_VALID (1 << 1) /**< value in RAM has been set */\n+#define NDB_IE_IS_VALID(md_ptr) (md_ptr->nv_data.state & NDB_IE_VALID)","path":"src/ndb.h","position":79,"original_position":79,"commit_id":"e330047113e0ebdd82fb1396fdd9bd137997a0c9","original_commit_id":"e330047113e0ebdd82fb1396fdd9bd137997a0c9","user":{"login":"rge-exafore","id":16404161,"avatar_url":"https://avatars.githubusercontent.com/u/16404161?v=3","gravatar_id":"","url":"https://api.github.com/users/rge-exafore","html_url":"https://github.com/rge-exafore","followers_url":"https://api.github.com/users/rge-exafore/followers","following_url":"https://api.github.com/users/rge-exafore/following{/other_user}","gists_url":"https://api.github.com/users/rge-exafore/gists{/gist_id}","starred_url":"https://api.github.com/users/rge-exafore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rge-exafore/subscriptions","organizations_url":"https://api.github.com/users/rge-exafore/orgs","repos_url":"https://api.github.com/users/rge-exafore/repos","events_url":"https://api.github.com/users/rge-exafore/events{/privacy}","received_events_url":"https://api.github.com/users/rge-exafore/received_events","type":"User","site_admin":false},"body":"Done","created_at":"2016-04-19T19:23:43Z","updated_at":"2016-04-19T19:23:43Z","html_url":"https://github.com/swift-nav/piksi_firmware/pull/621#discussion_r60294362","pull_request_url":"https://api.github.com/repos/swift-nav/piksi_firmware/pulls/621","_links":{"self":{"href":"https://api.github.com/repos/swift-nav/piksi_firmware/pulls/comments/60294362"},"html":{"href":"https://github.com/swift-nav/piksi_firmware/pull/621#discussion_r60294362"},"pull_request":{"href":"https://api.github.com/repos/swift-nav/piksi_firmware/pulls/621"}}},"pull_request":{"url":"https://api.github.com/repos/swift-nav/piksi_firmware/pulls/621","id":60084181,"html_url":"https://github.com/swift-nav/piksi_firmware/pull/621","diff_url":"https://github.com/swift-nav/piksi_firmware/pull/621.diff","patch_url":"https://github.com/swift-nav/piksi_firmware/pull/621.patch","issue_url":"https://api.github.com/repos/swift-nav/piksi_firmware/issues/621","number":621,"state":"open","locked":false,"title":"WIP: Add Nav DB module","user":{"login":"rge-exafore","id":16404161,"avatar_url":"https://avatars.githubusercontent.com/u/16404161?v=3","gravatar_id":"","url":"https://api.github.com/users/rge-exafore","html_url":"https://github.com/rge-exafore","followers_url":"https://api.github.com/users/rge-exafore/followers","following_url":"https://api.github.com/users/rge-exafore/following{/other_user}","gists_url":"https://api.github.com/users/rge-exafore/gists{/gist_id}","starred_url":"https://api.github.com/users/rge-exafore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rge-exafore/subscriptions","organizations_url":"https://api.github.com/users/rge-exafore/orgs","repos_url":"https://api.github.com/users/rge-exafore/repos","events_url":"https://api.github.com/users/rge-exafore/events{/privacy}","received_events_url":"https://api.github.com/users/rge-exafore/received_events","type":"User","site_admin":false},"body":"This change adds Nav DB module.\r\n\r\nIssues: \r\nhttps://github.com/swift-nav/exafore_planning/issues/55\r\nhttps://github.com/swift-nav/exafore_planning/issues/63\r\n\r\nDesign doc:\r\nhttps://swiftnav.hackpad.com/Piksi-Nav-DB-SMUivUFDh0Q","created_at":"2016-02-21T11:33:00Z","updated_at":"2016-04-19T19:23:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a9fc5ba89fa3258feaecb03b279e0378e64bc3db","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/swift-nav/piksi_firmware/pulls/621/commits","review_comments_url":"https://api.github.com/repos/swift-nav/piksi_firmware/pulls/621/comments","review_comment_url":"https://api.github.com/repos/swift-nav/piksi_firmware/pulls/comments{/number}","comments_url":"https://api.github.com/repos/swift-nav/piksi_firmware/issues/621/comments","statuses_url":"https://api.github.com/repos/swift-nav/piksi_firmware/statuses/e330047113e0ebdd82fb1396fdd9bd137997a0c9","head":{"label":"rge-exafore:i63-nav-db","ref":"i63-nav-db","sha":"e330047113e0ebdd82fb1396fdd9bd137997a0c9","user":{"login":"rge-exafore","id":16404161,"avatar_url":"https://avatars.githubusercontent.com/u/16404161?v=3","gravatar_id":"","url":"https://api.github.com/users/rge-exafore","html_url":"https://github.com/rge-exafore","followers_url":"https://api.github.com/users/rge-exafore/followers","following_url":"https://api.github.com/users/rge-exafore/following{/other_user}","gists_url":"https://api.github.com/users/rge-exafore/gists{/gist_id}","starred_url":"https://api.github.com/users/rge-exafore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rge-exafore/subscriptions","organizations_url":"https://api.github.com/users/rge-exafore/orgs","repos_url":"https://api.github.com/users/rge-exafore/repos","events_url":"https://api.github.com/users/rge-exafore/events{/privacy}","received_events_url":"https://api.github.com/users/rge-exafore/received_events","type":"User","site_admin":false},"repo":{"id":52073502,"name":"piksi_firmware","full_name":"rge-exafore/piksi_firmware","owner":{"login":"rge-exafore","id":16404161,"avatar_url":"https://avatars.githubusercontent.com/u/16404161?v=3","gravatar_id":"","url":"https://api.github.com/users/rge-exafore","html_url":"https://github.com/rge-exafore","followers_url":"https://api.github.com/users/rge-exafore/followers","following_url":"https://api.github.com/users/rge-exafore/following{/other_user}","gists_url":"https://api.github.com/users/rge-exafore/gists{/gist_id}","starred_url":"https://api.github.com/users/rge-exafore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rge-exafore/subscriptions","organizations_url":"https://api.github.com/users/rge-exafore/orgs","repos_url":"https://api.github.com/users/rge-exafore/repos","events_url":"https://api.github.com/users/rge-exafore/events{/privacy}","received_events_url":"https://api.github.com/users/rge-exafore/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rge-exafore/piksi_firmware","description":"Firmware for the Piksi GNSS receiver.","fork":true,"url":"https://api.github.com/repos/rge-exafore/piksi_firmware","forks_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/forks","keys_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/teams","hooks_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/hooks","issue_events_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/issues/events{/number}","events_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/events","assignees_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/assignees{/user}","branches_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/branches{/branch}","tags_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/tags","blobs_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/git/refs{/sha}","trees_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/statuses/{sha}","languages_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/languages","stargazers_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/stargazers","contributors_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/contributors","subscribers_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/subscribers","subscription_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/subscription","commits_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/commits{/sha}","git_commits_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/git/commits{/sha}","comments_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/comments{/number}","issue_comment_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/issues/comments{/number}","contents_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/contents/{+path}","compare_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/merges","archive_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/downloads","issues_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/issues{/number}","pulls_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/pulls{/number}","milestones_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/milestones{/number}","notifications_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/labels{/name}","releases_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/releases{/id}","deployments_url":"https://api.github.com/repos/rge-exafore/piksi_firmware/deployments","created_at":"2016-02-19T08:35:32Z","updated_at":"2016-02-19T08:35:33Z","pushed_at":"2016-04-18T14:11:27Z","git_url":"git://github.com/rge-exafore/piksi_firmware.git","ssh_url":"git@github.com:rge-exafore/piksi_firmware.git","clone_url":"https://github.com/rge-exafore/piksi_firmware.git","svn_url":"https://github.com/rge-exafore/piksi_firmware","homepage":"swift-nav.com","size":4417,"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":"swift-nav:master","ref":"master","sha":"34db0094bee946eb5f5304eccc52f4db3a261213","user":{"login":"swift-nav","id":1069835,"avatar_url":"https://avatars.githubusercontent.com/u/1069835?v=3","gravatar_id":"","url":"https://api.github.com/users/swift-nav","html_url":"https://github.com/swift-nav","followers_url":"https://api.github.com/users/swift-nav/followers","following_url":"https://api.github.com/users/swift-nav/following{/other_user}","gists_url":"https://api.github.com/users/swift-nav/gists{/gist_id}","starred_url":"https://api.github.com/users/swift-nav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swift-nav/subscriptions","organizations_url":"https://api.github.com/users/swift-nav/orgs","repos_url":"https://api.github.com/users/swift-nav/repos","events_url":"https://api.github.com/users/swift-nav/events{/privacy}","received_events_url":"https://api.github.com/users/swift-nav/received_events","type":"Organization","site_admin":false},"repo":{"id":2464156,"name":"piksi_firmware","full_name":"swift-nav/piksi_firmware","owner":{"login":"swift-nav","id":1069835,"avatar_url":"https://avatars.githubusercontent.com/u/1069835?v=3","gravatar_id":"","url":"https://api.github.com/users/swift-nav","html_url":"https://github.com/swift-nav","followers_url":"https://api.github.com/users/swift-nav/followers","following_url":"https://api.github.com/users/swift-nav/following{/other_user}","gists_url":"https://api.github.com/users/swift-nav/gists{/gist_id}","starred_url":"https://api.github.com/users/swift-nav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swift-nav/subscriptions","organizations_url":"https://api.github.com/users/swift-nav/orgs","repos_url":"https://api.github.com/users/swift-nav/repos","events_url":"https://api.github.com/users/swift-nav/events{/privacy}","received_events_url":"https://api.github.com/users/swift-nav/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/swift-nav/piksi_firmware","description":"Firmware for the Piksi GNSS receiver.","fork":false,"url":"https://api.github.com/repos/swift-nav/piksi_firmware","forks_url":"https://api.github.com/repos/swift-nav/piksi_firmware/forks","keys_url":"https://api.github.com/repos/swift-nav/piksi_firmware/keys{/key_id}","collaborators_url":"https://api.github.com/repos/swift-nav/piksi_firmware/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/swift-nav/piksi_firmware/teams","hooks_url":"https://api.github.com/repos/swift-nav/piksi_firmware/hooks","issue_events_url":"https://api.github.com/repos/swift-nav/piksi_firmware/issues/events{/number}","events_url":"https://api.github.com/repos/swift-nav/piksi_firmware/events","assignees_url":"https://api.github.com/repos/swift-nav/piksi_firmware/assignees{/user}","branches_url":"https://api.github.com/repos/swift-nav/piksi_firmware/branches{/branch}","tags_url":"https://api.github.com/repos/swift-nav/piksi_firmware/tags","blobs_url":"https://api.github.com/repos/swift-nav/piksi_firmware/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/swift-nav/piksi_firmware/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/swift-nav/piksi_firmware/git/refs{/sha}","trees_url":"https://api.github.com/repos/swift-nav/piksi_firmware/git/trees{/sha}","statuses_url":"https://api.github.com/repos/swift-nav/piksi_firmware/statuses/{sha}","languages_url":"https://api.github.com/repos/swift-nav/piksi_firmware/languages","stargazers_url":"https://api.github.com/repos/swift-nav/piksi_firmware/stargazers","contributors_url":"https://api.github.com/repos/swift-nav/piksi_firmware/contributors","subscribers_url":"https://api.github.com/repos/swift-nav/piksi_firmware/subscribers","subscription_url":"https://api.github.com/repos/swift-nav/piksi_firmware/subscription","commits_url":"https://api.github.com/repos/swift-nav/piksi_firmware/commits{/sha}","git_commits_url":"https://api.github.com/repos/swift-nav/piksi_firmware/git/commits{/sha}","comments_url":"https://api.github.com/repos/swift-nav/piksi_firmware/comments{/number}","issue_comment_url":"https://api.github.com/repos/swift-nav/piksi_firmware/issues/comments{/number}","contents_url":"https://api.github.com/repos/swift-nav/piksi_firmware/contents/{+path}","compare_url":"https://api.github.com/repos/swift-nav/piksi_firmware/compare/{base}...{head}","merges_url":"https://api.github.com/repos/swift-nav/piksi_firmware/merges","archive_url":"https://api.github.com/repos/swift-nav/piksi_firmware/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/swift-nav/piksi_firmware/downloads","issues_url":"https://api.github.com/repos/swift-nav/piksi_firmware/issues{/number}","pulls_url":"https://api.github.com/repos/swift-nav/piksi_firmware/pulls{/number}","milestones_url":"https://api.github.com/repos/swift-nav/piksi_firmware/milestones{/number}","notifications_url":"https://api.github.com/repos/swift-nav/piksi_firmware/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/swift-nav/piksi_firmware/labels{/name}","releases_url":"https://api.github.com/repos/swift-nav/piksi_firmware/releases{/id}","deployments_url":"https://api.github.com/repos/swift-nav/piksi_firmware/deployments","created_at":"2011-09-26T23:35:50Z","updated_at":"2016-04-11T09:01:00Z","pushed_at":"2016-04-19T02:25:18Z","git_url":"git://github.com/swift-nav/piksi_firmware.git","ssh_url":"git@github.com:swift-nav/piksi_firmware.git","clone_url":"https://github.com/swift-nav/piksi_firmware.git","svn_url":"https://github.com/swift-nav/piksi_firmware","homepage":"swift-nav.com","size":5937,"stargazers_count":68,"watchers_count":68,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":80,"mirror_url":null,"open_issues_count":118,"forks":80,"open_issues":118,"watchers":68,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/swift-nav/piksi_firmware/pulls/621"},"html":{"href":"https://github.com/swift-nav/piksi_firmware/pull/621"},"issue":{"href":"https://api.github.com/repos/swift-nav/piksi_firmware/issues/621"},"comments":{"href":"https://api.github.com/repos/swift-nav/piksi_firmware/issues/621/comments"},"review_comments":{"href":"https://api.github.com/repos/swift-nav/piksi_firmware/pulls/621/comments"},"review_comment":{"href":"https://api.github.com/repos/swift-nav/piksi_firmware/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/swift-nav/piksi_firmware/pulls/621/commits"},"statuses":{"href":"https://api.github.com/repos/swift-nav/piksi_firmware/statuses/e330047113e0ebdd82fb1396fdd9bd137997a0c9"}}}}