diff options
author | Thierry Bultel <thierry.bultel@iot.bzh> | 2018-07-11 17:40:07 +0200 |
---|---|---|
committer | Thierry Bultel <thierry.bultel@iot.bzh> | 2018-07-17 10:50:07 +0200 |
commit | 7db8c3df0b4abdb0bb643ca3220b3bfbc9a4db83 (patch) | |
tree | d04fcff3d5519779218b4c4ab49a1870f829cfeb /binding/radio_impl_kingfisher.c | |
parent | b3303810b1edbe0a9bc7c066fb6c4ea96cb65c12 (diff) |
added api verb for RDS information
Added a verb to retrieve the RDS information.
Notice that it is only supported on the kingfisher
implementation.
Change-Id: I0e2a830ff77154eb8cbb780bb599fb49f71a5b1c
Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
Diffstat (limited to 'binding/radio_impl_kingfisher.c')
-rw-r--r-- | binding/radio_impl_kingfisher.c | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/binding/radio_impl_kingfisher.c b/binding/radio_impl_kingfisher.c index d88176d..e183c1b 100644 --- a/binding/radio_impl_kingfisher.c +++ b/binding/radio_impl_kingfisher.c @@ -250,6 +250,43 @@ static void kf_set_frequency_callback(radio_freq_callback_t callback, freq_callback_data = data; } +static char * kf_get_rds_info(void) { + char cmd[SI_CTL_CMDLINE_MAXLEN]; + char line[SI_CTL_OUTPUT_MAXLEN]; + char * rds = NULL; + FILE *fp; + + if (scanning) + goto done; + + snprintf(cmd, SI_CTL_CMDLINE_MAXLEN, "%s /dev/i2c-12 0x65 -m", SI_CTL); + fp = popen(cmd, "r"); + if(fp == NULL) { + fprintf(stderr, "Could not run: %s!\n", cmd); + goto done; + } + // Look for "Name:" in output + while (fgets(line, SI_CTL_OUTPUT_MAXLEN, fp) != NULL) { + + char* nS = strstr(line, "Name:"); + char * end; + if (!nS) + continue; + + end = nS+strlen("Name:"); + /* remove the trailing \n */ + end[strlen(end)-1] = '\0'; + + rds = strdup(end); + break; + } + + // Make sure si_ctl has finished + pclose(fp); +done: + return rds; +} + static radio_band_t kf_get_band(void) { return BAND_FM; @@ -417,5 +454,6 @@ radio_impl_ops_t kf_impl_ops = { .scan_start = kf_scan_start, .scan_stop = kf_scan_stop, .get_stereo_mode = kf_get_stereo_mode, - .set_stereo_mode = kf_set_stereo_mode + .set_stereo_mode = kf_set_stereo_mode, + .get_rds_info = kf_get_rds_info }; |