Blog coding article

Knurling-rs changelog #2

Lotte
Article

Knurling-rs changelog #2

Published on 4 min read
Knurling icon
Knurling
A tool set to develop embedded applications faster.
❤️ Sponsor

    knurling logo

    This is the second weekly changelog for Knurling-rs, our push to sustainably build better tooling for developing and debugging Rust software for embedded systems. Knurling-rs includes a suite of tools that make it easier to develop, log, debug, and test your embedded Rust libraries and applications!

    Knurling-rs is supported by our sponsors on GitHub. If you're interested in seeing more projects like this, consider becoming a sponsor today!

    This week was a bit quieter in the knurling world. We largely focused on infrastructure work and bugfixes.

    Corporate Sponsorship

    We are looking for companies to sponsor our Knurling-rs efforts! If you or your team uses Knurling for work projects, consider supporting Knurling-rs! In addition to GitHub Sponsors, we now offer the following sponsorship choices

    Changelog Sponsorship

    Each changelog sponsor will have their company's logo showcased on each of our weekly changelogs! This sponsorship is currently available for 500 EUR per month, excluding VAT where applicable. If you are interested, please reach out to us for details.

    NOTE: This reward is NOT available through GitHub Sponsors.

    Website Sponsorship

    We'll be launching a landing page for Knurling-rs, showcasing all of the great tools available. Website sponsors will have their logo showcased directly on the main page as a thank you for supporting Knurling-rs. This sponsorship is currently available for 1000 EUR per month, excluding VAT where applicable. If you are interested, please reach out to us for details.

    NOTE: This reward is NOT available through GitHub Sponsors.

    Bugfix: prevent stalling applications when there's no debugger attached

    defmt-rtt now has a non-blocking mode which it uses by default. This prevents your application from stalling after a while when there's no debugger attached that can collect defmts RTT output.

    probe-run has been adjusted to accommodate this.

    First public release of defmt-test!

    We've built a library to assist with unit-testing on embedded systems called defmt-test to make writing unit tests more ergonomic. Since last week, we've released defmt-test publicly, meaning anyone can begin using it!

    As a quick reminder, with defmt-test you can write unit tests as if you were using the built-in #[test] attribute.

    // testsuite/tests/test.rs
    
    #[defmt_test::tests]
    mod tests {
        #[test]
        fn assert_true() {
            assert!(true)
        }
    
        #[test]
        fn assert_false() {
            assert!(false)
        }
    }
    
    $ cargo test -p testsuite
    0.000000 INFO  running assert_true ..
    0.000001 INFO  .. assert_true ok
    0.000002 INFO  running assert_false ..
    0.000003 ERROR panicked at 'assertion failed: false', tests/test.rs:15:9
    stack backtrace:
    (..)
    error: test failed, to rerun pass `-p testsuite --test all`
    
    $ echo $?
    134
    

    Thanks to all the feedback from sponsors who were able to try this out early!

    Improved error handling in defmt-test

    Instead of panic!()ing when encountering an incorrect test function signature or attribute, defmt-test now fails at compile time with a more helpful message.

    For example, trying to compile this test module

    struct MyState {
        flag: bool,
    }
    
    #[defmt_test::tests]
    mod tests {
        #[init]
        fn init() -> super::MyState {
            super::MyState {
                flag: true,
            }
        }
    
        #[init]
        fn init() {
            super::MyState {
                flag: false,
            }
        }
    }
    

    now fails with

    error: only a single `#[init]` function can be defined
      --> testsuite/tests/test.rs:22:8
       |
    22 |     fn init() -> super::MyState {
       |        ^^^^
    

    instead of the previous

    error: custom attribute panicked
      --> testsuite/tests/test.rs:11:1
       |
    11 | #[defmt_test::tests]
       | ^^^^^^^^^^^^^^^^^^^^
       |
       = help: message: assertion failed: init.is_none()
    

    Knurling Logo and Design

    We've gotten a new logo for Knurling-rs, thanks to the folks at Ura Design! You may have noticed this on our GitHub profile, as well as at the top of this changelog. We're working on building a landing page for Knurling-rs, so keep an eye out for that soon!

    Sponsor this work

    probe-run, defmt, and defmt-test are Knurling projects and can be funded through GitHub sponsors. Sponsors get early access to the tools we are building. Thank you to all of the people already sponsoring our work through the Knurling project!