{"action":"created","comment":{"url":"https://api.github.com/repos/kubostech/kubos/pulls/comments/86630675","pull_request_review_id":7282541,"id":86630675,"diff_hunk":"@@ -0,0 +1,66 @@\n+#ifdef YOTTA_CFG_TELEMETRY\n+\n+#include <telemetry/telemetry.h>\n+#include \"telemetry-beacon/beacon.h\"\n+#include <csp/csp.h>\n+\n+static uint8_t data_count = 0;\n+\n+void telemetry_update_beacon(telem_data data)\n+{\n+    if (data.source.dest_flag & TELEMETRY_BEACON_FLAG)\n+    {\n+        /* A dirty hack to fill up the whole array with data */\n+        telem_beacon[data_count++ % TELEMETRY_NUM_BEACON] = data;\n+    }\n+}\n+\n+CSP_DEFINE_TASK(beacon_rx_thread)\n+{\n+    int running = 1;\n+    csp_socket_t *socket = csp_socket(CSP_SO_NONE);\n+    csp_conn_t *conn;\n+    csp_packet_t *packet;\n+\n+    csp_bind(socket, TELEMETRY_BEACON_PORT);\n+    csp_listen(socket, 5);\n+    telem_data data;\n+\n+    while(running) {\n+        if( (conn = csp_accept(socket, 10000)) == NULL ) {\n+            continue;\n+        }\n+\n+        while( (packet = csp_read(conn, 100)) != NULL ) {\n+            switch( csp_conn_dport(conn) ) {\n+                case TELEMETRY_BEACON_PORT:\n+                    data = *((telem_data*)packet->data);\n+                    csp_buffer_free(packet);","path":"telemetry/telemetry-beacon/source/beacon.c","position":38,"original_position":38,"commit_id":"6b9ca9a65189fdbfdc3cbd29b4523d79d2916815","original_commit_id":"6b9ca9a65189fdbfdc3cbd29b4523d79d2916815","user":{"login":"marshall","id":29191,"avatar_url":"https://avatars.githubusercontent.com/u/29191?v=3","gravatar_id":"","url":"https://api.github.com/users/marshall","html_url":"https://github.com/marshall","followers_url":"https://api.github.com/users/marshall/followers","following_url":"https://api.github.com/users/marshall/following{/other_user}","gists_url":"https://api.github.com/users/marshall/gists{/gist_id}","starred_url":"https://api.github.com/users/marshall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marshall/subscriptions","organizations_url":"https://api.github.com/users/marshall/orgs","repos_url":"https://api.github.com/users/marshall/repos","events_url":"https://api.github.com/users/marshall/events{/privacy}","received_events_url":"https://api.github.com/users/marshall/received_events","type":"User","site_admin":false},"body":"I know this is PoC code, but you're actually freeing the memory before passing the underlying data to another function here :)","created_at":"2016-11-04T20:55:20Z","updated_at":"2016-11-04T21:03:13Z","html_url":"https://github.com/kubostech/kubos/pull/12#discussion_r86630675","pull_request_url":"https://api.github.com/repos/kubostech/kubos/pulls/12","_links":{"self":{"href":"https://api.github.com/repos/kubostech/kubos/pulls/comments/86630675"},"html":{"href":"https://github.com/kubostech/kubos/pull/12#discussion_r86630675"},"pull_request":{"href":"https://api.github.com/repos/kubostech/kubos/pulls/12"}}},"pull_request":{"url":"https://api.github.com/repos/kubostech/kubos/pulls/12","id":92408035,"html_url":"https://github.com/kubostech/kubos/pull/12","diff_url":"https://github.com/kubostech/kubos/pull/12.diff","patch_url":"https://github.com/kubostech/kubos/pull/12.patch","issue_url":"https://api.github.com/repos/kubostech/kubos/issues/12","number":12,"state":"open","locked":false,"title":"[WIP] Telemetry architecture","user":{"login":"plauche","id":5727559,"avatar_url":"https://avatars.githubusercontent.com/u/5727559?v=3","gravatar_id":"","url":"https://api.github.com/users/plauche","html_url":"https://github.com/plauche","followers_url":"https://api.github.com/users/plauche/followers","following_url":"https://api.github.com/users/plauche/following{/other_user}","gists_url":"https://api.github.com/users/plauche/gists{/gist_id}","starred_url":"https://api.github.com/users/plauche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plauche/subscriptions","organizations_url":"https://api.github.com/users/plauche/orgs","repos_url":"https://api.github.com/users/plauche/repos","events_url":"https://api.github.com/users/plauche/events{/privacy}","received_events_url":"https://api.github.com/users/plauche/received_events","type":"User","site_admin":false},"body":":construction: This PR represents a simple architecture for future telemetry work. :construction: \r\n\r\nAt its core telemetry represents a message bus. These messages may represent a variety of data sources (sensors, uptime, system errors) and could be sent to a variety of destinations (beacon, log files, health check, ground station). The goal of this architecture is to decouple the telemetry bus from potential data sources and destinations. \r\n\r\nThe telemetry module itself is primarily concerned with:\r\n1. Defining a generic data structure for passing data - **Not currently implemented**\r\n2. Exposing a method for telemetry sources to submit or pass in data\r\n3. Exposing a method for telemetry destinations to retrieve or filter relevant data\r\n\r\nThe telemetry module should **not** be concerned with:\r\n1. Who is submitting data\r\n2. Who is retrieving data\r\n3. How is that data used, stored or recorded\r\n\r\nThe current module provides a simple function call for submitting data `telemetry_submit`, a CSP interface for publishing data to telemetry destinations and (will) use a little bit of code generation magic to tie them together. CSP has no good built-in pub-sub functionality, so currently each telemetry destination must create a listening CSP socket and the telemetry module sends all received data over each destination socket. This is currently hardcoded but could be easily generated via config.json.\r\n\r\nTelemetry data sources are defined in the config.json file and specify where the data should end up. Code generation turns the destination specifications into flags. Currently all destinations receive all data and must check the destination flag themselves. \r\n\r\nHere is an example of a data source configuration:\r\n```json\r\n{\r\n  \"telemetry\":{\r\n    \"sources\":{\r\n      \"gps\":{\r\n        \"beacon\":true\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\nThis would indicate a source named gps which should be included in the beacon. This would be translated into the following structure:\r\n```c\r\nstatic telem_source gps_source = { .source_id = 0, .dest_flag = TELEMETRY_BEACON_FLAG };\r\n\r\n```\r\n\r\nThis data source configuration might also include what type (int/float/char/etc) of data is passed around.\r\n\r\nData destinations such as storage, beacon and health keeping will be responsible for what happens to the data. The telemetry module will not maintain any copies of the data internally. The storage destination will be responsible for recording (all) of the system telemetry. The beacon destination will be responsible for keeping a fresh set its data with AND with sending that out via comms. \r\n\r\nThe hope is that this organization of responsibilities will allow us to easily divide up the telemetry ecosystem (sources + base + destinations) into independent tasks :).\r\n\r\n\r\n/cc @kubostech/core  @kubostech/devs","created_at":"2016-11-04T20:12:38Z","updated_at":"2016-11-04T21:03:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5f507379cef13259c7c6022658973374edf10d2c","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/kubostech/kubos/pulls/12/commits","review_comments_url":"https://api.github.com/repos/kubostech/kubos/pulls/12/comments","review_comment_url":"https://api.github.com/repos/kubostech/kubos/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kubostech/kubos/issues/12/comments","statuses_url":"https://api.github.com/repos/kubostech/kubos/statuses/6b9ca9a65189fdbfdc3cbd29b4523d79d2916815","head":{"label":"kubostech:telemetry_architecture","ref":"telemetry_architecture","sha":"6b9ca9a65189fdbfdc3cbd29b4523d79d2916815","user":{"login":"kubostech","id":9488070,"avatar_url":"https://avatars.githubusercontent.com/u/9488070?v=3","gravatar_id":"","url":"https://api.github.com/users/kubostech","html_url":"https://github.com/kubostech","followers_url":"https://api.github.com/users/kubostech/followers","following_url":"https://api.github.com/users/kubostech/following{/other_user}","gists_url":"https://api.github.com/users/kubostech/gists{/gist_id}","starred_url":"https://api.github.com/users/kubostech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kubostech/subscriptions","organizations_url":"https://api.github.com/users/kubostech/orgs","repos_url":"https://api.github.com/users/kubostech/repos","events_url":"https://api.github.com/users/kubostech/events{/privacy}","received_events_url":"https://api.github.com/users/kubostech/received_events","type":"Organization","site_admin":false},"repo":{"id":71263276,"name":"kubos","full_name":"kubostech/kubos","owner":{"login":"kubostech","id":9488070,"avatar_url":"https://avatars.githubusercontent.com/u/9488070?v=3","gravatar_id":"","url":"https://api.github.com/users/kubostech","html_url":"https://github.com/kubostech","followers_url":"https://api.github.com/users/kubostech/followers","following_url":"https://api.github.com/users/kubostech/following{/other_user}","gists_url":"https://api.github.com/users/kubostech/gists{/gist_id}","starred_url":"https://api.github.com/users/kubostech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kubostech/subscriptions","organizations_url":"https://api.github.com/users/kubostech/orgs","repos_url":"https://api.github.com/users/kubostech/repos","events_url":"https://api.github.com/users/kubostech/events{/privacy}","received_events_url":"https://api.github.com/users/kubostech/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kubostech/kubos","description":null,"fork":false,"url":"https://api.github.com/repos/kubostech/kubos","forks_url":"https://api.github.com/repos/kubostech/kubos/forks","keys_url":"https://api.github.com/repos/kubostech/kubos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kubostech/kubos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kubostech/kubos/teams","hooks_url":"https://api.github.com/repos/kubostech/kubos/hooks","issue_events_url":"https://api.github.com/repos/kubostech/kubos/issues/events{/number}","events_url":"https://api.github.com/repos/kubostech/kubos/events","assignees_url":"https://api.github.com/repos/kubostech/kubos/assignees{/user}","branches_url":"https://api.github.com/repos/kubostech/kubos/branches{/branch}","tags_url":"https://api.github.com/repos/kubostech/kubos/tags","blobs_url":"https://api.github.com/repos/kubostech/kubos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kubostech/kubos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kubostech/kubos/git/refs{/sha}","trees_url":"https://api.github.com/repos/kubostech/kubos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kubostech/kubos/statuses/{sha}","languages_url":"https://api.github.com/repos/kubostech/kubos/languages","stargazers_url":"https://api.github.com/repos/kubostech/kubos/stargazers","contributors_url":"https://api.github.com/repos/kubostech/kubos/contributors","subscribers_url":"https://api.github.com/repos/kubostech/kubos/subscribers","subscription_url":"https://api.github.com/repos/kubostech/kubos/subscription","commits_url":"https://api.github.com/repos/kubostech/kubos/commits{/sha}","git_commits_url":"https://api.github.com/repos/kubostech/kubos/git/commits{/sha}","comments_url":"https://api.github.com/repos/kubostech/kubos/comments{/number}","issue_comment_url":"https://api.github.com/repos/kubostech/kubos/issues/comments{/number}","contents_url":"https://api.github.com/repos/kubostech/kubos/contents/{+path}","compare_url":"https://api.github.com/repos/kubostech/kubos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kubostech/kubos/merges","archive_url":"https://api.github.com/repos/kubostech/kubos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kubostech/kubos/downloads","issues_url":"https://api.github.com/repos/kubostech/kubos/issues{/number}","pulls_url":"https://api.github.com/repos/kubostech/kubos/pulls{/number}","milestones_url":"https://api.github.com/repos/kubostech/kubos/milestones{/number}","notifications_url":"https://api.github.com/repos/kubostech/kubos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kubostech/kubos/labels{/name}","releases_url":"https://api.github.com/repos/kubostech/kubos/releases{/id}","deployments_url":"https://api.github.com/repos/kubostech/kubos/deployments","created_at":"2016-10-18T15:33:43Z","updated_at":"2016-10-24T21:17:49Z","pushed_at":"2016-11-04T20:12:38Z","git_url":"git://github.com/kubostech/kubos.git","ssh_url":"git@github.com:kubostech/kubos.git","clone_url":"https://github.com/kubostech/kubos.git","svn_url":"https://github.com/kubostech/kubos","homepage":null,"size":97238,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"kubostech:master","ref":"master","sha":"d38218e1f3f6d99ebe44d70f739604a0beeb45cc","user":{"login":"kubostech","id":9488070,"avatar_url":"https://avatars.githubusercontent.com/u/9488070?v=3","gravatar_id":"","url":"https://api.github.com/users/kubostech","html_url":"https://github.com/kubostech","followers_url":"https://api.github.com/users/kubostech/followers","following_url":"https://api.github.com/users/kubostech/following{/other_user}","gists_url":"https://api.github.com/users/kubostech/gists{/gist_id}","starred_url":"https://api.github.com/users/kubostech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kubostech/subscriptions","organizations_url":"https://api.github.com/users/kubostech/orgs","repos_url":"https://api.github.com/users/kubostech/repos","events_url":"https://api.github.com/users/kubostech/events{/privacy}","received_events_url":"https://api.github.com/users/kubostech/received_events","type":"Organization","site_admin":false},"repo":{"id":71263276,"name":"kubos","full_name":"kubostech/kubos","owner":{"login":"kubostech","id":9488070,"avatar_url":"https://avatars.githubusercontent.com/u/9488070?v=3","gravatar_id":"","url":"https://api.github.com/users/kubostech","html_url":"https://github.com/kubostech","followers_url":"https://api.github.com/users/kubostech/followers","following_url":"https://api.github.com/users/kubostech/following{/other_user}","gists_url":"https://api.github.com/users/kubostech/gists{/gist_id}","starred_url":"https://api.github.com/users/kubostech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kubostech/subscriptions","organizations_url":"https://api.github.com/users/kubostech/orgs","repos_url":"https://api.github.com/users/kubostech/repos","events_url":"https://api.github.com/users/kubostech/events{/privacy}","received_events_url":"https://api.github.com/users/kubostech/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kubostech/kubos","description":null,"fork":false,"url":"https://api.github.com/repos/kubostech/kubos","forks_url":"https://api.github.com/repos/kubostech/kubos/forks","keys_url":"https://api.github.com/repos/kubostech/kubos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kubostech/kubos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kubostech/kubos/teams","hooks_url":"https://api.github.com/repos/kubostech/kubos/hooks","issue_events_url":"https://api.github.com/repos/kubostech/kubos/issues/events{/number}","events_url":"https://api.github.com/repos/kubostech/kubos/events","assignees_url":"https://api.github.com/repos/kubostech/kubos/assignees{/user}","branches_url":"https://api.github.com/repos/kubostech/kubos/branches{/branch}","tags_url":"https://api.github.com/repos/kubostech/kubos/tags","blobs_url":"https://api.github.com/repos/kubostech/kubos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kubostech/kubos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kubostech/kubos/git/refs{/sha}","trees_url":"https://api.github.com/repos/kubostech/kubos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kubostech/kubos/statuses/{sha}","languages_url":"https://api.github.com/repos/kubostech/kubos/languages","stargazers_url":"https://api.github.com/repos/kubostech/kubos/stargazers","contributors_url":"https://api.github.com/repos/kubostech/kubos/contributors","subscribers_url":"https://api.github.com/repos/kubostech/kubos/subscribers","subscription_url":"https://api.github.com/repos/kubostech/kubos/subscription","commits_url":"https://api.github.com/repos/kubostech/kubos/commits{/sha}","git_commits_url":"https://api.github.com/repos/kubostech/kubos/git/commits{/sha}","comments_url":"https://api.github.com/repos/kubostech/kubos/comments{/number}","issue_comment_url":"https://api.github.com/repos/kubostech/kubos/issues/comments{/number}","contents_url":"https://api.github.com/repos/kubostech/kubos/contents/{+path}","compare_url":"https://api.github.com/repos/kubostech/kubos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kubostech/kubos/merges","archive_url":"https://api.github.com/repos/kubostech/kubos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kubostech/kubos/downloads","issues_url":"https://api.github.com/repos/kubostech/kubos/issues{/number}","pulls_url":"https://api.github.com/repos/kubostech/kubos/pulls{/number}","milestones_url":"https://api.github.com/repos/kubostech/kubos/milestones{/number}","notifications_url":"https://api.github.com/repos/kubostech/kubos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kubostech/kubos/labels{/name}","releases_url":"https://api.github.com/repos/kubostech/kubos/releases{/id}","deployments_url":"https://api.github.com/repos/kubostech/kubos/deployments","created_at":"2016-10-18T15:33:43Z","updated_at":"2016-10-24T21:17:49Z","pushed_at":"2016-11-04T20:12:38Z","git_url":"git://github.com/kubostech/kubos.git","ssh_url":"git@github.com:kubostech/kubos.git","clone_url":"https://github.com/kubostech/kubos.git","svn_url":"https://github.com/kubostech/kubos","homepage":null,"size":97238,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kubostech/kubos/pulls/12"},"html":{"href":"https://github.com/kubostech/kubos/pull/12"},"issue":{"href":"https://api.github.com/repos/kubostech/kubos/issues/12"},"comments":{"href":"https://api.github.com/repos/kubostech/kubos/issues/12/comments"},"review_comments":{"href":"https://api.github.com/repos/kubostech/kubos/pulls/12/comments"},"review_comment":{"href":"https://api.github.com/repos/kubostech/kubos/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kubostech/kubos/pulls/12/commits"},"statuses":{"href":"https://api.github.com/repos/kubostech/kubos/statuses/6b9ca9a65189fdbfdc3cbd29b4523d79d2916815"}}}}
{"actor":{"display_login":"marshall"}}