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)
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)
35 printf("New RT: '%s'\n", radio_text);
38 void test_rds_date_time_cb(struct tm *rds_time)
40 printf("RDS date/time: %s", asctime(rds_time));
43 void test_rds_sname_cb(char *sname)
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];
72 if (strncmp("-all", argv[i], 4) == 0)
74 if (strncmp("-di", argv[i], 3) == 0)
75 OutputFlags |= RDS_OUTPUT_RDSINFO;
76 if (strncmp("-rd", argv[i], 3) == 0)
78 strcpy(rdevname, argv[++i]);
79 if (strncmp("-rt", argv[i], 3) == 0)
80 OutputFlags |= RDS_OUTPUT_RADIO_TEXT;
81 if (strncmp("-ri", argv[i], 3) == 0)
82 OutputFlags |= RDS_OUTPUT_STATION_ID;
83 if (strncmp("-tmc", argv[i], 4) == 0)
84 OutputFlags |= RDS_OUTPUT_TMC;
85 if (strncmp("-eon", argv[i], 4) == 0)
86 OutputFlags |= RDS_OUTPUT_EON;
87 if (strncmp("-dt", argv[i], 3) == 0)
88 OutputFlags |= RDS_OUTPUT_DATETIME;
89 if (strncmp("-ug", argv[i], 3) == 0)
90 OutputFlags |= RDS_OUTPUT_UNKNGRP;
91 if (strncmp("-pi", argv[i], 3) == 0)
92 OutputFlags |= RDS_RECEIVE_INDICATOR;
95 if (!(rds_fd = open_radio(rdevname))) {
96 perror("open radio:");
99 if (sqlite3_open("lcl.db", &lcl_db) != SQLITE_OK) {
100 perror("open radio:");
108 //rds_set_PI_cb(test_rds_PI_cb);
109 //rds_set_radiotext_cb(test_rds_radiotext_cb);
110 //rds_set_date_time_cb(test_rds_date_time_cb);
111 //rds_set_sname_cb(test_rds_sname_cb);
113 tmc_set_msg_cb(test_tmc_msg_cb, NULL);
116 if (rds_receive_group(rds_fd, rdsgroup)) {
117 // group complete, start decode
118 rds_decode_group(rdsgroup);