ProtoCore
v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
iccp.h
Go to the documentation of this file.
1
// ProtoCore v1.0.16 - Copyright (C) 2026 Douglas Quigg (dstroy0) <dquigg123@gmail.com>
2
// SPDX-License-Identifier: AGPL-3.0-or-later
3
4
/**
5
* @file iccp.h
6
* @brief ICCP / TASE.2 (IEC 60870-6) inter-control-center telemetry codec (PROTOCORE_ENABLE_ICCP).
7
*
8
* ICCP (TASE.2, IEC 60870-6) exchanges real-time power-grid telemetry between control centers. It is an
9
* application profile *on top of MMS* (the shipped services/energy/mms): a TASE.2 "indication point" (a data
10
* value with quality + timestamp) is transferred as an MMS Read on a named object. This codec builds the
11
* TASE.2 data value - the standard `Data_Value` structure a Read carries:
12
*
13
* Data_Value ::= SEQUENCE { value CHOICE {state/discrete/real/...}, flags DataFlags, timestamp }
14
*
15
* simplified here to the common **StateQ** (a discrete state 0..3 + a quality-flags byte) and **RealQ**
16
* (an IEEE-754-ish scaled real + quality) indication points that most bilateral tables use. The result
17
* is a BER blob the caller wraps in an MMS Read response (`protocore_mms_read_response`). Pure, zero heap,
18
* no stdlib, host-testable; the TASE.2 bilateral-table + MMS transport are the shipped services.
19
*/
20
21
#ifndef PROTOCORE_ICCP_H
22
#define PROTOCORE_ICCP_H
23
24
#include "
protocore_config.h
"
// the entry point: protocore_types.h for the widths
25
26
#if PROTOCORE_ENABLE_ICCP
27
28
EMBED_BEGIN_DECLS
29
30
/** @brief TASE.2 quality flags (DataFlags, the common bits). */
31
// TASE.2 quality/state wire values + the 2-bit quality mask, so integer constants in a struct.
32
#define ICCP_QUAL_VALID 0x00
///< value is valid.
33
#define ICCP_QUAL_HELD 0x01
///< value is held (frozen).
34
#define ICCP_QUAL_SUSPECT 0x02
///< value is suspect.
35
#define ICCP_QUAL_NOTVALID 0x03
///< value is not valid.
36
#define ICCP_QUAL_MASK 0x03
37
#define ICCP_STATE_BETWEEN 0x00
///< StateQ: intermediate.
38
#define ICCP_STATE_OFF 0x01
39
#define ICCP_STATE_ON 0x02
40
#define ICCP_STATE_INVALID 0x03
41
42
/**
43
* @brief Build a TASE.2 StateQ Data_Value: a discrete state + quality flags.
44
* @param state the 2-bit state (ICCP_STATE_*).
45
* @param flags the quality flags byte (ICCP_QUAL_*).
46
* @param time the 4-octet TimeStamp (seconds since 1970; big-endian), or null for no timestamp.
47
* @return the BER length written, or 0 on overflow.
48
*
49
* Encodes `[A2 { 85 <stateAndQuality byte> [17 <4-octet time>] }]` (context-tagged StateQ structure).
50
*/
51
size_t
protocore_iccp_state_q(uint8_t state, uint8_t flags,
const
uint8_t time[4], uint8_t *out,
size_t
cap);
52
53
/**
54
* @brief Build a TASE.2 RealQ Data_Value: a scaled real value (milli-units) + quality flags.
55
* @param milli the value in 1/1000 units (so 12.345 -> 12345), a signed 32-bit integer.
56
* @param flags the quality flags byte.
57
* @param time the 4-octet TimeStamp, or null.
58
* @return the BER length written, or 0 on overflow.
59
*
60
* Encodes `[A3 { 02 <INTEGER milli> 85 <quality byte> [17 <time>] }]`.
61
*/
62
size_t
protocore_iccp_real_q(int32_t milli, uint8_t flags,
const
uint8_t time[4], uint8_t *out,
size_t
cap);
63
64
EMBED_END_DECLS
65
66
#endif
// PROTOCORE_ENABLE_ICCP
67
68
#endif
// PROTOCORE_ICCP_H
protocore_config.h
src
services
energy
iccp
iccp.h
Generated by
1.15.0