Skip to content

RIOT: make use od module for hexdump #187

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

Merged
merged 1 commit into from
Feb 25, 2023

Conversation

benpicco
Copy link
Contributor

@benpicco benpicco commented Feb 5, 2023

While trying to figure out why tinydtls still requires gettimeofday() even though dtls_ticks() uses ZTimer now, I found that it's still used via time() in dtls_dsrv_hexdump_log().

Replace it with a native hexdump function as it was done for Zephyr.

This allows us to drop the gettimeofday compat modules that was so far needed to build tinydtls with RIOT.

before

   text	   data	    bss	    dec	    hex	filename
 123068	    384	  24920	 148372	  24394	/home/benpicco/dev/RIOT/examples/dtls-sock/bin/openmote-b/dtls_sock.elf

with this patch

   text	   data	    bss	    dec	    hex	filename
 107756	    272	  24776	 132804	  206c4	/home/benpicco/dev/RIOT/examples/dtls-sock/bin/openmote-b/dtls_sock.elf

#define dtls_debug_hexdump(name, buf, length) dtls_dsrv_hexdump_log(DTLS_LOG_DEBUG, name, buf, length, 1)
#define dtls_debug_dump(name, buf, length) dtls_dsrv_hexdump_log(DTLS_LOG_DEBUG, name, buf, length, 0)
#define dtls_debug_hexdump(name, buf, length) { if (LOG_DEBUG <= LOG_LEVEL) { LOG_DEBUG("%s (%zu bytes):", name, length); od_hex_dump(buf, length, 0); }}
#define dtls_debug_dump(name, buf, length) { if (LOG_DEBUG <= LOG_LEVEL) { LOG_DEBUG("%s (%zu bytes):", name, length); od_hex_dump(buf, length, 0); }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For tinydtls the difference of dtls_debug_hexdump and dtls_debug_dump is, that the first logs multiple lines (suitable for larger messages), while the second logs a single line.
In zephyr I didn't found something to achieve that behavior.
For RIOT it may be possible, using "\n" at the end of the LOG_DEBUG and then use a proper width for each instead of the 0. If you don't feel well with that proposal, the current version will also do it for me.

Copy link
Contributor Author

@benpicco benpicco Feb 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

od_hex_dump() will already split the buffer into multiple lines on it's own. A width of 0 will just select the default width.

I added a newline to dtls_debug_hexdump().

@boaks
Copy link
Contributor

boaks commented Feb 6, 2023

Just to mention: don't care about the ECA error. The eclipse admin are already on it. It's a general issue.

@benpicco
Copy link
Contributor Author

benpicco commented Feb 8, 2023

Looks like it's resolved :)

@boaks
Copy link
Contributor

boaks commented Feb 8, 2023

Yes, from my side LGTM.

@boaks boaks merged commit 5e14e49 into eclipse-tinydtls:main Feb 25, 2023
@benpicco benpicco deleted the RIOT-hexdump branch February 25, 2023 13:41
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.

3 participants