Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added files for eBZ DD3 2R06 #13

Closed
wants to merge 1 commit into from

Conversation

eng1neer-com
Copy link

I added example files for electric meter eBZ DD3 2R06.

I created the binary file based on the example:
cat yoursmldump.hex | xxd -r -p >yoursmldump.bin

But I was not able to test it with the sml-server example (no output was shown).
cat eBZ_DD3_2R06.bin | ./sml_server - | head -n10

added files for eBZ DD3 2R06 electric meter
@devZer0
Copy link
Owner

devZer0 commented Nov 16, 2022

hello. thanks for submission and sorry for not merging yet , but i like to merge working examples.

did you ever find out why sml_server is not able to decode?

unfortunately , my time is too limited to dig into it myself

@fkohlgrueber
Copy link
Collaborator

I just checked the data using the sml library I'm writing (sml-rs), and it seems to be fine. One caveat is that I can currently only check the transport layer because the actual parser is still a work in progress. But looking at the transport layer, the data contains a single message that correctly validates using the contained checksums. I would therefore say that the data is correct and can be merged.

@fkohlgrueber
Copy link
Collaborator

I dug a little deeper (using the work-in-progress parser in sml-rs). It seems like the message is fine except that the crc within the SML Message doesn't seem to be right. It's possible that this particular smart meter uses another crc variant. When disabling the crc check, I can decode the message. Here's some debug output:

File {
    messages: [
        Message {
            transaction_id: [1, 24, 142, 97],
            group_id: 0,
            abort_on_error: 0,
            message_body: OpenResponse(
                OpenResponse {
                    codepage: None,
                    client_id: None,
                    req_file_id: [0, 0, 0, 0, 0, 0],
                    server_id: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                    ref_time: None,
                    sml_version: None,
                },
            ),
        },
        Message {
            transaction_id: [1, 24, 142, 98],
            group_id: 0,
            abort_on_error: 0,
            message_body: GetListResponse(
                GetListResponse {
                    client_id: None,
                    server_id: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                    list_name: None,
                    act_sensor_time: Some(SecIndex(3064820)),
                    val_list: [
                        ListEntry {
                            obj_name: [129, 129, 199, 130, 3, 255],
                            status: None,
                            val_time: None,
                            unit: None,
                            scaler: None,
                            value: Bytes([69, 66, 90]),
                            value_signature: None,
                        },
                        ListEntry {
                            obj_name: [1, 0, 0, 0, 9, 255],
                            status: None,
                            val_time: None,
                            unit: None,
                            scaler: None,
                            value: Bytes([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]),
                            value_signature: None,
                        },
                        ListEntry {
                            obj_name: [1, 0, 1, 8, 0, 255],
                            status: Some(Status32(65920)),
                            val_time: None,
                            unit: Some(30),
                            scaler: Some(-5),
                            value: U64(45009189911),
                            value_signature: None,
                        },
                        ListEntry {
                            obj_name: [1, 0, 1, 8, 1, 255],
                            status: None,
                            val_time: None,
                            unit: Some(30),
                            scaler: Some(-5),
                            value: U64(44907489911),
                            value_signature: None,
                        },
                        ListEntry {
                            obj_name: [1, 0, 1, 8, 2, 255],
                            status: None,
                            val_time: None,
                            unit: Some(30),
                            scaler: Some(-5),
                            value: U64(101700000),
                            value_signature: None,
                        },
                        ListEntry {
                            obj_name: [1, 0, 2, 8, 0, 255],
                            status: Some(Status32(65920)),
                            val_time: None,
                            unit: Some(30),
                            scaler: Some(-5),
                            value: U64(219800000),
                            value_signature: None,
                        },
                        ListEntry {
                            obj_name: [1, 0, 16, 7, 0, 255],
                            status: None,
                            val_time: None,
                            unit: Some(27),
                            scaler: Some(-2),
                            value: I32(35289),
                            value_signature: None,
                        },
                        ListEntry {
                            obj_name: [1, 0, 36, 7, 0, 255],
                            status: None,
                            val_time: None,
                            unit: Some(27),
                            scaler: Some(-2),
                            value: I32(8226),
                            value_signature: None,
                        },
                        ListEntry {
                            obj_name: [1, 0, 56, 7, 0, 255],
                            status: None,
                            val_time: None,
                            unit: Some(27),
                            scaler: Some(-2),
                            value: I32(2706),
                            value_signature: None,
                        },
                        ListEntry {
                            obj_name: [1, 0, 76, 7, 0, 255],
                            status: None,
                            val_time: None,
                            unit: Some(27),
                            scaler: Some(-2),
                            value: I32(24357),
                            value_signature: None,
                        },
                    ],
                    list_signature: None,
                    act_gateway_time: None,
                },
            ),
        },
        Message {
            transaction_id: [1, 24, 142, 99],
            group_id: 0,
            abort_on_error: 0,
            message_body: CloseResponse(
                CloseResponse {
                    global_signature: None,
                },
            ),
        },
    ],
},

