diff options
author | dbiastoch <dbiastoch@de.adit-jv.com> | 2021-01-13 11:27:17 +0100 |
---|---|---|
committer | Saya Sugiura <39760799+ssugiura@users.noreply.github.com> | 2021-06-30 10:54:59 +0900 |
commit | 442688504260bb2bfcfb08a9865f223d2ab2d19a (patch) | |
tree | deb6e007dfd727d0ec91430cac8ec9cd27e03b7e /include/dlt | |
parent | f5a22d09b620be0c911815145f0e6486f061aecd (diff) | |
download | DLT-daemon-442688504260bb2bfcfb08a9865f223d2ab2d19a.tar.gz |
dlt-receive: Enabled more filtering by using json filter files
-Added '-j' flag to dlt-receive for reading a json filter file
-Added more attributes to DltFilter (LogLevel, MaxPayload, MinPayload) for extended message filtering, when using old filters these values are set to default. Same behaviour, when they are not defined in json filter file.
-extended dlt_common.c to support json filter files and new DltFilter attributes
+add dlt_json_filter_load to parse a json filter file into a DltFilter
+add dlt_json_filter_save to print a DltFilter into a json file
-Two new libraries are used to parse the json filter files: json-c for Linux based systems and the QNX internal libjson for QNX systems
-gtest_dlt_common was modified to test the new function 'dlt_json_filter_load'
+add testfile_extended.dlt that contains a bigger varity of messages (different context/app IDs, lengths and log levels)
+add testfilter.json which is a valid json filter file
-New dependency on library was added to related CMakeLists and is described in README.md
Signed-off-by: dbiastoch <dbiastoch@de.adit-jv.com>
Diffstat (limited to 'include/dlt')
-rw-r--r-- | include/dlt/dlt_common.h | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/include/dlt/dlt_common.h b/include/dlt/dlt_common.h index 7973ab1..89f9c96 100644 --- a/include/dlt/dlt_common.h +++ b/include/dlt/dlt_common.h @@ -297,6 +297,7 @@ enum { # define DLT_OUTPUT_ASCII_LIMITED 5 # define DLT_FILTER_MAX 30 /**< Maximum number of filters */ +# define JSON_FILTER_NAME_SIZE 16 /* Size of buffer for the filter names in json filter files */ # define DLT_MSG_READ_VALUE(dst, src, length, type) \ { \ @@ -736,6 +737,9 @@ typedef struct { char apid[DLT_FILTER_MAX][DLT_ID_SIZE]; /**< application id */ char ctid[DLT_FILTER_MAX][DLT_ID_SIZE]; /**< context id */ + int log_level[DLT_FILTER_MAX]; /**< log level */ + int32_t payload_max[DLT_FILTER_MAX]; /**< upper border for payload */ + int32_t payload_min[DLT_FILTER_MAX]; /**< lower border for payload */ int counter; /**< number of filters */ } DltFilter; @@ -926,40 +930,68 @@ DltReturnValue dlt_filter_free(DltFilter *filter, int verbose); */ DltReturnValue dlt_filter_load(DltFilter *filter, const char *filename, int verbose); /** - * Save filter list to file. + * Load json filter from file. * @param filter pointer to structure of organising DLT filter * @param filename filename to load filters from * @param verbose if set to true verbose information is printed out. * @return negative value if there was an error */ +DltReturnValue dlt_json_filter_load(DltFilter *filter, const char *filename, int verbose); +/** + * Save filter in space separated list to text file. + * @param filter pointer to structure of organising DLT filter + * @param filename filename to safe filters into + * @param verbose if set to true verbose information is printed out. + * @return negative value if there was an error + */ DltReturnValue dlt_filter_save(DltFilter *filter, const char *filename, int verbose); /** + * Save filter in json format to file. + * @param filter pointer to structure of organising DLT filter + * @param filename filename to safe filters into + * @param verbose if set to true verbose information is printed out. + * @return negative value if there was an error + */ +DltReturnValue dlt_json_filter_save(DltFilter *filter, const char *filename, int verbose); +/** * Find index of filter in filter list * @param filter pointer to structure of organising DLT filter * @param apid application id to be found in filter list * @param ctid context id to be found in filter list + * @param log_level log level to be found in filter list + * @param payload_min minimum payload lenght to be found in filter list + * @param payload_max maximum payload lenght to be found in filter list * @param verbose if set to true verbose information is printed out. * @return negative value if there was an error (or not found), else return index of filter */ -int dlt_filter_find(DltFilter *filter, const char *apid, const char *ctid, int verbose); +int dlt_filter_find(DltFilter *filter, const char *apid, const char *ctid, const int log_level, + const int32_t payload_min, const int32_t payload_max, int verbose); /** * Add new filter to filter list. * @param filter pointer to structure of organising DLT filter * @param apid application id to be added to filter list (must always be set). * @param ctid context id to be added to filter list. empty equals don't care. + * @param log_level log level to be added to filter list. 0 equals don't care. + * @param payload_min min lenght of payload to be added to filter list. 0 equals don't care. + * @param payload_max max lenght of payload to be added to filter list. INT32_MAX equals don't care. * @param verbose if set to true verbose information is printed out. * @return negative value if there was an error */ -DltReturnValue dlt_filter_add(DltFilter *filter, const char *apid, const char *ctid, int verbose); +DltReturnValue dlt_filter_add(DltFilter *filter, const char *apid, const char *ctid, const int log_level, + const int32_t payload_min, const int32_t payload_max, int verbose); /** * Delete filter from filter list * @param filter pointer to structure of organising DLT filter * @param apid application id to be deleted from filter list * @param ctid context id to be deleted from filter list + * @param log_level log level to be deleted from filter list + * @param payload_min minimum payload lenght to be deleted from filter list + * @param payload_max maximum payload lenght to be deleted from filter list * @param verbose if set to true verbose information is printed out. * @return negative value if there was an error */ -DltReturnValue dlt_filter_delete(DltFilter *filter, const char *apid, const char *ctid, int verbose); +DltReturnValue dlt_filter_delete(DltFilter *filter, const char *apid, const char *ctid, const int log_level, + const int32_t payload_min, const int32_t payload_max, int verbose); /** * Initialise the structure used to access a DLT message. |