Adding core TMC decoding support to RDS library
A message that is not in the archive (sent off-list or not yet received): [RFC PATCH 0/1] Adding core TMC decoding support to RDS library
v2 cover Adding core TMC decoding support to RDS library
this patch is an updated version of the last RDS-TMC core support patch.
The changes proposed by Hans Verkuil were implemented. In addition the handling and decoding of multi-group TMC messages was heavily modified, in order to improve read- and maintainability
Regards,
Konke
RFC PATCH v2 1/1 Add core TMC (Traffic Message Channel) support
--- lib/include/libv4l2rds.h | 65 +++++++++ lib/libv4l2rds/libv4l2rds.c | 309 ++++++++++++++++++++++++++++++++++++++++++- utils/rds-ctl/rds-ctl.cpp | 31 ++++- 3 files changed, 402 insertions(+), 3 deletions(-)
lib/include/libv4l2rds.h +65 -0
@@ -46,6 +46,10 @@ extern "C" {* AF Method B does not impose a limit on the number of AFs * but it is not fully supported at the moment and will * not receive more than 25 AFs */ +#define MAX_TMC_ADDITIONAL 28/* 28 is the maximal possible number of fields. +* Additional data is limited to 112 bit, and the smallest +* optional tuple has a size of 4 bit (4 bit identifier + +* 0 bits of data) */ /* Define Constants for the possible types of RDS information * used to address the relevant bit in the valid_fields bitmask */
@@ -63,6 +67,9 @@ extern "C" {#define V4L2_RDS_AF 0x800/* AF (alternative freq) available */ #define V4L2_RDS_ECC 0x1000/* Extended County Code */ #define V4L2_RDS_LC 0x2000/* Language Code */ +#define V4L2_RDS_TMC_SG 0x4000/* RDS-TMC single group */ +#define V4L2_RDS_TMC_MG 0x8000/* RDS-TMC multi group */ +#define V4L2_RDS_TMC_SYS 0x10000/* RDS-TMC system information */ /* Define Constants for the state of the RDS decoding process * used to address the relevant bit in the decode_information bitmask */
@@ -76,6 +83,11 @@ extern "C" {#define V4L2_RDS_FLAG_COMPRESSED 0x04#define V4L2_RDS_FLAG_STATIC_PTY 0x08 +/* TMC related codes +* used to extract TMC fields from RDS groups */ +#define V4L2_TMC_TUNING_INFO 0x08 +#define V4L2_TMC_SINGLE_GROUP 0x04 +/* struct to encapsulate one complete RDS group */ /* This structure is used internally to store data until a complete RDS * group was received and group id dependent decoding can be done.
@@ -137,6 +149,58 @@ struct v4l2_rds_af_set {uint32_t af[MAX_AF_CNT ];/* AFs defined in Hz */ }; +/* struct to encapsulate an additional data field in a TMC message */ +struct v4l2_tmc_additional { +uint8_t label; +uint16_t data; +}; + +/* struct to encapsulate an arbitrary number of additional data fields +* belonging to one TMC message */ +struct v4l2_tmc_additional_set { +uint8_t size; +struct v4l2_tmc_additional fields[MAX_TMC_ADDITIONAL ]; +}; + +/* struct to encapsulate a decoded TMC message with optional additional +* data field (in case of a multi-group TMC message) */ +struct v4l2_rds_tmc_msg { +uint8_t length;/* length of multi-group message (0..4) */ +uint8_t sid;/* service identifier at time of reception */ +uint8_t extent; +uint8_t dp;/* duration and persistence */ +uint16_t event;/* TMC event code */ +uint16_t location;/* TMC event location */ +bool follow_diversion;/* indicates if the driver is adviced to +* follow the diversion */ +bool neg_direction;/* indicates negative / positive direction */ + +/* decoded additional information (only available in multi-group +* messages) */ +struct v4l2_tmc_additional_set additional; +}; + +/* struct to encapsulate all TMC related information, including TMC System +* Information, TMC Tuning information and a buffer for the last decoded +* TMC messages */ +struct v4l2_rds_tmc { +uint8_t ltn;/* location_table_number */ +bool afi;/* alternative frequency indicator */ +bool enhanced_mode;/* mode of transmission, +* if false -> basic => gaps between tmc groups +* gap defines timing behavior +* if true -> enhanced => t_a, t_w and t_d +* define timing behavior of tmc groups */ +uint8_t mgs;/* message geographical scope */ +uint8_t sid;/* service identifier (unique ID on national level) */ +uint8_t gap;/* Gap parameters */ +uint8_t t_a;/* activity time (only if mode = enhanced) */ +uint8_t t_w;/* window time (only if mode = enhanced */ +uint8_t t_d;/* delay time (only if mode = enhanced */ +uint8_t spn[9 ];/* service provider name */ +struct v4l2_rds_tmc_msg tmc_msg; +}; +/* struct to encapsulate state and RDS information for current decoding process */ /* This is the structure that will be used by external applications, to * communicate with the library and get access to RDS data */
@@ -172,6 +236,7 @@ struct v4l2_rds {struct v4l2_rds_statistics rds_statistics;struct v4l2_rds_oda_set rds_oda;/* Open Data Services */ struct v4l2_rds_af_set rds_af;/* Alternative Frequencies */ +struct v4l2_rds_tmc tmc;/* TMC information */ };/* v4l2_rds_init() - initializes a new decoding process
lib/libv4l2rds/libv4l2rds.c +307 -2
345 lines not on this page · raw message
utils/rds-ctl/rds-ctl.cpp +30 -1
@@ -76,6 +76,7 @@ enum Option { OptOpenFile, OptPrintBlock, OptSilent, + OptTMC, OptTunerIndex, OptVerbose, OptWaitLimit,
@@ -110,6 +111,7 @@ static struct option long_options[] = { {"print-block", no_argument, 0, OptPrintBlock}, {"read-rds", no_argument, 0, OptReadRds}, {"set-freq", required_argument, 0, OptSetFreq}, + {"tmc", no_argument, 0, OptTMC}, {"tuner-index", required_argument, 0, OptTunerIndex}, {"verbose", no_argument, 0, OptVerbose}, {"wait-limit", required_argument, 0, OptWaitLimit},
@@ -170,6 +172,8 @@ static void usage_rds(void) " --print-block\n" " prints all valid RDS fields, whenever a value is updated\n" " instead of printing only updated values\n" + " --tmc\n" + " enables decoding of TMC (Traffic Message Channel) data\n" " --verbose\n" " turn on verbose mode - every received RDS group\n" " will be printed\n"
@@ -491,7 +495,30 @@ static void print_decoder_info(uint8_t di) printf("Not Compressed"); } -static void print_rds_statistics(struct v4l2_rds_statistics *statistics) +static void print_rds_tmc(const struct v4l2_rds *handle, uint32_t updated_fields) +{ + const struct v4l2_rds_tmc_msg *msg = &handle->tmc.tmc_msg; + const struct v4l2_tmc_additional_set *set = &msg->additional; + + if (updated_fields & V4L2_RDS_TMC_SG) { + printf("\nTMC Single-grp: location: %04x, event: %04x, extent: %02x " + "duration: %02x", msg->location, msg->event, + msg->extent, msg->dp); + return; + } + if (updated_fields & V4L2_RDS_TMC_MG) { + printf("\nTMC Multi-grp: length: %02d, location: %04x, event: %04x,\n" + " extent: %02x duration: %02x", msg->length, msg->location, msg->event, + msg->extent, msg->dp); + for (int i = 0; i < set->size; i++) { + printf("\n additional[%02d]: label: %02d, value: %04x", + i, set->fields[i].label, set->fields[i].data); + } + return; + } +} + +static void print_rds_statistics(const struct v4l2_rds_statistics *statistics) { printf("\n\nRDS Statistics: \n"); printf("received blocks / received groups: %u / %u\n",
@@ -583,6 +610,8 @@ static void print_rds_data(const struct v4l2_rds *handle, uint32_t updated_field print_rds_af(&handle->rds_af); if (params.options[OptPrintBlock]) printf("\n"); + if (params.options[OptTMC]) + print_rds_tmc(handle, updated_fields); } static void read_rds(struct v4l2_rds *handle, const int fd, const int wait_limit)
Signature · 1 line
1.7.10.4
Quoted 5 lines · On Wed August 15 2012 16:30:57 Konke Radlow wrote:
this patch is an updated version of the last RDS-TMC core support patch.
The changes proposed by Hans Verkuil were implemented. In addition the handling and decoding of multi-group TMC messages was heavily modified, in order to improve read- and maintainability
If there are no further comments, then I plan on merging this tomorrow.
Regards,
Hans