The output looks good to me. It's odd that the server_id is set to all-zero, but it's quite possible that the meter doesn't populate this field. According to the data, the meter's total energy consumption is 450091 Wh.

@eng1neer-com does the output look good to you?

@devZer0
Copy link
Owner

devZer0 commented Nov 18, 2022

cool, thanks for the analysis.

wouldn't it make sense to implement optional disabling of crc checksum checking in libsml/sml_server ?

@eng1neer-com , could you provide a longer/larger sample of binary data which contains multiple sml messages? that would perhaps make it easier to decide if this is a checksum error or if it is different checksum algorithm.

adding error message like this should be helpful, too. being curious why it's missing at all. will submit that to libsml if you think it's good/ok

sml_message.c:

    if (*msg->crc != sml_crc16_calculate(&(buf->buffer[msg_start]), len))
            // Workaround for Holley DTZ541 uses CRC-16/Kermit
            if (*msg->crc != sml_crc16kermit_calculate(&(buf->buffer[msg_start]), len)) {
                    fprintf(stderr, "libsml: error: checksum mismatch\n");
                    goto error;
            }

@fkohlgrueber
Copy link
Collaborator

wouldn't it make sense to implement optional disabling of crc checksum checking in libsml/sml_server ?

Not sure about that. CRC mismatches almost always indicate corrupted data and allowing users to bypass them could lead to corrupted data being displayed. I'd prefer displaying warnings for messages that have a CRC mismatch (possibly with the calculated / expected values).

adding error message like this should be helpful, too. being curious why it's missing at all. will submit that to libsml if you think it's good/ok

LGTM. You could probably add the actual crc values (calculated vs. expected) and also include that the message is discarded due to the mismatch. Something along the lines of "discarding message due to checksum mismatch" maybe?

@eng1neer-com , could you provide a longer/larger sample of binary data which contains multiple sml messages? that would perhaps make it easier to decide if this is a checksum error or if it is different checksum algorithm.

That'd be great, +1 from me!

@fkohlgrueber
Copy link
Collaborator

BTW, we already have data from an eBZ DD3 2R06 in the repo (see here). It'd be interesting to know why the other data set works fine.

devZer0 referenced this pull request in devZer0/libsml Nov 19, 2022
@fkohlgrueber
Copy link
Collaborator

@eng1neer-com just checking in, any chance you could provide another dump for us?

@eng1neer-com
Copy link
Author

Hi, unfortunately I currently have no access to this particular meter. I will try to get another measurement next time.

@devZer0 devZer0 closed this Apr 18, 2023
@devZer0
Copy link
Owner

devZer0 commented Apr 18, 2023

sorry, but this is invalid message data, so no merge

@r00t-
Copy link

r00t- commented Mar 8, 2024

or if it is different checksum algorithm

note that one such case is already implemented:
https://github.com/volkszaehler/libsml/blob/32910b2fbcd477aedb972e438598b39df9317375/sml/src/sml_message.c#L82-L87

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants