GitHub PullRequestReviewCommentEvent at 2014-12-16 14:41:38
Repository: RIOT
Actor: OlegHahm
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/comments/21901285","id":21901285,"diff_hunk":"@@ -1,76 +1,185 @@\n-/**\n- * Shell commands for real time clock\n- *\n- * Copyright (C) 2013  INRIA.\n+/*\n+ * Copyright 2013 INRIA.\n+ * Copyright 2014 Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>\n  *\n  * This file is subject to the terms and conditions of the GNU Lesser\n  * General Public License v2.1. See the file LICENSE in the top level\n  * directory for more details.\n- *\n+ */\n+\n+/**\n  * @ingroup shell_commands\n  * @{\n- * @file    sc_rtc.c\n- * @brief   provides shell commands to access the rtc\n+ * @file\n+ * @brief   Shell command implementation for the peripheral RTC interface\n+ *\n  * @author  Oliver Hahm <oliver.hahm@inria.fr>\n+ * @author  Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>\n  * @}\n  */\n \n+#ifdef FEATURE_PERIPH_RTC\n+\n #include <stdio.h>\n #include <stdint.h>\n #include <string.h>\n+#include <stdlib.h>\n \n-#ifdef MODULE_RTC\n-#include \"rtc.h\"\n+#include \"periph/rtc.h\"\n \n-static void _gettime_handler(void)\n+void _alarm_handler(void *arg)\n {\n-    struct tm now;\n-    rtc_get_localtime(&now);\n+    (void) arg;\n \n-    /* cppcheck: see man 3 asctime: obsoleted by POSIX.1-2008 */\n-    /* cppcheck-suppress obsoleteFunctionsasctime */\n-    printf(\"%s\", asctime(&now));\n+    puts(\"The alarm rang\");\n }\n \n-static void _settime_handler(char **argv)\n+static int dow(int year, int month, int day)\n {\n-    do {\n-        short i1, i2, i3;\n+    /* calculate the day of week using Tøndering's algorithm */\n+    static int t[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};\n+    year -= month < 3;\n+    return (year + year/4 - year/100 + year/400 + t[month-1] + day) % 7;\n+}\n \n-        int res = sscanf(argv[1], \"%6hd-%6hd-%6hd\", &i1, &i2, &i3);\n-        if (res != 3) {\n-            break;\n-        }\n \n-        struct tm now;\n-        now.tm_year = i1 - 1900;\n-        now.tm_mon = i2 - 1;\n-        now.tm_mday = i3;\n+static int _parse_time(char **argv, struct tm *time)\n+{\n+    short i1, i2, i3;\n+    char *end;\n+\n+    i1 = strtol(argv[0], &end, 10);\n+    i2 = strtol(end + 1, &end, 10);\n+    i3 = strtol(end + 1, &end, 10);\n+\n+    time->tm_year = i1 - 1900;\n+    time->tm_mon = i2 - 1;\n+    time->tm_mday = i3;\n+    time->tm_wday = dow(i1, i2, i3);\n+\n+    i1 = strtol(argv[1], &end, 10);\n+    i2 = strtol(end + 1, &end, 10);\n+    i3 = strtol(end + 1, &end, 10);\n+\n+    time->tm_hour = i1;\n+    time->tm_min = i2;\n+    time->tm_sec = i3;\n+\n+    time->tm_isdst = -1; /* undefined */\n+\n+    return 0;\n+}\n+\n+static void _print_time(struct tm *time)\n+{\n+    printf(\"%04i-%02i-%02i %02i:%02i:%02i\\n\",\n+            time->tm_year + 1900, time->tm_mon + 1, time->tm_mday,\n+            time->tm_hour, time->tm_min, time->tm_sec\n+          );\n+}\n+\n+static void _rtc_getalarm(void)\n+{\n+    struct tm t;\n+    if (rtc_get_alarm(&t) == 0) {\n+        _print_time(&t);\n+    }\n+    else {\n+        puts(\"error\");\n+    }\n+}\n+\n+static void _rtc_setalarm(char **argv)\n+{\n+    struct tm now;\n \n-        res = sscanf(argv[2], \"%6hd:%6hd:%6hd\", &i1, &i2, &i3);\n-        if (res != 3) {\n-            break;\n+    if (_parse_time(argv, &now) == 0) {\n+        if (rtc_set_alarm(&now, _alarm_handler, NULL) == -1) {\n+            puts(\"error\");","path":"sys/shell/commands/sc_rtc.c","position":127,"original_position":127,"commit_id":"8a0a9250dd03088b6928fbcf4be54ae492c43aa9","original_commit_id":"8a0a9250dd03088b6928fbcf4be54ae492c43aa9","user":{"login":"OlegHahm","id":1590423,"avatar_url":"https://avatars.githubusercontent.com/u/1590423?v=3","gravatar_id":"","url":"https://api.github.com/users/OlegHahm","html_url":"https://github.com/OlegHahm","followers_url":"https://api.github.com/users/OlegHahm/followers","following_url":"https://api.github.com/users/OlegHahm/following{/other_user}","gists_url":"https://api.github.com/users/OlegHahm/gists{/gist_id}","starred_url":"https://api.github.com/users/OlegHahm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OlegHahm/subscriptions","organizations_url":"https://api.github.com/users/OlegHahm/orgs","repos_url":"https://api.github.com/users/OlegHahm/repos","events_url":"https://api.github.com/users/OlegHahm/events{/privacy}","received_events_url":"https://api.github.com/users/OlegHahm/received_events","type":"User","site_admin":false},"body":"s.a.","created_at":"2014-12-16T14:41:38Z","updated_at":"2014-12-16T14:41:38Z","html_url":"https://github.com/RIOT-OS/RIOT/pull/2061#discussion_r21901285","pull_request_url":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/2061","_links":{"self":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/comments/21901285"},"html":{"href":"https://github.com/RIOT-OS/RIOT/pull/2061#discussion_r21901285"},"pull_request":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/2061"}}},"pull_request":{"url":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/2061","id":24784598,"html_url":"https://github.com/RIOT-OS/RIOT/pull/2061","diff_url":"https://github.com/RIOT-OS/RIOT/pull/2061.diff","patch_url":"https://github.com/RIOT-OS/RIOT/pull/2061.patch","issue_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/2061","number":2061,"state":"open","locked":false,"title":"RTC shell command update","user":{"login":"LudwigOrtmann","id":3739173,"avatar_url":"https://avatars.githubusercontent.com/u/3739173?v=3","gravatar_id":"","url":"https://api.github.com/users/LudwigOrtmann","html_url":"https://github.com/LudwigOrtmann","followers_url":"https://api.github.com/users/LudwigOrtmann/followers","following_url":"https://api.github.com/users/LudwigOrtmann/following{/other_user}","gists_url":"https://api.github.com/users/LudwigOrtmann/gists{/gist_id}","starred_url":"https://api.github.com/users/LudwigOrtmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LudwigOrtmann/subscriptions","organizations_url":"https://api.github.com/users/LudwigOrtmann/orgs","repos_url":"https://api.github.com/users/LudwigOrtmann/repos","events_url":"https://api.github.com/users/LudwigOrtmann/events{/privacy}","received_events_url":"https://api.github.com/users/LudwigOrtmann/received_events","type":"User","site_admin":false},"body":"* rewrite rtc command for periph/rtc\r\n* adopt default application\r\n\r\n**Based on** ~~https://github.com/RIOT-OS/RIOT/pull/2060 and~~ https://github.com/RIOT-OS/RIOT/pull/1922\r\n\r\nUpdate;\r\nRemoved `strptime` for now","created_at":"2014-11-20T17:55:23Z","updated_at":"2014-12-16T14:41:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"52b1e91daf0d4e8ff60e5accad9da57da36fc66b","assignee":{"login":"haukepetersen","id":620834,"avatar_url":"https://avatars.githubusercontent.com/u/620834?v=3","gravatar_id":"","url":"https://api.github.com/users/haukepetersen","html_url":"https://github.com/haukepetersen","followers_url":"https://api.github.com/users/haukepetersen/followers","following_url":"https://api.github.com/users/haukepetersen/following{/other_user}","gists_url":"https://api.github.com/users/haukepetersen/gists{/gist_id}","starred_url":"https://api.github.com/users/haukepetersen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haukepetersen/subscriptions","organizations_url":"https://api.github.com/users/haukepetersen/orgs","repos_url":"https://api.github.com/users/haukepetersen/repos","events_url":"https://api.github.com/users/haukepetersen/events{/privacy}","received_events_url":"https://api.github.com/users/haukepetersen/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/2061/commits","review_comments_url":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/2061/comments","review_comment_url":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/comments/{number}","comments_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/2061/comments","statuses_url":"https://api.github.com/repos/RIOT-OS/RIOT/statuses/8a0a9250dd03088b6928fbcf4be54ae492c43aa9","head":{"label":"LudwigOrtmann:shell-rtc","ref":"shell-rtc","sha":"8a0a9250dd03088b6928fbcf4be54ae492c43aa9","user":{"login":"LudwigOrtmann","id":3739173,"avatar_url":"https://avatars.githubusercontent.com/u/3739173?v=3","gravatar_id":"","url":"https://api.github.com/users/LudwigOrtmann","html_url":"https://github.com/LudwigOrtmann","followers_url":"https://api.github.com/users/LudwigOrtmann/followers","following_url":"https://api.github.com/users/LudwigOrtmann/following{/other_user}","gists_url":"https://api.github.com/users/LudwigOrtmann/gists{/gist_id}","starred_url":"https://api.github.com/users/LudwigOrtmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LudwigOrtmann/subscriptions","organizations_url":"https://api.github.com/users/LudwigOrtmann/orgs","repos_url":"https://api.github.com/users/LudwigOrtmann/repos","events_url":"https://api.github.com/users/LudwigOrtmann/events{/privacy}","received_events_url":"https://api.github.com/users/LudwigOrtmann/received_events","type":"User","site_admin":false},"repo":{"id":8590137,"name":"RIOT","full_name":"LudwigOrtmann/RIOT","owner":{"login":"LudwigOrtmann","id":3739173,"avatar_url":"https://avatars.githubusercontent.com/u/3739173?v=3","gravatar_id":"","url":"https://api.github.com/users/LudwigOrtmann","html_url":"https://github.com/LudwigOrtmann","followers_url":"https://api.github.com/users/LudwigOrtmann/followers","following_url":"https://api.github.com/users/LudwigOrtmann/following{/other_user}","gists_url":"https://api.github.com/users/LudwigOrtmann/gists{/gist_id}","starred_url":"https://api.github.com/users/LudwigOrtmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LudwigOrtmann/subscriptions","organizations_url":"https://api.github.com/users/LudwigOrtmann/orgs","repos_url":"https://api.github.com/users/LudwigOrtmann/repos","events_url":"https://api.github.com/users/LudwigOrtmann/events{/privacy}","received_events_url":"https://api.github.com/users/LudwigOrtmann/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/LudwigOrtmann/RIOT","description":"RIOT - The rum OS for the IoT ","fork":true,"url":"https://api.github.com/repos/LudwigOrtmann/RIOT","forks_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/forks","keys_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/keys{/key_id}","collaborators_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/teams","hooks_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/hooks","issue_events_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/issues/events{/number}","events_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/events","assignees_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/assignees{/user}","branches_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/branches{/branch}","tags_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/tags","blobs_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/git/refs{/sha}","trees_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/git/trees{/sha}","statuses_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/statuses/{sha}","languages_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/languages","stargazers_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/stargazers","contributors_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/contributors","subscribers_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/subscribers","subscription_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/subscription","commits_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/commits{/sha}","git_commits_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/git/commits{/sha}","comments_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/comments{/number}","issue_comment_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/issues/comments/{number}","contents_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/contents/{+path}","compare_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/compare/{base}...{head}","merges_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/merges","archive_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/downloads","issues_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/issues{/number}","pulls_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/pulls{/number}","milestones_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/milestones{/number}","notifications_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/labels{/name}","releases_url":"https://api.github.com/repos/LudwigOrtmann/RIOT/releases{/id}","created_at":"2013-03-05T22:01:42Z","updated_at":"2014-12-16T10:35:42Z","pushed_at":"2014-12-16T14:33:18Z","git_url":"git://github.com/LudwigOrtmann/RIOT.git","ssh_url":"git@github.com:LudwigOrtmann/RIOT.git","clone_url":"https://github.com/LudwigOrtmann/RIOT.git","svn_url":"https://github.com/LudwigOrtmann/RIOT","homepage":"https://github.com/RIOT-OS/RIOT/wiki","size":20005,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"RIOT-OS:master","ref":"master","sha":"29c5822e02d9b8ed686bc3a5af1a902214199a39","user":{"login":"RIOT-OS","id":3079480,"avatar_url":"https://avatars.githubusercontent.com/u/3079480?v=3","gravatar_id":"","url":"https://api.github.com/users/RIOT-OS","html_url":"https://github.com/RIOT-OS","followers_url":"https://api.github.com/users/RIOT-OS/followers","following_url":"https://api.github.com/users/RIOT-OS/following{/other_user}","gists_url":"https://api.github.com/users/RIOT-OS/gists{/gist_id}","starred_url":"https://api.github.com/users/RIOT-OS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RIOT-OS/subscriptions","organizations_url":"https://api.github.com/users/RIOT-OS/orgs","repos_url":"https://api.github.com/users/RIOT-OS/repos","events_url":"https://api.github.com/users/RIOT-OS/events{/privacy}","received_events_url":"https://api.github.com/users/RIOT-OS/received_events","type":"Organization","site_admin":false},"repo":{"id":7370241,"name":"RIOT","full_name":"RIOT-OS/RIOT","owner":{"login":"RIOT-OS","id":3079480,"avatar_url":"https://avatars.githubusercontent.com/u/3079480?v=3","gravatar_id":"","url":"https://api.github.com/users/RIOT-OS","html_url":"https://github.com/RIOT-OS","followers_url":"https://api.github.com/users/RIOT-OS/followers","following_url":"https://api.github.com/users/RIOT-OS/following{/other_user}","gists_url":"https://api.github.com/users/RIOT-OS/gists{/gist_id}","starred_url":"https://api.github.com/users/RIOT-OS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RIOT-OS/subscriptions","organizations_url":"https://api.github.com/users/RIOT-OS/orgs","repos_url":"https://api.github.com/users/RIOT-OS/repos","events_url":"https://api.github.com/users/RIOT-OS/events{/privacy}","received_events_url":"https://api.github.com/users/RIOT-OS/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/RIOT-OS/RIOT","description":"RIOT -  The friendly OS for IoT","fork":false,"url":"https://api.github.com/repos/RIOT-OS/RIOT","forks_url":"https://api.github.com/repos/RIOT-OS/RIOT/forks","keys_url":"https://api.github.com/repos/RIOT-OS/RIOT/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RIOT-OS/RIOT/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RIOT-OS/RIOT/teams","hooks_url":"https://api.github.com/repos/RIOT-OS/RIOT/hooks","issue_events_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/events{/number}","events_url":"https://api.github.com/repos/RIOT-OS/RIOT/events","assignees_url":"https://api.github.com/repos/RIOT-OS/RIOT/assignees{/user}","branches_url":"https://api.github.com/repos/RIOT-OS/RIOT/branches{/branch}","tags_url":"https://api.github.com/repos/RIOT-OS/RIOT/tags","blobs_url":"https://api.github.com/repos/RIOT-OS/RIOT/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RIOT-OS/RIOT/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RIOT-OS/RIOT/git/refs{/sha}","trees_url":"https://api.github.com/repos/RIOT-OS/RIOT/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RIOT-OS/RIOT/statuses/{sha}","languages_url":"https://api.github.com/repos/RIOT-OS/RIOT/languages","stargazers_url":"https://api.github.com/repos/RIOT-OS/RIOT/stargazers","contributors_url":"https://api.github.com/repos/RIOT-OS/RIOT/contributors","subscribers_url":"https://api.github.com/repos/RIOT-OS/RIOT/subscribers","subscription_url":"https://api.github.com/repos/RIOT-OS/RIOT/subscription","commits_url":"https://api.github.com/repos/RIOT-OS/RIOT/commits{/sha}","git_commits_url":"https://api.github.com/repos/RIOT-OS/RIOT/git/commits{/sha}","comments_url":"https://api.github.com/repos/RIOT-OS/RIOT/comments{/number}","issue_comment_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/comments/{number}","contents_url":"https://api.github.com/repos/RIOT-OS/RIOT/contents/{+path}","compare_url":"https://api.github.com/repos/RIOT-OS/RIOT/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RIOT-OS/RIOT/merges","archive_url":"https://api.github.com/repos/RIOT-OS/RIOT/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RIOT-OS/RIOT/downloads","issues_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues{/number}","pulls_url":"https://api.github.com/repos/RIOT-OS/RIOT/pulls{/number}","milestones_url":"https://api.github.com/repos/RIOT-OS/RIOT/milestones{/number}","notifications_url":"https://api.github.com/repos/RIOT-OS/RIOT/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RIOT-OS/RIOT/labels{/name}","releases_url":"https://api.github.com/repos/RIOT-OS/RIOT/releases{/id}","created_at":"2012-12-29T20:38:40Z","updated_at":"2014-12-16T14:36:37Z","pushed_at":"2014-12-16T14:36:37Z","git_url":"git://github.com/RIOT-OS/RIOT.git","ssh_url":"git@github.com:RIOT-OS/RIOT.git","clone_url":"https://github.com/RIOT-OS/RIOT.git","svn_url":"https://github.com/RIOT-OS/RIOT","homepage":"https://github.com/RIOT-OS/RIOT/wiki","size":97294,"stargazers_count":210,"watchers_count":210,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":175,"mirror_url":null,"open_issues_count":249,"forks":175,"open_issues":249,"watchers":210,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/2061"},"html":{"href":"https://github.com/RIOT-OS/RIOT/pull/2061"},"issue":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/issues/2061"},"comments":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/issues/2061/comments"},"review_comments":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/2061/comments"},"review_comment":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/2061/commits"},"statuses":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/statuses/8a0a9250dd03088b6928fbcf4be54ae492c43aa9"}}}}