2 * Copyright (C) 2009, 2010 by Nils Faerber <nils.faerber@kernelconcepts.de>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
28 void test_rds_PI_cb(unsigned short PI, unsigned char ccode, unsigned char ptype, unsigned char pref, void *udata)
30 printf("New PI=%d ccode=%X ptype=%X '%s' '%s' pref=%d\n", PI, ccode, ptype, ptype_stext[ptype], ptype_ltext[ptype], pref);
33 void test_rds_radiotext_cb(char *radio_text, void *udata)
35 printf("New RT: '%s'\n", radio_text);
38 void test_rds_date_time_cb(struct tm *rds_time, void *udata)
40 printf("RDS date/time: %s", asctime(rds_time));
43 void test_rds_sname_cb(char *sname, void *udata)
45 printf("RDS sname='%s'\n", sname);
48 void test_tmc_msg_cb(char *msg, void *user_data)
50 printf("\nTMC msg:\n%s", msg);
53 int open_radio(const char *name)
57 fd = open(name, O_RDONLY);
64 int main(int argc, char **argv)
66 char rdevname[PATH_MAX] = "/dev/radio0";
67 unsigned short rdsgroup[4];
75 if (strncmp("-all", argv[i], 4) == 0)
77 if (strncmp("-di", argv[i], 3) == 0)
78 OutputFlags |= RDS_OUTPUT_RDSINFO;
79 if (strncmp("-rd", argv[i], 3) == 0)
81 strcpy(rdevname, argv[++i]);
82 if (strncmp("-rt", argv[i], 3) == 0) {
83 // OutputFlags |= RDS_OUTPUT_RADIO_TEXT;
84 rds_set_radiotext_cb(test_rds_radiotext_cb, NULL);
86 if (strncmp("-ri", argv[i], 3) == 0) {
87 // OutputFlags |= RDS_OUTPUT_STATION_ID;
88 rds_set_sname_cb(test_rds_sname_cb, NULL);
90 if (strncmp("-tmc", argv[i], 4) == 0) {
91 // OutputFlags |= RDS_OUTPUT_TMC;
92 tmc_set_msg_cb(test_tmc_msg_cb, NULL);
94 if (strncmp("-eon", argv[i], 4) == 0)
95 OutputFlags |= RDS_OUTPUT_EON;
96 if (strncmp("-dt", argv[i], 3) == 0) {
97 // OutputFlags |= RDS_OUTPUT_DATETIME;
98 rds_set_date_time_cb(test_rds_date_time_cb, NULL);
100 if (strncmp("-ug", argv[i], 3) == 0)
101 OutputFlags |= RDS_OUTPUT_UNKNGRP;
102 if (strncmp("-pi", argv[i], 3) == 0) {
103 // OutputFlags |= RDS_RECEIVE_INDICATOR;
104 rds_set_PI_cb(test_rds_PI_cb, NULL);
109 if (!(rds_fd = open_radio(rdevname))) {
110 perror("open radio:");
114 if (sqlite3_open("lcl.db", &lcl_db) != SQLITE_OK) {
115 perror("open LCL database:");
121 if (rds_receive_group(rds_fd, rdsgroup)) {
122 /* group complete, start decode */
123 rds_decode_group(rdsgroup);