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

add crc error message #109

Closed
wants to merge 1 commit into from
Closed

add crc error message #109

wants to merge 1 commit into from

Conversation

devZer0
Copy link

@devZer0 devZer0 commented Nov 19, 2022

example message from devZer0/libsml-testing#13

cat eBZ_DD3_2R06.bin | ./sml_server -

libsml: error: CRC checksum mismatch
libsml: error: CRC checksum mismatch

also see discussion there

@jahir
Copy link
Member

jahir commented Feb 6, 2023

libs should only print errors to stderr as a last resort. but as it is already used (occasionally), it seems ok. AFAIK, there is currently no better way to get errors out of libsml... (#93 is WIP)

So if nobody objects, this should be merged.

@r00t-
Copy link
Collaborator

r00t- commented Feb 7, 2023

this seems to relate to #103

@r00t-
Copy link
Collaborator

r00t- commented Feb 7, 2023

@devZer0:
good idea (it seems i missed this MR before!), just a few details:

your commit has the username set to root, can you fix this?
(git config --global --add user.email "..." --add user.name="..." git commit --amend --reset-author git push --force)

the formatting isn't ideal, as it now seems the comment "Workaround for Holley DTZ541"
applies to the whole block, and not just the the condition.

also imho the message could be more helpful.

i would write this like:

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

@mbehr1
Copy link

mbehr1 commented Feb 7, 2023

I was thinking whether returning e.g. a "fake" sml reading that maps to obis error codes like S.1.1.16 (device status) S.1.1.7 (failed readout attempts) would make it easier processable.

@r00t-
Copy link
Collaborator

r00t- commented Feb 8, 2023

@mbehr1:

I was thinking whether returning e.g. a "fake" sml reading ...

we shouldn't be doing such a thing.
we simply need to extend the API, if the current one doesn't fit our requirements.
that should even still be backwards compatible for code that does not need the new features - same as for #93

@r00t-
Copy link
Collaborator

r00t- commented Feb 9, 2023

if @devZer0 doesn't mind or doesn't respond, we can just merge #114 instead.

@devZer0
Copy link
Author

devZer0 commented Feb 9, 2023

thanks for reminder, i'm totally busy at the moment, so i'm fine if you drop my commit or replace with something other/better

@r00t-
Copy link
Collaborator

r00t- commented Feb 9, 2023

@devZer0: thanks!

closing as superseded by #114

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.

4 participants