From: Thibaut VARÈNE Date: Tue, 5 Jul 2022 15:23:04 +0000 (+0200) Subject: Document ISO 8601 horodates X-Git-Tag: v2.4~6 X-Git-Url: http://vcs.slashdirt.org/git/?a=commitdiff_plain;h=8b064a7ffe8024af3be10c477182f882df8c32ca;p=sw%2Ftic2json.git Document ISO 8601 horodates --- diff --git a/README.md b/README.md index 716a577..9d89949 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,6 @@ Alternatively, using dictionnary output and JSON_v2 parser for TIC "standard" pr measurement_name = "ticv2" timestamp_path = "DATE.horodate" timestamp_format = "rfc3339" - timestamp_timezone = "Local" [[inputs.socket_listener.json_v2.object]] path = "@this" included_keys = [ "PRM_data", "EAST_data", "IRMS1_data", "URMS1_data", "SINSTS_data", "SMAXSN_data", "UMOY1_data" ] @@ -113,6 +112,22 @@ Will only log `EAST`, `IRMS1`, `URMS1`, `SINSTS`, `SMAXSN` and `UMOY1`, tagged w Note: 'socket_listener' expects _exactly_ 1 JSON object per UDP packet (decoding of data is done on a per-packet basis), hence the need to send each line individually with `nc`. Another alternative is to use the script provided in `tools/ticprocess.py`. +#### PME-PMI specifics + +The PME-PMI meter uses a variant of TIC 01 that does not provide enough date/time information to infer the current DST and adjust the UTC offset in the converted (-r) date output. + +In that case, the converted horodate will ommit this offset in the output. The resulting string is still valid ISO 8601 but no longer valid RFC3339. + +The following configuration can be used with telegraf's JSON_v2 parser to correctly handle this: + +```toml + timestamp_path = "DATE.horodate" + timestamp_format = "2006-01-02T15:04:05" + timestamp_timezone = "Local" +``` + +The timestamps will be logged following the telegraf server timezone which is assumed to be the same as that of the meter (adjust as necessary). + ## Embedded applications The following embedded applications are based on this tool diff --git a/src/tic2json.c b/src/tic2json.c index d46956b..3cb49ec 100644 --- a/src/tic2json.c +++ b/src/tic2json.c @@ -252,7 +252,7 @@ void print_field(const struct tic_field *field) switch (d[0]) { default: case ' ': - o = ""; + o = ""; // this is not RFC3339-compliant but still valid ISO8601. Does not happen for "DATE" which is normally the timestamp. break; case 'E': case 'e': @@ -272,7 +272,7 @@ void print_field(const struct tic_field *field) #endif /* TICV02 */ case V01PME: #ifdef TICV01pme - // ticv01pme horodate: JJ/MM/AA HH:MM:SS + // ticv01pme horodate: JJ/MM/AA HH:MM:SS - output is valid ISO8601; cannot be RFC339 due to lack of DST info ticprintf(", \"horodate\": \"20%.2s-%.2s-%.2sT%.2s:%.2s:%.2s\"", d+6, d+3, d, d+9, d+12, d+15); break; #endif /* TICV01pme */ @@ -353,7 +353,7 @@ static void usage(void) " -i id\t\t" "Ajoute une balise \"id\" avec la valeur à chaque groupe\n" " -l\t\t" "Ajoute les descriptions longues et les unitées de chaque groupe\n" " -n\t\t" "Insà ̈re une nouvelle ligne aprà ̈s chaque groupe\n" - " -r\t\t" "Interprà ̈te les horodates en format RFC3339\n" + " -r\t\t" "Interprà ̈te les horodates en format RFC3339 (TIC v02) ou ISO8601\n" " -s N\t\t" "Émet une trame toutes les reçues\n" " -u\t\t" "Décode le registre de statut sous forme de dictionnaire (TIC v02)\n" " -V\t\t" "Montre la version et quitte\n"

AltStyle によって変換されたページ (->オリジナル) /