Skip to content

Commit d521e19

Browse files
committed
add egd example dump
1 parent 7236d87 commit d521e19

File tree

2 files changed

+107
-4
lines changed

2 files changed

+107
-4
lines changed

tests/expected/raw_egd_example.h

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#pragma once
2+
3+
#include <cstdint>
4+
#include <map>
5+
#include <string>
6+
7+
namespace dlms::test_data {
8+
9+
// Changes from Original File : ega_2025_komunikacni_rozhrani_rs485.pdf
10+
11+
// Changed this:
12+
// 0x02, 0x02, 0x16, 0x01, 0x01, 0x16, // structure(2) = {enum = 1, array = 22}
13+
//
14+
// To this (suspect OCR mistake) :
15+
// 0x02, 0x02, 0x16, 0x01, 0x01, 0x1B, // structure(2) = {enum = 1, array = 27}
16+
17+
// Changed this:
18+
// 0x02, 0x02, 0x00, 0x01, 0x00, 0x00, 0x2A, 0x00, 0x00, 0xFF, 0x02, 0x09, 0x10, 0x45, 0x47, 0x44, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, // structure(2) = {(0,1,0,0,42,0,0,255,2), octet-string(16) = "EGD012345"}
19+
//
20+
// To this (suspect error in the original document):
21+
// 0x02, 0x02, 0x00, 0x01, 0x00, 0x00, 0x2A, 0x00, 0x00, 0xFF, 0x02, 0x09, 0x09, 0x45, 0x47, 0x44, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, // structure(2) = {(0,1,0,0,42,0,0,255,2), octet-string(9) = "EGD012345"}
22+
23+
const uint8_t egd_example_raw_frame[] = {
24+
0x0F, // data-notification --------------------------------------------------------------------------------------------------------------------
25+
0x00, 0x00, 0x00, 0x01, // long-invoke-id-and-priority = 0x00000001
26+
0x00, // date-time = null
27+
0x02, 0x02, 0x16, 0x01, 0x01, 0x1B, // structure(2) = {enum = 1, array = 27}
28+
0x02, 0x02, 0x00, 0x01, 0x00, 0x00, 0x2A, 0x00, 0x00, 0xFF, 0x02, 0x09, 0x09, 0x45, 0x47, 0x44, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, // structure(2) = {(0,1,0,0,42,0,0,255,2), octet-string(9) = "EGD012345"}
29+
0x02, 0x02, 0x00, 0x28, 0x00, 0x02, 0x19, 0x09, 0x00, 0xFF, 0x01, 0x09, 0x06, 0x00, 0x02, 0x19, 0x09, 0x00, 0xFF, // structure(2) = {(0,40,0,2,25,9,0,255,1), octet-string(6) = (0,2,25,9,0,255)}
30+
0x02, 0x02, 0x00, 0x01, 0x00, 0x00, 0x60, 0x01, 0x00, 0xFF, 0x02, 0x09, 0x0A, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, // structure(2) = {(0,1,0,0,96,1,0,255,2), octet-string(10) = "0123456789"}
31+
0x02, 0x02, 0x00, 0x46, 0x00, 0x00, 0x60, 0x03, 0x0A, 0xFF, 0x03, 0x16, 0x01, // structure(2) = {(0,70,0,0,96,3,10,255,3), enum = 1}
32+
0x02, 0x02, 0x00, 0x47, 0x00, 0x00, 0x11, 0x00, 0x00, 0xFF, 0x03, 0x06, 0x00, 0x00, 0x00, 0x00, // structure(2) = {(0,71,0,0,17,0,0,255,3), double-long-unsigned = 0}
33+
0x02, 0x02, 0x00, 0x46, 0x00, 0x01, 0x60, 0x03, 0x0A, 0xFF, 0x03, 0x16, 0x01, // structure(2) = {(0,70,0,1,96,3,10,255,3), enum = 1}
34+
0x02, 0x02, 0x00, 0x46, 0x00, 0x02, 0x60, 0x03, 0x0A, 0xFF, 0x03, 0x16, 0x01, // structure(2) = {(0,70,0,2,96,3,10,255,3), enum = 1}
35+
0x02, 0x02, 0x00, 0x46, 0x00, 0x03, 0x60, 0x03, 0x0A, 0xFF, 0x03, 0x16, 0x00, // structure(2) = {(0,70,0,3,96,3,10,255,3), enum = 0}
36+
0x02, 0x02, 0x00, 0x46, 0x00, 0x04, 0x60, 0x03, 0x0A, 0xFF, 0x03, 0x16, 0x00, // structure(2) = {(0,70,0,4,96,3,10,255,3), enum = 0}
37+
0x02, 0x02, 0x00, 0x46, 0x00, 0x05, 0x60, 0x03, 0x0A, 0xFF, 0x03, 0x16, 0x00, // structure(2) = {(0,70,0,5,96,3,10,255,3), enum = 0}
38+
0x02, 0x02, 0x00, 0x46, 0x00, 0x06, 0x60, 0x03, 0x0A, 0xFF, 0x03, 0x16, 0x00, // structure(2) = {(0,70,0,6,96,3,10,255,3), enum = 0}
39+
0x02, 0x02, 0x00, 0x01, 0x00, 0x00, 0x60, 0x0E, 0x00, 0xFF, 0x02, 0x09, 0x02, 0x54, 0x33, // structure(2) = {(0,1,0,0,96,14,0,255,2), octet-string = "T3"}
40+
0x02, 0x02, 0x00, 0x03, 0x01, 0x00, 0x01, 0x07, 0x00, 0xFF, 0x02, 0x06, 0x00, 0x00, 0x00, 0x03, // structure(2) = {(0,3,1,0,1,7,0,255,2), double-long-unsigned = 3}
41+
0x02, 0x02, 0x00, 0x03, 0x01, 0x00, 0x15, 0x07, 0x00, 0xFF, 0x02, 0x06, 0x00, 0x00, 0x00, 0x01, // structure(2) = {(0,3,1,0,21,7,0,255,2), double-long-unsigned = 1}
42+
0x02, 0x02, 0x00, 0x03, 0x01, 0x00, 0x29, 0x07, 0x00, 0xFF, 0x02, 0x06, 0x00, 0x00, 0x00, 0x01, // structure(2) = {(0,3,1,0,41,7,0,255,2), double-long-unsigned = 1}
43+
0x02, 0x02, 0x00, 0x03, 0x01, 0x00, 0x3D, 0x07, 0x00, 0xFF, 0x02, 0x06, 0x00, 0x00, 0x00, 0x01, // structure(2) = {(0,3,1,0,61,7,0,255,2), double-long-unsigned = 1}
44+
0x02, 0x02, 0x00, 0x03, 0x01, 0x00, 0x02, 0x07, 0x00, 0xFF, 0x02, 0x06, 0x00, 0x00, 0x00, 0x03, // structure(2) = {(0,3,1,0,2,7,0,255,2), double-long-unsigned = 3}
45+
0x02, 0x02, 0x00, 0x03, 0x01, 0x00, 0x16, 0x07, 0x00, 0xFF, 0x02, 0x06, 0x00, 0x00, 0x00, 0x01, // structure(2) = {(0,3,1,0,22,7,0,255,2), double-long-unsigned = 1}
46+
0x02, 0x02, 0x00, 0x03, 0x01, 0x00, 0x2A, 0x07, 0x00, 0xFF, 0x02, 0x06, 0x00, 0x00, 0x00, 0x01, // structure(2) = {(0,3,1,0,42,7,0,255,2), double-long-unsigned = 1}
47+
0x02, 0x02, 0x00, 0x03, 0x01, 0x00, 0x3E, 0x07, 0x00, 0xFF, 0x02, 0x06, 0x00, 0x00, 0x00, 0x01, // structure(2) = {(0,3,1,0,62,7,0,255,2), double-long-unsigned = 1}
48+
0x02, 0x02, 0x00, 0x03, 0x01, 0x00, 0x01, 0x08, 0x00, 0xFF, 0x02, 0x06, 0x00, 0x00, 0x00, 0x08, // structure(2) = {(0,3,1,0,1,8,0,255,2), double-long-unsigned = 8}
49+
0x02, 0x02, 0x00, 0x03, 0x01, 0x00, 0x01, 0x08, 0x01, 0xFF, 0x02, 0x06, 0x00, 0x00, 0x00, 0x00, // structure(2) = {(0,3,1,0,1,8,1,255,2), double-long-unsigned = 0}
50+
0x02, 0x02, 0x00, 0x03, 0x01, 0x00, 0x01, 0x08, 0x02, 0xFF, 0x02, 0x06, 0x00, 0x00, 0x00, 0x04, // structure(2) = {(0,3,1,0,1,8,2,255,2), double-long-unsigned = 4}
51+
0x02, 0x02, 0x00, 0x03, 0x01, 0x00, 0x01, 0x08, 0x03, 0xFF, 0x02, 0x06, 0x00, 0x00, 0x00, 0x04, // structure(2) = {(0,3,1,0,1,8,3,255,2), double-long-unsigned = 4}
52+
0x02, 0x02, 0x00, 0x03, 0x01, 0x00, 0x01, 0x08, 0x04, 0xFF, 0x02, 0x06, 0x00, 0x00, 0x00, 0x00, // structure(2) = {(0,3,1,0,1,8,4,255,2), double-long-unsigned = 0}
53+
0x02, 0x02, 0x00, 0x03, 0x01, 0x00, 0x02, 0x08, 0x00, 0xFF, 0x02, 0x06, 0x00, 0x00, 0x00, 0x04, // structure(2) = {(0,3,1,0,2,8,0,255,2), double-long-unsigned = 4}
54+
0x02, 0x02, 0x00, 0x01, 0x00, 0x00, 0x60, 0x0D, 0x00, 0xFF, 0x02, 0x09, 0x00 // structure(2) = {(0,1,0,0,96,13,0,255,2), octet-string = null}
55+
};
56+
57+
constexpr size_t egd_example_expected_count = 27;
58+
59+
const std::map<std::string, std::string> egd_example_expected_strings = {
60+
{"0.0.96.14.0.255", "T3"},
61+
{"0.0.42.0.0.255", "EGD012345"},
62+
{"0.2.25.9.0.255", ""}, // (0,2,25,9,0,255)
63+
{"0.0.96.1.0.255", "0123456789"},
64+
{"0.0.96.13.0.255", ""}
65+
};
66+
67+
const std::map<std::string, float> egd_example_expected_floats = {
68+
{"0.0.96.3.10.255", 1.0f},
69+
{"0.0.17.0.0.255", 0.0f},
70+
{"0.1.96.3.10.255", 1.0f},
71+
{"0.2.96.3.10.255", 1.0f},
72+
{"0.3.96.3.10.255", 0.0f},
73+
{"0.4.96.3.10.255", 0.0f},
74+
{"0.5.96.3.10.255", 0.0f},
75+
{"0.6.96.3.10.255", 0.0f},
76+
{"1.0.1.7.0.255", 3.0f},
77+
{"1.0.21.7.0.255", 1.0f},
78+
{"1.0.41.7.0.255", 1.0f},
79+
{"1.0.61.7.0.255", 1.0f},
80+
{"1.0.2.7.0.255", 3.0f},
81+
{"1.0.22.7.0.255", 1.0f},
82+
{"1.0.42.7.0.255", 1.0f},
83+
{"1.0.62.7.0.255", 1.0f},
84+
{"1.0.1.8.0.255", 8.0f},
85+
{"1.0.1.8.1.255", 0.0f},
86+
{"1.0.1.8.2.255", 4.0f},
87+
{"1.0.1.8.3.255", 4.0f},
88+
{"1.0.1.8.4.255", 0.0f},
89+
{"1.0.2.8.0.255", 4.0f}
90+
};
91+
92+
} // namespace dlms::test_data

