{"action":"created","issue":{"url":"https://api.github.com/repos/merbanan/rtl_433/issues/748","repository_url":"https://api.github.com/repos/merbanan/rtl_433","labels_url":"https://api.github.com/repos/merbanan/rtl_433/issues/748/labels{/name}","comments_url":"https://api.github.com/repos/merbanan/rtl_433/issues/748/comments","events_url":"https://api.github.com/repos/merbanan/rtl_433/issues/748/events","html_url":"https://github.com/merbanan/rtl_433/issues/748","id":330984083,"node_id":"MDU6SXNzdWUzMzA5ODQwODM=","number":748,"title":"Using rtl_433 with stdin ","user":{"login":"jlmcgraw","id":3441886,"node_id":"MDQ6VXNlcjM0NDE4ODY=","avatar_url":"https://avatars0.githubusercontent.com/u/3441886?v=4","gravatar_id":"","url":"https://api.github.com/users/jlmcgraw","html_url":"https://github.com/jlmcgraw","followers_url":"https://api.github.com/users/jlmcgraw/followers","following_url":"https://api.github.com/users/jlmcgraw/following{/other_user}","gists_url":"https://api.github.com/users/jlmcgraw/gists{/gist_id}","starred_url":"https://api.github.com/users/jlmcgraw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jlmcgraw/subscriptions","organizations_url":"https://api.github.com/users/jlmcgraw/orgs","repos_url":"https://api.github.com/users/jlmcgraw/repos","events_url":"https://api.github.com/users/jlmcgraw/events{/privacy}","received_events_url":"https://api.github.com/users/jlmcgraw/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2018-06-10T16:49:26Z","updated_at":"2018-12-06T09:22:16Z","closed_at":null,"author_association":"NONE","body":"I've got a setup where I'm using process redirection to pipe rtl_tcp stdout to an input file for rtl_433\r\n( see [rtl_client.sh](https://github.com/jlmcgraw/rtl_sdr_reader/blob/master/rtl_client.sh) and [both_readers.sh](https://github.com/jlmcgraw/rtl_sdr_reader/blob/master/both_readers.sh) for more detail on how I'm doing this ).  \r\n\r\nThis allows me to start rtl_tcp once and use it with multiple programs in rotation, each of which runs for a limited amount of time.\r\n\r\nIn order to support this I had to make some minor modifications to util.c and rtl_433.c\r\nWithout the patches, timestamps are in relative seconds ( which is reasonable because reading from a file is typically used for testing ) and durations don't work.\r\n\r\nThese patches work for my purposes but I'm not sure they're the best general approach, perhaps there is a better way to do this?\r\n\r\nEither way, here are my patches in the hope that they may be useful to others\r\n\r\n> Patch rtl_433.c to honor duration timer settings when reading from a file\r\n  \r\n    @@ -1165,6 +1165,9 @@ int main(int argc, char **argv) {\r\n                     duration = atoi_time(optarg, \"-T: \");\r\n                     if (duration < 1) {\r\n                         fprintf(stderr, \"Duration '%s' not a positive number; will continue indefinitely\\n\", optarg);\r\n    +                } else {\r\n    +                    time(&stop_time);\r\n    +                    stop_time += duration;\r\n                     }\r\n                     break;\r\n                 case 'y':\r\n\r\n    @@ -1389,7 +1392,7 @@ int main(int argc, char **argv) {\r\n                 rtlsdr_callback(test_mode_buf, n_read, demod);\r\n                 i++;\r\n                 sample_file_pos = (float)i * n_read / samp_rate / 2;\r\n    -        } while (n_read != 0);\r\n    +        } while (n_read != 0 && !do_exit);\r\n     \r\n             // Call a last time with cleared samples to ensure EOP detection\r\n             memset(test_mode_buf, 128, DEFAULT_BUF_LENGTH);  // 128 is 0 in unsigned data\r\n\r\n> Patch util.c to make it report sample times as timestamps when reading from\r\n> a file and also make it report local times formatted per ISO 8601\r\n\r\n    @@ -139,10 +139,12 @@ char* local_time_str(time_t time_secs, char *buf)\r\n     \r\n         if (time_secs == 0) {\r\n             extern float sample_file_pos;\r\n    -        if (sample_file_pos != -1.0) {\r\n    -            snprintf(buf, LOCAL_TIME_BUFLEN, \"@%fs\", sample_file_pos);\r\n    -            return buf;\r\n    -        }\r\n             time(&etime);\r\n         } else {\r\n             etime = time_secs;\r\n\r\n    @@ -150,7 +152,8 @@ char* local_time_str(time_t time_secs, char *buf)\r\n     \r\n         tm_info = localtime(&etime); // note: win32 doesn't have localtime_r()\r\n     \r\n    -    strftime(buf, LOCAL_TIME_BUFLEN, \"%Y-%m-%d %H:%M:%S\", tm_info);\r\n    +    // Output local times as ISO 8601\r\n    +    strftime(buf, LOCAL_TIME_BUFLEN, \"%FT%T%z\", tm_info);\r\n         return buf;\r\n     }"},"comment":{"url":"https://api.github.com/repos/merbanan/rtl_433/issues/comments/444804893","html_url":"https://github.com/merbanan/rtl_433/issues/748#issuecomment-444804893","issue_url":"https://api.github.com/repos/merbanan/rtl_433/issues/748","id":444804893,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NDgwNDg5Mw==","user":{"login":"zuckschwerdt","id":12833,"node_id":"MDQ6VXNlcjEyODMz","avatar_url":"https://avatars1.githubusercontent.com/u/12833?v=4","gravatar_id":"","url":"https://api.github.com/users/zuckschwerdt","html_url":"https://github.com/zuckschwerdt","followers_url":"https://api.github.com/users/zuckschwerdt/followers","following_url":"https://api.github.com/users/zuckschwerdt/following{/other_user}","gists_url":"https://api.github.com/users/zuckschwerdt/gists{/gist_id}","starred_url":"https://api.github.com/users/zuckschwerdt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zuckschwerdt/subscriptions","organizations_url":"https://api.github.com/users/zuckschwerdt/orgs","repos_url":"https://api.github.com/users/zuckschwerdt/repos","events_url":"https://api.github.com/users/zuckschwerdt/events{/privacy}","received_events_url":"https://api.github.com/users/zuckschwerdt/received_events","type":"User","site_admin":false},"created_at":"2018-12-06T09:22:16Z","updated_at":"2018-12-06T09:22:16Z","author_association":"COLLABORATOR","body":"I guess adding the time and event limit options to stdin (and read-file) inputs can't hurt much.\r\n\r\nAlso I'll add the time output selection to `-M`. You'll be able to select absolut time output with `-M time` (preset on live inputs), relativ time with `-M reltime` (preset on files and stdin), change to UTC with `-M utc` and extend the output to microseconds with `-M hires`. All options can be combined or individually deselected with e.g. `-M notime`…"}}
{"actor":{"display_login":"zuckschwerdt"}}