Mynewt FAQ - Syntax, Semantics, Configuration¶
Q: I am trying to print floating point in Mynewt using
console_printf("%f", floating_var) but I am unable to do so.
How do I resolve the issue? I’m aware Mynewt uses baselibc - does it even support floating point?
A: Baselibc does support floating point formatting, but it is not enabled
by default. To enable it, set the following syscfg setting to 1 in your
However, baselibc’s float printf support is a bit limited. In particular, it ignores precision specifiers and always prints three digits after the decimal point.
Q: I have a task which is blocking on a call to
os_time_delay(). What is the recommended way to end the delay
early in an ISR (e.g. button press)?
A: The best way would be to use a semaphore. Initialize the semaphore with a count of 0 (
block on the semaphore with the maximum delay you want to wait for (
os_sem_pend()). The button press event would
wake the first task up early by calling
Q: Does Mynewt have a random function or random device?
Q: What is
mfghash? How do I set
mfghash (currently blank in my app)?
mfghash is computed if you’re using
newt mfg to construct your flash image, and it identifies the build of
newt mfg bundles togetherthe bootloader, target image, and other data you’d want to bundle when creating
an image to burn to flash. See the
newt mfg documentation for the construction
side of things and
apache-mynewt-core/sys/mfg/src/mfg.c for the firmware side.
serial was intended to be used if you
want to have your own naming scheme per device when building products; i.e. you want something other than the mcu serial
number, or if you don’t have serial number available.
Q: Is there a way to make printf and console_printf honor the leading zeros format? As in:
outputting “05” instead of as for me now: “2d” ?
Q: Is there an equivalent to the UNIX sleep(3)?
os_time_delay(OS_TICKS_PER_SEC * secs)