tests/test_meter_dumps.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@
1111
#include "dlms_parser/log.h"
1212

1313
#include "tests/expected/raw_sagemcom_xt211.h"
14+
#include "tests/expected/raw_energomera.h"
15+
#include "tests/expected/raw_salzburg_netz.h"
16+
#include "tests/expected/raw_egd_example.h"
1417
#include "tests/expected/hdlc_iskra550.h"
1518
#include "tests/expected/hdlc_norway_han_1phase.h"
1619
#include "tests/expected/hdlc_norway_han_3phase.h"
17-
#include "tests/expected/mbus_netz_noe_p1.h"
18-
#include "tests/expected/raw_energomera.h"
1920
#include "tests/expected/hdlc_landis_gyr_zmf100.h"
20-
#include "tests/expected/raw_salzburg_netz.h"
2121
#include "tests/expected/hdlc_landis_gyr_e450.h"
2222
#include "tests/expected/hdlc_lgz_e450_2.h"
23+
#include "tests/expected/mbus_netz_noe_p1.h"
2324

2425
void run_meter_test(const char* name,
2526
const uint8_t* payload, size_t payload_size,
@@ -137,6 +138,16 @@ TEST_CASE("Integration: RAW APDU") {
137138
);
138139
}
139140

141+
SUBCASE("EGD Example") {
142+
run_meter_test("EGD Example",
143+
dlms::test_data::egd_example_raw_frame,
144+
sizeof(dlms::test_data::egd_example_raw_frame),
145+
dlms::test_data::egd_example_expected_count,
146+
dlms::test_data::egd_example_expected_strings,
147+
dlms::test_data::egd_example_expected_floats
148+
);
149+
}
150+
140151
}
141152

142153
// ---------------------------------------------------------
@@ -197,7 +208,7 @@ TEST_CASE("Integration: HDLC") {
197208
);
198209
}
199210

200-
SUBCASE("Landis+Gyr ZMF100 CRC check rejects bad FCS") {
211+
SUBCASE("Landis+Gyr ZMF100 - CRC check rejects bad FCS") {
201212
std::array<uint8_t, 2048> work_buf{};
202213
dlms_parser::DlmsParser parser;
203214
parser.set_work_buffer(work_buf.data(), work_buf.size());

0 commit comments

Comments
 (0)