microbuilder / LPC11U_LPC13U_CodeBase

Open source code base for ARM Cortex M3 LPC1347 or Cortex M0 LPC11U37/LPC11U24 MCUs
Other
55 stars 40 forks source link

defects in stdio.c #20

Open markfink opened 10 years ago

markfink commented 10 years ago

I think open source is the way to go in embedded programming. I like your project. Awesome work!

I came across your project when I was looking for sprintf with reasonable footprint. I thought I give it some spin with unity tests. I found some defects and I thought I would double check with you if you are interested and if you are planning to fix them. I have the impression that there are probably some more. I also verified the problem on the target (LPC1343).

// this works TEST(sprintf, DoubleNoFormat) { char output[80]; TEST_ASSERT_EQUAL(20, my_sprintf(output, "double: %f\n", 1234.56789)); TEST_ASSERT_EQUAL_STRING("double: 1234.567890\n", output); }

TEST(sprintf, DoubleSimple) { char output[80]; TEST_ASSERT_EQUAL(17, my_sprintf(output, "double: %.3f\n", 1234.56789)); TEST_ASSERT_EQUAL_STRING("double: 1234.567\n", output); }

Unity test run 1 of 1 .....!!.. tests/test_sprintf.c:93:TEST(sprintf, DoubleSimple):FAIL: Expected 17 Was -1

I noticed that the library was originally developed by Atmel. Do you know by any chance a project that continued the work?

Cheers, Mark

microbuilder commented 10 years ago

I'm aware of some bugs here, yes. See issue 14 here for example (https://github.com/microbuilder/LPC11U_LPC13U_CodeBase/issues/14).

If you're willing to poke at this, I'm more than happy to integrate any pull requests. The code is a departure from Atmel who didn't include float support, etc., and I don't think there is anything else out there. I ended up adding support myself precisely because there wasn't much out there that included float (etc.) and was appropriate for tiny embedded systems.

microbuilder commented 10 years ago

BTW ... make sure you're working on the development branch. The main branch is quite old.