LwPRINTF branch-2801bb3 documentation¶
Welcome to the documentation for version branch-2801bb3.
LwPRINTF is lightweight stdio manager optimized for embedded systems.
It includes implementation of standard output functions such as printf
, vprintf
, snprintf
, sprintf
and vsnprintf
in an embedded-systems optimized way.
Download library Getting started Open Github Donate
Features¶
Written in ANSI C99, compatible with
size_t
anduintmax_t
types for some specifiersImplements output functions compatible with
printf
,vprintf
,snprintf
,sprintf
andvsnprintf
Low-memory footprint, suitable for embedded systems
Reentrant access to all API functions
Operating-system ready
Requires single output function to be implemented by user for
printf
-like API callsWith optional functions for operating systems to protect multiple threads printing to the same output stream
Allows multiple output stream functions (unlike standard
printf
which supports only one) to separate parts of applicationAdded additional specifiers vs original features
User friendly MIT license
Requirements¶
C compiler
Few kB of non-volatile memory
Contribute¶
Fresh contributions are always welcome. Simple instructions to proceed:
Fork Github repository
Respect C style & coding rules used by the library
Create a pull request to
develop
branch with new features or bug fixes
Alternatively you may:
Report a bug
Ask for a feature request
License¶
MIT License
Copyright (c) 2020 Tilen Majerle
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Table of contents¶
Getting started¶
Getting started may be the most challenging part of every new library. This guide is describing how to start with the library quickly and effectively
Download library¶
Library is primarly hosted on Github.
You can get it with:
Downloading latest release from releases area on Github
Cloning
master
branch for latest stable versionCloning
develop
branch for latest development
Download from releases¶
All releases are available on Github releases area.
Clone from Github¶
First-time clone¶
This is used when you do not have yet local copy on your machine.
Make sure
git
is installed.Open console and navigate to path in the system to clone repository to. Use command
cd your_path
Clone repository with one of available
3
optionsRun
git clone --recurse-submodules https://github.com/MaJerle/lwprintf
command to clone entire repository, including submodulesRun
git clone --recurse-submodules --branch develop https://github.com/MaJerle/lwprintf
to clone development branch, including submodulesRun
git clone --recurse-submodules --branch master https://github.com/MaJerle/lwprintf
to clone latest stable branch, including submodules
Navigate to
examples
directory and run favourite example
Update cloned to latest version¶
Open console and navigate to path in the system where your resources repository is. Use command
cd your_path
Run
git pull origin master --recurse-submodules
command to pull latest changes and to fetch latest changes from submodules onmaster
branchRun
git pull origin develop --recurse-submodules
command to pull latest changes and to fetch latest changes from submodules ondevelop
branchRun
git submodule foreach git pull origin master
to update & merge all submodules
Note
This is preferred option to use when you want to evaluate library and run prepared examples. Repository consists of multiple submodules which can be automatically downloaded when cloning and pulling changes from root repository.
Add library to project¶
At this point it is assumed that you have successfully download library, either cloned it or from releases page. Next step is to add the library to the project, by means of source files to compiler inputs and header files in search path
Copy
lwprintf
folder to your project, it contains library filesAdd
lwprintf/src/include
folder to include path of your toolchain. This is where C/C++ compiler can find the files during compilation process. Usually using-I
flagAdd source files from
lwprintf/src/
folder to toolchain build. These files are built by C/C++ compilerCopy
lwprintf/src/include/lwprintf/lwprintf_opts_template.h
to project folder and rename it tolwprintf_opts.h
Build the project
Configuration file¶
Configuration file is used to overwrite default settings defined for the essential use case.
Library comes with template config file, which can be modified according to needs.
and it should be copied (or simply renamed in-place) and named lwprintf_opts.h
Note
Default configuration template file location: lwprintf/src/include/lwprintf/lwprintf_opts_template.h
.
File must be renamed to lwprintf_opts.h
first and then copied to the project directory where compiler
include paths have access to it by using #include "lwprintf_opts.h"
.
List of configuration options are available in the Configuration section. If any option is about to be modified, it should be done in configuration file
1/**
2 * \file lwprintf_opts_template.h
3 * \brief LwPRINTF configuration file
4 */
5
6/*
7 * Copyright (c) 2020 Tilen MAJERLE
8 *
9 * Permission is hereby granted, free of charge, to any person
10 * obtaining a copy of this software and associated documentation
11 * files (the "Software"), to deal in the Software without restriction,
12 * including without limitation the rights to use, copy, modify, merge,
13 * publish, distribute, sublicense, and/or sell copies of the Software,
14 * and to permit persons to whom the Software is furnished to do so,
15 * subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice shall be
18 * included in all copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
23 * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 * OTHER DEALINGS IN THE SOFTWARE.
28 *
29 * This file is part of LwPRINTF - Lightweight stdio manager library.
30 *
31 * Author: Tilen MAJERLE <tilen@majerle.eu>
32 * Version: v1.0.3
33 */
34#ifndef LWPRINTF_HDR_OPTS_H
35#define LWPRINTF_HDR_OPTS_H
36
37/* Rename this file to "lwprintf_opts.h" for your application */
38
39/*
40 * Open "include/lwprintf/lwprintf_opt.h" and
41 * copy & replace here settings you want to change values
42 */
43
44#endif /* LWPRINTF_HDR_OPTS_H */
Note
If you prefer to avoid using configuration file, application must define
a global symbol LWPRINTF_IGNORE_USER_OPTS
, visible across entire application.
This can be achieved with -D
compiler option.
Minimal example code¶
To verify proper library setup, minimal example has been prepared. Run it in your main application file to verify its proper execution
1#include "lwprintf/lwprintf.h"
2
3/* Called for every character to be printed */
4int
5lwprintf_out(int ch, lwprintf_t* lwp) {
6 /* May use printf to output it for test */
7 if (ch != '\0') {
8 printf("%c", (char)ch);
9 }
10
11 return ch;
12}
13
14int
15main(void) {
16 /* Initialize default lwprintf instance with output function */
17 lwprintf_init(lwprintf_out);
18
19 /* Print first text */
20 lwprintf_printf("Text: %d", 10);
21}
User manual¶
How it works¶
LwPRINTF library supports 2
different formatting output types:
Write formatted data to user input array
Directly print formatted characters by calling
output_function
for every formatted character in the input string
Text formatting is based on input format string followed by the data parameters. It is mostly used to prepare numeric data types to human readable format.
Note
LwPRINTF is open-source implementation of regular stdio.h library in C language. It implements only output functions, excluding input scanning features
Formatting functions take input format string followed by (optional) different data types. Internal algorithm scans character by character to understand type of expected data user would like to have printed.
Every format specifier starts with letter %
, followed by optional set of flags, widths and other sets of characters.
Last part of every specifier is its type, that being type of format and data to display.
Tip
To print number 1234
in human readable format, use specifier %d
.
With default configuration, call lwprintf_printf("%d", 1234);
and it will print "1234"
.
Check section Format specifier for list of all formats and data types
Character output function¶
API functions printing characters directly to the output stream (ex. lwprintf_printf
),
require output function to be set during initialization procedure.
Output function is called by the API for every character to be printed/transmitted by the application.
Note
- Output function is set during initialization procedure.
If not set (set as
NULL
), it is not possible to use API function which directly print characters to output stream. Application is then limited only to API functions that write formatted data to input buffer.
Notes to consider:
Output function must return same character as it was used as an input parameter to consider successful print
Output function will receive
(int)'\0'
character to indicate no more characters will follow in this API callSingle output function may be used for different LwPRINTF instances
1#include "lwprintf/lwprintf.h"
2
3/* Called for every character to be printed */
4int
5lwprintf_out(int ch, lwprintf_t* lwp) {
6 /* May use printf to output it for test */
7 if (ch != '\0') {
8 printf("%c", (char)ch);
9 }
10
11 return ch;
12}
13
14int
15main(void) {
16 /* Initialize default lwprintf instance with output function */
17 lwprintf_init(lwprintf_out);
18
19 /* Print first text */
20 lwprintf_printf("Text: %d", 10);
21}
Format specifier¶
Syntax¶
Full syntax for format specifier is
%[flags][width][.precision][length]type
Flags¶
Flags field may have zero or more characters, and in any order. List of supported flags:
Character |
Description |
---|---|
minus |
Left-align the output of this placeholder. The default is to right-align the output |
plus |
Prepends a plus for positive signed-numeric types.
positive = |
space `` `` |
Prepends a space for positive signed-numeric types.
positive = `` |
zero |
When the width option is specified, prepends zeros for numeric types. The default prepends spaces, if this flag is not set |
apostrophe |
The integer or exponent of a decimal has the thousands grouping separator applied. |
has |
Alternate form:
For |
Width¶
Width field specifies a minimum number of characters to output, and is typically used to pad fixed-width fields in tabulated output, where fields would otherwise be smaller. Please keep in mind that this parameter does not truncate output is input is longer than width field value.
Concerning width field, you may:
Ignore it completely, output does not rely on width field by any means
Write a fixed value as part of format specifier. Number must be an integer value
Use asterisk
*
char and pass number as part of parameter.printf("%3d", 6)
orprintf("%*d", 3, 6)
will generate the same output.
Tip
When fixed value is used to set width field, leading zero is not counted as part of width field, but as flag instead, indicating prepend number with leading zeros
Precision¶
Precision field usually specifies a maximum limit on the output, depending on the particular formatting type. For floating point numeric types, it specifies the number of digits to the right of the decimal point that the output should be rounded. For the string type, it limits the number of characters that should be output, after which the string is truncated.
Precision field may be omitted, or a numeric integer value, or a dynamic value when passed as another argument when indicated by an asterisk *
. For example, printf("%.*s", 3, "abcdef")
will result in abc
being printed.
Length¶
Length field may be ignored or one of the below:
Character |
Description |
---|---|
|
For integer types, causes |
|
For integer types, causes |
|
For integer types, causes |
|
For integer types, causes |
|
For floating point types, causes |
|
For integer types, causes |
|
For integer types, causes |
|
For integer types, causes |
Specifier types¶
This is a list of standard specifiers for outputting the data to the stream. Column Supported gives an overview which specifiers are actually supported by the library.
Specifier |
Supported |
Description |
---|---|---|
|
Yes |
Prints literal |
|
Yes |
Prints |
|
Yes |
Prints |
|
Yes |
Prints |
|
Yes |
Prints |
|
Yes |
Prints |
|
Yes |
Prints |
|
Yes |
Prints |
|
Yes |
Prints null terminated string |
|
Yes |
Prints |
|
Yes |
Prints |
|
Not yet |
Prints |
|
Yes |
Prints nothing but writes the number of characters successfully written so far into an integer pointer parameter |
Notes about float types¶
It is important to understand how library works under the hood to understand limitations on floating-point numbers.
When it comes to level of precision, maximum number of digits is linked to support long
or long long
integer types.
Note
When long long
type is supported by the compiler (usually part of C99 or later),
maximum number of valid digits is 18
, or 9
digits if system supports only long
data types.
If application tries to use more precision digits than maximum, remaining digits are automatically printed as all 0
.
As a consequence, output using LwPRINTF library may be different in comparison to other printf
implementations.
Tip
Float data type supports up to 7
and double up to 15
.
Additional specifier types¶
LwPRINTF implementation supports some specifiers that are usually not available in standard implementation. Those are more targeting embedded systems although they may be used in any general-purpose application
Specifier |
Description |
---|---|
|
Prints |
|
Prints |
1/* List of specifiers added in the library which are not available in standard printf implementation */
2
3#include "lwprintf/lwprintf.h"
4
5/**
6 * \brief List of additional specifiers to print
7 */
8void
9additional_format_specifiers(void) {
10 unsigned char my_array[] = { 0x01, 0x02, 0xA4, 0xB5, 0xC6 };
11
12 /* Binary output */
13
14 /* Prints number 8 in binary format, so "1000" */
15 lwprintf_printf("%b\r\n", 8U);
16 /* Prints number 16 in binary format with 10 places, so " 10000" */
17 lwprintf_printf("%10b\r\n", 16U);
18 /* Prints number 16 in binary format with 10 places, leading zeros, so "0000010000" */
19 lwprintf_printf("%010b\r\n", 16U);
20
21 /* Array outputs */
22
23 /* Fixed length with uppercase hex numbers, outputs "0102A4B5C6" */
24 lwprintf_printf("%5K\r\n", my_array);
25 /* Fixed length with lowercase hex numbers, outputs "0102a4b5c6" */
26 lwprintf_printf("%5k\r\n", my_array);
27 /* Variable length with uppercase letters, outputs "0102A4B5C6" */
28 lwprintf_printf("%*K\r\n", (int)LWPRINTF_ARRAYSIZE(my_array), my_array);
29 /* Variable length with lowercase letters, outputs "0102a4b5c6" */
30 lwprintf_printf("%*k\r\n", (int)LWPRINTF_ARRAYSIZE(my_array), my_array);
31 /* Variable length with uppercase letters and spaces, outputs "01 02 A4 B5 C6" */
32 lwprintf_printf("% *K\r\n", (int)LWPRINTF_ARRAYSIZE(my_array), my_array);
33 /* Variable length with uppercase letters and spaces, outputs "01 02 a4 b5 c6" */
34 lwprintf_printf("% *k\r\n", (int)LWPRINTF_ARRAYSIZE(my_array), my_array);
35}
LwPRINTF instances¶
LwPRINTF is very flexible and allows multiple instances for output print functions.
Note
Multiple instances with LwPRINTF are useful only with direct
print functions, suchs as lwprintf_printf
.
If application uses only format functions which write to input buffer,
it may always use default LwPRINTF instance which is
created by the library itself
Use of different instances is useful if application needs different print
configurations. Each instance has its own print_output
function,
allowing application to use multiple debug configurations (as an example)
Tip
Use functions with _ex
suffix to direcly work with custom instances.
Functions without _ex
suffix use default LwPRINTF instance
1#include "lwprintf/lwprintf.h"
2
3/* Define application custom instance */
4lwprintf_t custom_instance;
5
6/* Define custom output function for print */
7int
8custom_out(int ch, lwprintf_t* p) {
9 /* Do whatever with this character */
10 if (ch == '\0') {
11 /* This is end of string in current formatting */
12 /* Maybe time to start DMA transfer? */
13 } else {
14 /* Print or send character */
15 }
16
17 /* Return character to proceed */
18 return ch;
19}
20
21/* Define output function for default instance */
22int
23default_out(int ch, lwprintf_t* p) {
24 /* Print function for default instance */
25
26 /* See custom_out function for implementation details */
27}
28
29int
30main(void) {
31 /* Initialize default lwprintf instance with output function */
32 lwprintf_init(default_out);
33 /* Initialize custom lwprintf instance with output function */
34 lwprintf_init_ex(&custom_instance, custom_out);
35
36 /* Print first text over default output */
37 lwprintf_printf("Text: %d", 10);
38 /* Print text over custom instance */
39 lwprintf_printf_ex(&custom_instance, "Custom: %f", 3.2f);
40}
Note
It is perfectly valid to use single output function for all application instances.
Use check against input parameter for lwprintf_t
if it matches your custom LwPRINTF instance memory address
1#include "lwprintf/lwprintf.h"
2
3/* Define application custom instance */
4lwprintf_t custom_instance1;
5lwprintf_t custom_instance2;
6
7/* Define custom output function for print */
8int
9my_out(int ch, lwprintf_t* p) {
10 if (p == &custom_instance1) {
11 /* This is custom instance 1 */
12 } else if (p == &custom_instance2) {
13 /* This is custom instance 2 */
14 } else {
15 /* This is default instance */
16 }
17 return ch;
18}
19
20int
21main(void) {
22 /* Initialize default lwprintf instance with output function */
23 lwprintf_init(my_out);
24 lwprintf_init_ex(&custom_instance1, my_out);
25 lwprintf_init_ex(&custom_instance2, my_out);
26
27 /* Use print functions ... */
28}
Thread safety¶
LwPRINTF uses re-entrant functions, especially the one that format string to user application buffer. It is fully allowed to access to the same LwPRINTF instance from multiple operating-system threads.
However, when it comes to direct print functions, such as lwprintf_printf_ex()
(or any other similar),
calling those functions from multiple threads may introduce mixed output stream of data.
This is due to the fact that direct printing functions use same output function to print single character. When called from multiple threads, one thread may preempt another, causing strange output string.
1#include "lwprintf/lwprintf.h"
2
3/* Assuming LwPRINTF has been initialized before */
4
5void
6task_1(void* arg) {
7 lwprintf_printf("Hello world\r\n");
8}
9
10void
11task_2(void* arg) {
12 lwprintf_printf("This is Task 2\r\n");
13}
14
15/*
16 * If thread safety is not enabled,
17 * running above example may print:
18 *
19 * "Hello This is Task 2\r\nworld\r\n"
20 */
LwPRINTF therefore comes with a solution that introduces mutexes to lock print functions when in use from within single thread context.
Note
If application does not have any issues concerning mixed output, it is safe to disable OS support in OS environment. This will not have any negative effect on performance or memory corruption.
Tip
To enable thread-safety support, parameter LWPRINTF_CFG_OS
must be set to 1
.
Please check Configuration for more information about other options.
After thread-safety features has been enabled, it is necessary to implement
4
low-level system functions.
Tip
System function template example is available in lwprintf/src/system/
folder.
Example code for CMSIS-OS V2
Note
Check System functions section for function description
1/**
2 * \file lwprintf_sys_cmsis_os.c
3 * \brief System functions for CMSIS-OS based operating system
4 */
5
6/*
7 * Copyright (c) 2020 Tilen MAJERLE
8 *
9 * Permission is hereby granted, free of charge, to any person
10 * obtaining a copy of this software and associated documentation
11 * files (the "Software"), to deal in the Software without restriction,
12 * including without limitation the rights to use, copy, modify, merge,
13 * publish, distribute, sublicense, and/or sell copies of the Software,
14 * and to permit persons to whom the Software is furnished to do so,
15 * subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice shall be
18 * included in all copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
23 * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 * OTHER DEALINGS IN THE SOFTWARE.
28 *
29 * This file is part of LwPRINTF - Lightweight stdio manager library.
30 *
31 * Author: Tilen MAJERLE <tilen@majerle.eu>
32 * Version: v1.0.3
33 */
34#include "system/lwprintf_sys.h"
35
36#if LWPRINTF_CFG_OS && !__DOXYGEN__
37
38#include "cmsis_os.h"
39
40uint8_t
41lwprintf_sys_mutex_create(LWPRINTF_CFG_OS_MUTEX_HANDLE* m) {
42 const osMutexAttr_t attr = {
43 .name = "lwprintf_mutex",
44 };
45 return (*m = osMutexNew(&attr)) != NULL;
46}
47
48uint8_t
49lwprintf_sys_mutex_isvalid(LWPRINTF_CFG_OS_MUTEX_HANDLE* m) {
50 return *m != NULL;
51}
52
53uint8_t
54lwprintf_sys_mutex_wait(LWPRINTF_CFG_OS_MUTEX_HANDLE* m) {
55 return osMutexAcquire(*m, osWaitForever) == osOK;
56}
57
58uint8_t
59lwprintf_sys_mutex_release(LWPRINTF_CFG_OS_MUTEX_HANDLE* m) {
60 return osMutexRelease(*m) == osOK;
61}
62
63#endif /* LWPRINTF_CFG_OS && !__DOXYGEN__ */
API reference¶
List of all the modules:
LwPRINTF¶
- group LWPRINTF
Lightweight stdio manager.
Defines
-
LWPRINTF_UNUSED(x)¶
Unused variable macro.
- Parameters
x – [in] Unused variable
-
LWPRINTF_ARRAYSIZE(x)¶
Calculate size of statically allocated array.
- Parameters
x – [in] Input array
- Returns
Number of array elements
-
lwprintf_sprintf_ex(lw, s, format, ...)¶
Write formatted data from variable argument list to sized buffer.
- Parameters
lw – [inout] LwPRINTF instance. Set to
NULL
to use default instances – [in] Pointer to a buffer where the resulting C-string is stored. The buffer should have a size of at least
n
charactersformat – [in] C string that contains a format string that follows the same specifications as format in printf
... – [in] Optional arguments for format string
- Returns
The number of characters that would have been written, not counting the terminating null character.
-
lwprintf_init(out_fn)¶
Initialize default LwPRINTF instance.
- Parameters
out_fn – [in] Output function used for print operation
- Returns
1
on success,0
otherwise
-
lwprintf_vprintf(format, arg)¶
Print formatted data from variable argument list to the output with default LwPRINTF instance.
- Parameters
format – [in] C string that contains the text to be written to output
arg – [in] A value identifying a variable arguments list initialized with
va_start
.va_list
is a special type defined in<cstdarg>
.
- Returns
The number of characters that would have been written if
n
had been sufficiently large, not counting the terminating null character.
-
lwprintf_printf(format, ...)¶
Print formatted data to the output with default LwPRINTF instance.
- Parameters
format – [in] C string that contains the text to be written to output
... – [in] Optional arguments for format string
- Returns
The number of characters that would have been written if
n
had been sufficiently large, not counting the terminating null character.
-
lwprintf_vsnprintf(s, n, format, arg)¶
Write formatted data from variable argument list to sized buffer with default LwPRINTF instance.
- Parameters
s – [in] Pointer to a buffer where the resulting C-string is stored. The buffer should have a size of at least
n
charactersn – [in] Maximum number of bytes to be used in the buffer. The generated string has a length of at most
n - 1
, leaving space for the additional terminating null characterformat – [in] C string that contains a format string that follows the same specifications as format in printf
arg – [in] A value identifying a variable arguments list initialized with
va_start
.va_list
is a special type defined in<cstdarg>
.
- Returns
The number of characters that would have been written if
n
had been sufficiently large, not counting the terminating null character.
-
lwprintf_snprintf(s, n, format, ...)¶
Write formatted data from variable argument list to sized buffer with default LwPRINTF instance.
- Parameters
s – [in] Pointer to a buffer where the resulting C-string is stored. The buffer should have a size of at least
n
charactersn – [in] Maximum number of bytes to be used in the buffer. The generated string has a length of at most
n - 1
, leaving space for the additional terminating null characterformat – [in] C string that contains a format string that follows the same specifications as format in printf
... – [in] Optional arguments for format string
- Returns
The number of characters that would have been written if
n
had been sufficiently large, not counting the terminating null character.
-
lwprintf_sprintf(s, format, ...)¶
Write formatted data from variable argument list to sized buffer with default LwPRINTF instance.
- Parameters
s – [in] Pointer to a buffer where the resulting C-string is stored. The buffer should have a size of at least
n
charactersformat – [in] C string that contains a format string that follows the same specifications as format in printf
... – [in] Optional arguments for format string
- Returns
The number of characters that would have been written, not counting the terminating null character.
-
lwprintf¶
Print formatted data to the output with default LwPRINTF instance.
Note
This function is equivalent to lwprintf_printf and available only if LWPRINTF_CFG_ENABLE_SHORTNAMES is enabled
- Parameters
format – [in] C string that contains the text to be written to output
... – [in] Optional arguments for format string
- Returns
The number of characters that would have been written if
n
had been sufficiently large, not counting the terminating null character.
-
lwvprintf¶
Print formatted data from variable argument list to the output with default LwPRINTF instance.
Note
This function is equivalent to lwprintf_vprintf and available only if LWPRINTF_CFG_ENABLE_SHORTNAMES is enabled
- Parameters
format – [in] C string that contains the text to be written to output
arg – [in] A value identifying a variable arguments list initialized with
va_start
.va_list
is a special type defined in<cstdarg>
.
- Returns
The number of characters that would have been written if
n
had been sufficiently large, not counting the terminating null character.
-
lwvsnprintf¶
Write formatted data from variable argument list to sized buffer with default LwPRINTF instance.
Note
This function is equivalent to lwprintf_vsnprintf and available only if LWPRINTF_CFG_ENABLE_SHORTNAMES is enabled
- Parameters
s – [in] Pointer to a buffer where the resulting C-string is stored. The buffer should have a size of at least
n
charactersn – [in] Maximum number of bytes to be used in the buffer. The generated string has a length of at most
n - 1
, leaving space for the additional terminating null characterformat – [in] C string that contains a format string that follows the same specifications as format in printf
arg – [in] A value identifying a variable arguments list initialized with
va_start
.va_list
is a special type defined in<cstdarg>
.
- Returns
The number of characters that would have been written if
n
had been sufficiently large, not counting the terminating null character.
-
lwsnprintf¶
Write formatted data from variable argument list to sized buffer with default LwPRINTF instance.
Note
This function is equivalent to lwprintf_snprintf and available only if LWPRINTF_CFG_ENABLE_SHORTNAMES is enabled
- Parameters
s – [in] Pointer to a buffer where the resulting C-string is stored. The buffer should have a size of at least
n
charactersn – [in] Maximum number of bytes to be used in the buffer. The generated string has a length of at most
n - 1
, leaving space for the additional terminating null characterformat – [in] C string that contains a format string that follows the same specifications as format in printf
... – [in] Optional arguments for format string
- Returns
The number of characters that would have been written if
n
had been sufficiently large, not counting the terminating null character.
-
lwsprintf¶
Write formatted data from variable argument list to sized buffer with default LwPRINTF instance.
Note
This function is equivalent to lwprintf_sprintf and available only if LWPRINTF_CFG_ENABLE_SHORTNAMES is enabled
- Parameters
s – [in] Pointer to a buffer where the resulting C-string is stored. The buffer should have a size of at least
n
charactersformat – [in] C string that contains a format string that follows the same specifications as format in printf
... – [in] Optional arguments for format string
- Returns
The number of characters that would have been written, not counting the terminating null character.
-
printf¶
Print formatted data to the output with default LwPRINTF instance.
Note
This function is equivalent to lwprintf_printf and available only if LWPRINTF_CFG_ENABLE_STD_NAMES is enabled
- Parameters
format – [in] C string that contains the text to be written to output
... – [in] Optional arguments for format string
- Returns
The number of characters that would have been written if
n
had been sufficiently large, not counting the terminating null character.
-
vprintf¶
Print formatted data from variable argument list to the output with default LwPRINTF instance.
Note
This function is equivalent to lwprintf_vprintf and available only if LWPRINTF_CFG_ENABLE_STD_NAMES is enabled
- Parameters
format – [in] C string that contains the text to be written to output
arg – [in] A value identifying a variable arguments list initialized with
va_start
.va_list
is a special type defined in<cstdarg>
.
- Returns
The number of characters that would have been written if
n
had been sufficiently large, not counting the terminating null character.
-
vsnprintf¶
Write formatted data from variable argument list to sized buffer with default LwPRINTF instance.
Note
This function is equivalent to lwprintf_vsnprintf and available only if LWPRINTF_CFG_ENABLE_STD_NAMES is enabled
- Parameters
s – [in] Pointer to a buffer where the resulting C-string is stored. The buffer should have a size of at least
n
charactersn – [in] Maximum number of bytes to be used in the buffer. The generated string has a length of at most
n - 1
, leaving space for the additional terminating null characterformat – [in] C string that contains a format string that follows the same specifications as format in printf
arg – [in] A value identifying a variable arguments list initialized with
va_start
.va_list
is a special type defined in<cstdarg>
.
- Returns
The number of characters that would have been written if
n
had been sufficiently large, not counting the terminating null character.
-
snprintf¶
Write formatted data from variable argument list to sized buffer with default LwPRINTF instance.
Note
This function is equivalent to lwprintf_snprintf and available only if LWPRINTF_CFG_ENABLE_STD_NAMES is enabled
- Parameters
s – [in] Pointer to a buffer where the resulting C-string is stored. The buffer should have a size of at least
n
charactersn – [in] Maximum number of bytes to be used in the buffer. The generated string has a length of at most
n - 1
, leaving space for the additional terminating null characterformat – [in] C string that contains a format string that follows the same specifications as format in printf
... – [in] Optional arguments for format string
- Returns
The number of characters that would have been written if
n
had been sufficiently large, not counting the terminating null character.
-
sprintf¶
Write formatted data from variable argument list to sized buffer with default LwPRINTF instance.
Note
This function is equivalent to lwprintf_sprintf and available only if LWPRINTF_CFG_ENABLE_STD_NAMES is enabled
- Parameters
s – [in] Pointer to a buffer where the resulting C-string is stored. The buffer should have a size of at least
n
charactersformat – [in] C string that contains a format string that follows the same specifications as format in printf
... – [in] Optional arguments for format string
- Returns
The number of characters that would have been written, not counting the terminating null character.
Typedefs
-
typedef int (*lwprintf_output_fn)(int ch, struct lwprintf *lw)¶
Callback function for character output.
- Parameters
ch – [in] Character to print
lw – [in] LwPRINTF instance
- Returns
ch
on success,0
to terminate further string processing
Functions
-
uint8_t lwprintf_init_ex(lwprintf_t *lw, lwprintf_output_fn out_fn)¶
Initialize LwPRINTF instance.
- Parameters
lw – [inout] LwPRINTF working instance
out_fn – [in] Output function used for print operation
- Returns
1
on success,0
otherwise
-
int lwprintf_vprintf_ex(lwprintf_t *const lw, const char *format, va_list arg)¶
Print formatted data from variable argument list to the output.
- Parameters
lw – [inout] LwPRINTF instance. Set to
NULL
to use default instanceformat – [in] C string that contains the text to be written to output
arg – [in] A value identifying a variable arguments list initialized with
va_start
.va_list
is a special type defined in<cstdarg>
.
- Returns
The number of characters that would have been written if
n
had been sufficiently large, not counting the terminating null character.
-
int lwprintf_printf_ex(lwprintf_t *const lw, const char *format, ...)¶
Print formatted data to the output.
- Parameters
lw – [inout] LwPRINTF instance. Set to
NULL
to use default instanceformat – [in] C string that contains the text to be written to output
... – [in] Optional arguments for format string
- Returns
The number of characters that would have been written if
n
had been sufficiently large, not counting the terminating null character.
-
int lwprintf_vsnprintf_ex(lwprintf_t *const lw, char *s, size_t n, const char *format, va_list arg)¶
Write formatted data from variable argument list to sized buffer.
- Parameters
lw – [inout] LwPRINTF instance. Set to
NULL
to use default instances – [in] Pointer to a buffer where the resulting C-string is stored. The buffer should have a size of at least
n
charactersn – [in] Maximum number of bytes to be used in the buffer. The generated string has a length of at most
n - 1
, leaving space for the additional terminating null characterformat – [in] C string that contains a format string that follows the same specifications as format in printf
arg – [in] A value identifying a variable arguments list initialized with
va_start
.va_list
is a special type defined in<cstdarg>
.
- Returns
The number of characters that would have been written if
n
had been sufficiently large, not counting the terminating null character.
-
int lwprintf_snprintf_ex(lwprintf_t *const lw, char *s, size_t n, const char *format, ...)¶
Write formatted data from variable argument list to sized buffer.
- Parameters
lw – [inout] LwPRINTF instance. Set to
NULL
to use default instances – [in] Pointer to a buffer where the resulting C-string is stored. The buffer should have a size of at least
n
charactersn – [in] Maximum number of bytes to be used in the buffer. The generated string has a length of at most
n - 1
, leaving space for the additional terminating null characterformat – [in] C string that contains a format string that follows the same specifications as format in printf
... – [in] Optional arguments for format string
- Returns
The number of characters that would have been written if
n
had been sufficiently large, not counting the terminating null character.
-
struct lwprintf_t¶
- #include <lwprintf.h>
LwPRINTF instance.
Public Members
-
lwprintf_output_fn out_fn¶
Output function for direct print operations
-
LWPRINTF_CFG_OS_MUTEX_HANDLE mutex¶
OS mutex handle
-
lwprintf_output_fn out_fn¶
-
LWPRINTF_UNUSED(x)¶
Configuration¶
This is the default configuration of the middleware.
When any of the settings shall be modified, it shall be done in dedicated application config lwprintf_opts.h
file.
Note
Check Getting started to create configuration file.
- group LWPRINTF_OPT
LwPRINTF options.
Defines
-
LWPRINTF_CFG_OS¶
Enables
1
or disables0
operating system support in the library.Note
When
LWPRINTF_CFG_OS
is enabled, user must implement functions in System functions group.
-
LWPRINTF_CFG_OS_MUTEX_HANDLE¶
Mutex handle type.
Note
This value must be set in case LWPRINTF_CFG_OS is set to
1
. If data type is not known to compiler, include header file with definition before you define handle type
-
LWPRINTF_CFG_SUPPORT_LONG_LONG¶
Enables
1
or disables0
support forlong long int
type, signed or unsigned.
-
LWPRINTF_CFG_SUPPORT_TYPE_INT¶
Enables
1
or disables0
support for any specifier accepting any kind of integer types. This is enablingd, b, u, o, i, x
specifiers.
-
LWPRINTF_CFG_SUPPORT_TYPE_POINTER¶
Enables
1
or disables0
supportp
pointer print type.When enabled, architecture must support
uintptr_t
type, normally available with C11 standard
-
LWPRINTF_CFG_SUPPORT_TYPE_FLOAT¶
Enables
1
or disables0
supportf
float type.
-
LWPRINTF_CFG_SUPPORT_TYPE_ENGINEERING¶
Enables
1
or disables0
support fore
engineering output type for float numbers.Note
LWPRINTF_CFG_SUPPORT_TYPE_FLOAT has to be enabled to use this feature
-
LWPRINTF_CFG_SUPPORT_TYPE_STRING¶
Enables
1
or disables0
support fors
for string output.
-
LWPRINTF_CFG_SUPPORT_TYPE_BYTE_ARRAY¶
Enables
1
or disables0
support fork
for hex byte array output.
-
LWPRINTF_CFG_FLOAT_DEFAULT_PRECISION¶
Specifies default number of precision for floating number.
Represents number of digits to be used after comma if no precision is set with specifier itself
-
LWPRINTF_CFG_ENABLE_SHORTNAMES¶
Enables
1
or disables0
optional short names for LwPRINTF API functions.It adds functions for default instance:
lwprintf
,lwsnprintf
and others
-
LWPRINTF_CFG_ENABLE_STD_NAMES¶
Enables
1
or disables0
C standard API names.Disabled by default not to interfere with compiler implementation. Application may need to remove standard C STDIO library from linkage to be able to properly compile LwPRINTF with this option enabled
-
LWPRINTF_CFG_OS¶
System functions¶
System function are used in conjunction with thread safety. Please check Thread safety section for more information
- group LWPRINTF_SYS
System functions when used with operating system.
Functions
-
uint8_t lwprintf_sys_mutex_create(LWPRINTF_CFG_OS_MUTEX_HANDLE *m)¶
Create a new mutex and assign value to handle.
- Parameters
m – [out] Output variable to save mutex handle
- Returns
1
on success,0
otherwise
-
uint8_t lwprintf_sys_mutex_isvalid(LWPRINTF_CFG_OS_MUTEX_HANDLE *m)¶
Check if mutex handle is valid.
- Parameters
m – [in] Mutex handle to check if valid
- Returns
1
on success,0
otherwise
-
uint8_t lwprintf_sys_mutex_wait(LWPRINTF_CFG_OS_MUTEX_HANDLE *m)¶
Wait for a mutex until ready (unlimited time)
- Parameters
m – [in] Mutex handle to wait for
- Returns
1
on success,0
otherwise
-
uint8_t lwprintf_sys_mutex_release(LWPRINTF_CFG_OS_MUTEX_HANDLE *m)¶
Release already locked mutex.
- Parameters
m – [in] Mutex handle to release
- Returns
1
on success,0
otherwise
-
uint8_t lwprintf_sys_mutex_create(LWPRINTF_CFG_OS_MUTEX_HANDLE *m)¶
Test results¶
Library is put under several tests to ensure correct output format. Results are underneath with information about number of passed and failed tests.
Note
Majority of failed tests are linked to precision digits with floating-point based specifiers.
This is considered as OK since failures are visible at higher number of precision digits,
not affecting final results. Keep in mind that effective number of precision digits
with float
type is 7
and for double
is 15
.
With the exception to additional specifiers, supported only by LwPRINTF library,
all tests are compared against stdio printf
library included in Microsoft Visual Studio C/C++ compiler.
1------------------------
2Number of tests run: 149
3Number of tests passed: 141
4Number of tests failed: 8
5Coverage: 94.630875 %
6------------------------
7
8Negative tests
9
10----
11Format: "Precision: %3d, %20.*g"
12Params: "i, i, 432432423.342321321"
13Result VSprintf: "Precision: 19, 432432423.3423213363"
14Length VSprintf: 36
15Result LwPRINTF: "Precision: 19, 432432423.342321336"
16Length LwPRINTF: 36
17Test result: Fail
18----
19Format: "Precision: %3d, %20.*g"
20Params: "i, i, 0.0001234567"
21Result VSprintf: "Precision: 19, 0.0001234566999999999999"
22Length VSprintf: 40
23Result LwPRINTF: "Precision: 19, 0.0001234567"
24Length LwPRINTF: 36
25Test result: Fail
26----
27Format: "%.45f"
28Params: "3.23321321"
29Result VSprintf: "3.233213210000000170651901498786173760890960693"
30Length VSprintf: 47
31Result LwPRINTF: "3.233213210000000160000000000000000000000000000"
32Length LwPRINTF: 47
33Test result: Fail
34----
35Format: "%.45F"
36Params: "3.23321321"
37Result VSprintf: "3.233213210000000170651901498786173760890960693"
38Length VSprintf: 47
39Result LwPRINTF: "3.233213210000000160000000000000000000000000000"
40Length LwPRINTF: 47
41Test result: Fail
42----
43Format: "%22.33e"
44Params: "123.456"
45Result VSprintf: "1.234560000000000030695446184836328e+02"
46Length VSprintf: 39
47Result LwPRINTF: "1.234560000000000096000000000000000e+02"
48Length LwPRINTF: 39
49Test result: Fail
50----
51Format: "%22.33e"
52Params: "-123.456"
53Result VSprintf: "-1.234560000000000030695446184836328e+02"
54Length VSprintf: 40
55Result LwPRINTF: "-1.234560000000000096000000000000000e+02"
56Length LwPRINTF: 40
57Test result: Fail
58----
59Format: "%22.33e"
60Params: "0.123456"
61Result VSprintf: "1.234559999999999962971841682701779e-01"
62Length VSprintf: 39
63Result LwPRINTF: "1.234559999999999872000000000000000e-01"
64Length LwPRINTF: 39
65Test result: Fail
66----
67Format: "%22.33e"
68Params: "-0.123456"
69Result VSprintf: "-1.234559999999999962971841682701779e-01"
70Length VSprintf: 40
71Result LwPRINTF: "-1.234559999999999872000000000000000e-01"
72Length LwPRINTF: 40
73Test result: Fail
74------------------------
75
76Positive tests
77
78----
79Format: "Precision: %3d, %.*g"
80Params: "17, 17, 0.0001234567"
81Result VSprintf: "Precision: 17, 0.0001234567"
82Length VSprintf: 28
83Result LwPRINTF: "Precision: 17, 0.0001234567"
84Length LwPRINTF: 28
85Test result: Pass
86----
87Format: "Precision: %3d, %20.*g"
88Params: "i, i, 432432423.342321321"
89Result VSprintf: "Precision: 0, 4e+08"
90Length VSprintf: 36
91Result LwPRINTF: "Precision: 0, 4e+08"
92Length LwPRINTF: 36
93Test result: Pass
94----
95Format: "Precision: %3d, %20.*g"
96Params: "i, i, 432432423.342321321"
97Result VSprintf: "Precision: 1, 4e+08"
98Length VSprintf: 36
99Result LwPRINTF: "Precision: 1, 4e+08"
100Length LwPRINTF: 36
101Test result: Pass
102----
103Format: "Precision: %3d, %20.*g"
104Params: "i, i, 432432423.342321321"
105Result VSprintf: "Precision: 2, 4.3e+08"
106Length VSprintf: 36
107Result LwPRINTF: "Precision: 2, 4.3e+08"
108Length LwPRINTF: 36
109Test result: Pass
110----
111Format: "Precision: %3d, %20.*g"
112Params: "i, i, 432432423.342321321"
113Result VSprintf: "Precision: 3, 4.32e+08"
114Length VSprintf: 36
115Result LwPRINTF: "Precision: 3, 4.32e+08"
116Length LwPRINTF: 36
117Test result: Pass
118----
119Format: "Precision: %3d, %20.*g"
120Params: "i, i, 432432423.342321321"
121Result VSprintf: "Precision: 4, 4.324e+08"
122Length VSprintf: 36
123Result LwPRINTF: "Precision: 4, 4.324e+08"
124Length LwPRINTF: 36
125Test result: Pass
126----
127Format: "Precision: %3d, %20.*g"
128Params: "i, i, 432432423.342321321"
129Result VSprintf: "Precision: 5, 4.3243e+08"
130Length VSprintf: 36
131Result LwPRINTF: "Precision: 5, 4.3243e+08"
132Length LwPRINTF: 36
133Test result: Pass
134----
135Format: "Precision: %3d, %20.*g"
136Params: "i, i, 432432423.342321321"
137Result VSprintf: "Precision: 6, 4.32432e+08"
138Length VSprintf: 36
139Result LwPRINTF: "Precision: 6, 4.32432e+08"
140Length LwPRINTF: 36
141Test result: Pass
142----
143Format: "Precision: %3d, %20.*g"
144Params: "i, i, 432432423.342321321"
145Result VSprintf: "Precision: 7, 4.324324e+08"
146Length VSprintf: 36
147Result LwPRINTF: "Precision: 7, 4.324324e+08"
148Length LwPRINTF: 36
149Test result: Pass
150----
151Format: "Precision: %3d, %20.*g"
152Params: "i, i, 432432423.342321321"
153Result VSprintf: "Precision: 8, 4.3243242e+08"
154Length VSprintf: 36
155Result LwPRINTF: "Precision: 8, 4.3243242e+08"
156Length LwPRINTF: 36
157Test result: Pass
158----
159Format: "Precision: %3d, %20.*g"
160Params: "i, i, 432432423.342321321"
161Result VSprintf: "Precision: 9, 432432423"
162Length VSprintf: 36
163Result LwPRINTF: "Precision: 9, 432432423"
164Length LwPRINTF: 36
165Test result: Pass
166----
167Format: "Precision: %3d, %20.*g"
168Params: "i, i, 432432423.342321321"
169Result VSprintf: "Precision: 10, 432432423.3"
170Length VSprintf: 36
171Result LwPRINTF: "Precision: 10, 432432423.3"
172Length LwPRINTF: 36
173Test result: Pass
174----
175Format: "Precision: %3d, %20.*g"
176Params: "i, i, 432432423.342321321"
177Result VSprintf: "Precision: 11, 432432423.34"
178Length VSprintf: 36
179Result LwPRINTF: "Precision: 11, 432432423.34"
180Length LwPRINTF: 36
181Test result: Pass
182----
183Format: "Precision: %3d, %20.*g"
184Params: "i, i, 432432423.342321321"
185Result VSprintf: "Precision: 12, 432432423.342"
186Length VSprintf: 36
187Result LwPRINTF: "Precision: 12, 432432423.342"
188Length LwPRINTF: 36
189Test result: Pass
190----
191Format: "Precision: %3d, %20.*g"
192Params: "i, i, 432432423.342321321"
193Result VSprintf: "Precision: 13, 432432423.3423"
194Length VSprintf: 36
195Result LwPRINTF: "Precision: 13, 432432423.3423"
196Length LwPRINTF: 36
197Test result: Pass
198----
199Format: "Precision: %3d, %20.*g"
200Params: "i, i, 432432423.342321321"
201Result VSprintf: "Precision: 14, 432432423.34232"
202Length VSprintf: 36
203Result LwPRINTF: "Precision: 14, 432432423.34232"
204Length LwPRINTF: 36
205Test result: Pass
206----
207Format: "Precision: %3d, %20.*g"
208Params: "i, i, 432432423.342321321"
209Result VSprintf: "Precision: 15, 432432423.342321"
210Length VSprintf: 36
211Result LwPRINTF: "Precision: 15, 432432423.342321"
212Length LwPRINTF: 36
213Test result: Pass
214----
215Format: "Precision: %3d, %20.*g"
216Params: "i, i, 432432423.342321321"
217Result VSprintf: "Precision: 16, 432432423.3423213"
218Length VSprintf: 36
219Result LwPRINTF: "Precision: 16, 432432423.3423213"
220Length LwPRINTF: 36
221Test result: Pass
222----
223Format: "Precision: %3d, %20.*g"
224Params: "i, i, 432432423.342321321"
225Result VSprintf: "Precision: 17, 432432423.34232134"
226Length VSprintf: 36
227Result LwPRINTF: "Precision: 17, 432432423.34232134"
228Length LwPRINTF: 36
229Test result: Pass
230----
231Format: "Precision: %3d, %20.*g"
232Params: "i, i, 432432423.342321321"
233Result VSprintf: "Precision: 18, 432432423.342321336"
234Length VSprintf: 36
235Result LwPRINTF: "Precision: 18, 432432423.342321336"
236Length LwPRINTF: 36
237Test result: Pass
238----
239Format: "Precision: %3d, %20.*g"
240Params: "i, i, 0.0001234567"
241Result VSprintf: "Precision: 0, 0.0001"
242Length VSprintf: 36
243Result LwPRINTF: "Precision: 0, 0.0001"
244Length LwPRINTF: 36
245Test result: Pass
246----
247Format: "Precision: %3d, %20.*g"
248Params: "i, i, 0.0001234567"
249Result VSprintf: "Precision: 1, 0.0001"
250Length VSprintf: 36
251Result LwPRINTF: "Precision: 1, 0.0001"
252Length LwPRINTF: 36
253Test result: Pass
254----
255Format: "Precision: %3d, %20.*g"
256Params: "i, i, 0.0001234567"
257Result VSprintf: "Precision: 2, 0.00012"
258Length VSprintf: 36
259Result LwPRINTF: "Precision: 2, 0.00012"
260Length LwPRINTF: 36
261Test result: Pass
262----
263Format: "Precision: %3d, %20.*g"
264Params: "i, i, 0.0001234567"
265Result VSprintf: "Precision: 3, 0.000123"
266Length VSprintf: 36
267Result LwPRINTF: "Precision: 3, 0.000123"
268Length LwPRINTF: 36
269Test result: Pass
270----
271Format: "Precision: %3d, %20.*g"
272Params: "i, i, 0.0001234567"
273Result VSprintf: "Precision: 4, 0.0001235"
274Length VSprintf: 36
275Result LwPRINTF: "Precision: 4, 0.0001235"
276Length LwPRINTF: 36
277Test result: Pass
278----
279Format: "Precision: %3d, %20.*g"
280Params: "i, i, 0.0001234567"
281Result VSprintf: "Precision: 5, 0.00012346"
282Length VSprintf: 36
283Result LwPRINTF: "Precision: 5, 0.00012346"
284Length LwPRINTF: 36
285Test result: Pass
286----
287Format: "Precision: %3d, %20.*g"
288Params: "i, i, 0.0001234567"
289Result VSprintf: "Precision: 6, 0.000123457"
290Length VSprintf: 36
291Result LwPRINTF: "Precision: 6, 0.000123457"
292Length LwPRINTF: 36
293Test result: Pass
294----
295Format: "Precision: %3d, %20.*g"
296Params: "i, i, 0.0001234567"
297Result VSprintf: "Precision: 7, 0.0001234567"
298Length VSprintf: 36
299Result LwPRINTF: "Precision: 7, 0.0001234567"
300Length LwPRINTF: 36
301Test result: Pass
302----
303Format: "Precision: %3d, %20.*g"
304Params: "i, i, 0.0001234567"
305Result VSprintf: "Precision: 8, 0.0001234567"
306Length VSprintf: 36
307Result LwPRINTF: "Precision: 8, 0.0001234567"
308Length LwPRINTF: 36
309Test result: Pass
310----
311Format: "Precision: %3d, %20.*g"
312Params: "i, i, 0.0001234567"
313Result VSprintf: "Precision: 9, 0.0001234567"
314Length VSprintf: 36
315Result LwPRINTF: "Precision: 9, 0.0001234567"
316Length LwPRINTF: 36
317Test result: Pass
318----
319Format: "Precision: %3d, %20.*g"
320Params: "i, i, 0.0001234567"
321Result VSprintf: "Precision: 10, 0.0001234567"
322Length VSprintf: 36
323Result LwPRINTF: "Precision: 10, 0.0001234567"
324Length LwPRINTF: 36
325Test result: Pass
326----
327Format: "Precision: %3d, %20.*g"
328Params: "i, i, 0.0001234567"
329Result VSprintf: "Precision: 11, 0.0001234567"
330Length VSprintf: 36
331Result LwPRINTF: "Precision: 11, 0.0001234567"
332Length LwPRINTF: 36
333Test result: Pass
334----
335Format: "Precision: %3d, %20.*g"
336Params: "i, i, 0.0001234567"
337Result VSprintf: "Precision: 12, 0.0001234567"
338Length VSprintf: 36
339Result LwPRINTF: "Precision: 12, 0.0001234567"
340Length LwPRINTF: 36
341Test result: Pass
342----
343Format: "Precision: %3d, %20.*g"
344Params: "i, i, 0.0001234567"
345Result VSprintf: "Precision: 13, 0.0001234567"
346Length VSprintf: 36
347Result LwPRINTF: "Precision: 13, 0.0001234567"
348Length LwPRINTF: 36
349Test result: Pass
350----
351Format: "Precision: %3d, %20.*g"
352Params: "i, i, 0.0001234567"
353Result VSprintf: "Precision: 14, 0.0001234567"
354Length VSprintf: 36
355Result LwPRINTF: "Precision: 14, 0.0001234567"
356Length LwPRINTF: 36
357Test result: Pass
358----
359Format: "Precision: %3d, %20.*g"
360Params: "i, i, 0.0001234567"
361Result VSprintf: "Precision: 15, 0.0001234567"
362Length VSprintf: 36
363Result LwPRINTF: "Precision: 15, 0.0001234567"
364Length LwPRINTF: 36
365Test result: Pass
366----
367Format: "Precision: %3d, %20.*g"
368Params: "i, i, 0.0001234567"
369Result VSprintf: "Precision: 16, 0.0001234567"
370Length VSprintf: 36
371Result LwPRINTF: "Precision: 16, 0.0001234567"
372Length LwPRINTF: 36
373Test result: Pass
374----
375Format: "Precision: %3d, %20.*g"
376Params: "i, i, 0.0001234567"
377Result VSprintf: "Precision: 17, 0.0001234567"
378Length VSprintf: 36
379Result LwPRINTF: "Precision: 17, 0.0001234567"
380Length LwPRINTF: 36
381Test result: Pass
382----
383Format: "Precision: %3d, %20.*g"
384Params: "i, i, 0.0001234567"
385Result VSprintf: "Precision: 18, 0.0001234567"
386Length VSprintf: 36
387Result LwPRINTF: "Precision: 18, 0.0001234567"
388Length LwPRINTF: 36
389Test result: Pass
390----
391Format: "%.4f"
392Params: "3.23321321"
393Result VSprintf: "3.2332"
394Length VSprintf: 6
395Result LwPRINTF: "3.2332"
396Length LwPRINTF: 6
397Test result: Pass
398----
399Format: "%.4F"
400Params: "3.23321321"
401Result VSprintf: "3.2332"
402Length VSprintf: 6
403Result LwPRINTF: "3.2332"
404Length LwPRINTF: 6
405Test result: Pass
406----
407Format: "%g"
408Params: "1.23342"
409Result VSprintf: "1.23342"
410Length VSprintf: 7
411Result LwPRINTF: "1.23342"
412Length LwPRINTF: 7
413Test result: Pass
414----
415Format: "%g"
416Params: "12334.2"
417Result VSprintf: "12334.2"
418Length VSprintf: 7
419Result LwPRINTF: "12334.2"
420Length LwPRINTF: 7
421Test result: Pass
422----
423Format: "%.8g"
424Params: "0.000000123342"
425Result VSprintf: "1.23342e-07"
426Length VSprintf: 11
427Result LwPRINTF: "1.23342e-07"
428Length LwPRINTF: 11
429Test result: Pass
430----
431Format: "%.8G"
432Params: "0.000000123342"
433Result VSprintf: "1.23342E-07"
434Length VSprintf: 11
435Result LwPRINTF: "1.23342E-07"
436Length LwPRINTF: 11
437Test result: Pass
438----
439Format: "%.4f"
440Params: "323243432432432.432"
441Result VSprintf: "323243432432432.4375"
442Length VSprintf: 20
443Result LwPRINTF: "323243432432432.4375"
444Length LwPRINTF: 20
445Test result: Pass
446----
447Format: "%e"
448Params: "-123.456"
449Result VSprintf: "-1.234560e+02"
450Length VSprintf: 13
451Result LwPRINTF: "-1.234560e+02"
452Length LwPRINTF: 13
453Test result: Pass
454----
455Format: "%e"
456Params: "0.000001"
457Result VSprintf: "1.000000e-06"
458Length VSprintf: 12
459Result LwPRINTF: "1.000000e-06"
460Length LwPRINTF: 12
461Test result: Pass
462----
463Format: "%e"
464Params: "0.123456"
465Result VSprintf: "1.234560e-01"
466Length VSprintf: 12
467Result LwPRINTF: "1.234560e-01"
468Length LwPRINTF: 12
469Test result: Pass
470----
471Format: "%e"
472Params: "-0.123456"
473Result VSprintf: "-1.234560e-01"
474Length VSprintf: 13
475Result LwPRINTF: "-1.234560e-01"
476Length LwPRINTF: 13
477Test result: Pass
478----
479Format: "%.4e"
480Params: "123.456"
481Result VSprintf: "1.2346e+02"
482Length VSprintf: 10
483Result LwPRINTF: "1.2346e+02"
484Length LwPRINTF: 10
485Test result: Pass
486----
487Format: "%.4e"
488Params: "-123.456"
489Result VSprintf: "-1.2346e+02"
490Length VSprintf: 11
491Result LwPRINTF: "-1.2346e+02"
492Length LwPRINTF: 11
493Test result: Pass
494----
495Format: "%.4e"
496Params: "0.123456"
497Result VSprintf: "1.2346e-01"
498Length VSprintf: 10
499Result LwPRINTF: "1.2346e-01"
500Length LwPRINTF: 10
501Test result: Pass
502----
503Format: "%.4e"
504Params: "-0.123456"
505Result VSprintf: "-1.2346e-01"
506Length VSprintf: 11
507Result LwPRINTF: "-1.2346e-01"
508Length LwPRINTF: 11
509Test result: Pass
510----
511Format: "%.0e"
512Params: "123.456"
513Result VSprintf: "1e+02"
514Length VSprintf: 5
515Result LwPRINTF: "1e+02"
516Length LwPRINTF: 5
517Test result: Pass
518----
519Format: "%.0e"
520Params: "-123.456"
521Result VSprintf: "-1e+02"
522Length VSprintf: 6
523Result LwPRINTF: "-1e+02"
524Length LwPRINTF: 6
525Test result: Pass
526----
527Format: "%.0e"
528Params: "0.123456"
529Result VSprintf: "1e-01"
530Length VSprintf: 5
531Result LwPRINTF: "1e-01"
532Length LwPRINTF: 5
533Test result: Pass
534----
535Format: "%.0e"
536Params: "-0.123456"
537Result VSprintf: "-1e-01"
538Length VSprintf: 6
539Result LwPRINTF: "-1e-01"
540Length LwPRINTF: 6
541Test result: Pass
542----
543Format: "%22.4e"
544Params: "123.456"
545Result VSprintf: " 1.2346e+02"
546Length VSprintf: 22
547Result LwPRINTF: " 1.2346e+02"
548Length LwPRINTF: 22
549Test result: Pass
550----
551Format: "%22.4e"
552Params: "-123.456"
553Result VSprintf: " -1.2346e+02"
554Length VSprintf: 22
555Result LwPRINTF: " -1.2346e+02"
556Length LwPRINTF: 22
557Test result: Pass
558----
559Format: "%22.4e"
560Params: "0.123456"
561Result VSprintf: " 1.2346e-01"
562Length VSprintf: 22
563Result LwPRINTF: " 1.2346e-01"
564Length LwPRINTF: 22
565Test result: Pass
566----
567Format: "%22.4e"
568Params: "-0.123456"
569Result VSprintf: " -1.2346e-01"
570Length VSprintf: 22
571Result LwPRINTF: " -1.2346e-01"
572Length LwPRINTF: 22
573Test result: Pass
574----
575Format: "%022.4e"
576Params: "123.456"
577Result VSprintf: "0000000000001.2346e+02"
578Length VSprintf: 22
579Result LwPRINTF: "0000000000001.2346e+02"
580Length LwPRINTF: 22
581Test result: Pass
582----
583Format: "%022.4e"
584Params: "-123.456"
585Result VSprintf: "-000000000001.2346e+02"
586Length VSprintf: 22
587Result LwPRINTF: "-000000000001.2346e+02"
588Length LwPRINTF: 22
589Test result: Pass
590----
591Format: "%022.4e"
592Params: "0.123456"
593Result VSprintf: "0000000000001.2346e-01"
594Length VSprintf: 22
595Result LwPRINTF: "0000000000001.2346e-01"
596Length LwPRINTF: 22
597Test result: Pass
598----
599Format: "%e"
600Params: "0.00000000123456"
601Result VSprintf: "1.234560e-09"
602Length VSprintf: 12
603Result LwPRINTF: "1.234560e-09"
604Length LwPRINTF: 12
605Test result: Pass
606----
607Format: "%022.4e"
608Params: "-0.123456"
609Result VSprintf: "-000000000001.2346e-01"
610Length VSprintf: 22
611Result LwPRINTF: "-000000000001.2346e-01"
612Length LwPRINTF: 22
613Test result: Pass
614----
615Format: "%.4E"
616Params: "-123.456"
617Result VSprintf: "-1.2346E+02"
618Length VSprintf: 11
619Result LwPRINTF: "-1.2346E+02"
620Length LwPRINTF: 11
621Test result: Pass
622----
623Format: "% 3u"
624Params: "(unsigned)28"
625Result VSprintf: " 28"
626Length VSprintf: 3
627Result LwPRINTF: " 28"
628Length LwPRINTF: 3
629Test result: Pass
630----
631Format: "% 3u"
632Params: "(unsigned)123456"
633Result VSprintf: "123456"
634Length VSprintf: 6
635Result LwPRINTF: "123456"
636Length LwPRINTF: 6
637Test result: Pass
638----
639Format: "%03d"
640Params: "28"
641Result VSprintf: "028"
642Length VSprintf: 3
643Result LwPRINTF: "028"
644Length LwPRINTF: 3
645Test result: Pass
646----
647Format: "%+03d"
648Params: "28"
649Result VSprintf: "+28"
650Length VSprintf: 3
651Result LwPRINTF: "+28"
652Length LwPRINTF: 3
653Test result: Pass
654----
655Format: "%+3d"
656Params: "28"
657Result VSprintf: "+28"
658Length VSprintf: 3
659Result LwPRINTF: "+28"
660Length LwPRINTF: 3
661Test result: Pass
662----
663Format: "%03d"
664Params: "-28"
665Result VSprintf: "-28"
666Length VSprintf: 3
667Result LwPRINTF: "-28"
668Length LwPRINTF: 3
669Test result: Pass
670----
671Format: "%+03d"
672Params: "-28"
673Result VSprintf: "-28"
674Length VSprintf: 3
675Result LwPRINTF: "-28"
676Length LwPRINTF: 3
677Test result: Pass
678----
679Format: "%+3d"
680Params: "-28"
681Result VSprintf: "-28"
682Length VSprintf: 3
683Result LwPRINTF: "-28"
684Length LwPRINTF: 3
685Test result: Pass
686----
687Format: "%03u"
688Params: "(unsigned)123456"
689Result VSprintf: "123456"
690Length VSprintf: 6
691Result LwPRINTF: "123456"
692Length LwPRINTF: 6
693Test result: Pass
694----
695Format: "%-010uabc"
696Params: "(unsigned)123456"
697Result VSprintf: "123456 abc"
698Length VSprintf: 13
699Result LwPRINTF: "123456 abc"
700Length LwPRINTF: 13
701Test result: Pass
702----
703Format: "%010uabc"
704Params: "(unsigned)123456"
705Result VSprintf: "0000123456abc"
706Length VSprintf: 13
707Result LwPRINTF: "0000123456abc"
708Length LwPRINTF: 13
709Test result: Pass
710----
711Format: "%-10d"
712Params: "-123"
713Result VSprintf: "-123 "
714Length VSprintf: 10
715Result LwPRINTF: "-123 "
716Length LwPRINTF: 10
717Test result: Pass
718----
719Format: "%10d"
720Params: "-123"
721Result VSprintf: " -123"
722Length VSprintf: 10
723Result LwPRINTF: " -123"
724Length LwPRINTF: 10
725Test result: Pass
726----
727Format: "%-06d"
728Params: "-1234567"
729Result VSprintf: "-1234567"
730Length VSprintf: 8
731Result LwPRINTF: "-1234567"
732Length LwPRINTF: 8
733Test result: Pass
734----
735Format: "%06d"
736Params: "-1234567"
737Result VSprintf: "-1234567"
738Length VSprintf: 8
739Result LwPRINTF: "-1234567"
740Length LwPRINTF: 8
741Test result: Pass
742----
743Format: "%-10d"
744Params: "-1234567"
745Result VSprintf: "-1234567 "
746Length VSprintf: 10
747Result LwPRINTF: "-1234567 "
748Length LwPRINTF: 10
749Test result: Pass
750----
751Format: "%10d"
752Params: "-1234567"
753Result VSprintf: " -1234567"
754Length VSprintf: 10
755Result LwPRINTF: " -1234567"
756Length LwPRINTF: 10
757Test result: Pass
758----
759Format: "%-010d"
760Params: "-1234567"
761Result VSprintf: "-1234567 "
762Length VSprintf: 10
763Result LwPRINTF: "-1234567 "
764Length LwPRINTF: 10
765Test result: Pass
766----
767Format: "%010d"
768Params: "-1234567"
769Result VSprintf: "-001234567"
770Length VSprintf: 10
771Result LwPRINTF: "-001234567"
772Length LwPRINTF: 10
773Test result: Pass
774----
775Format: "%s"
776Params: ""This is my string""
777Result VSprintf: "This is my string"
778Length VSprintf: 17
779Result LwPRINTF: "This is my string"
780Length LwPRINTF: 17
781Test result: Pass
782----
783Format: "%10s"
784Params: ""This is my string""
785Result VSprintf: "This is my string"
786Length VSprintf: 17
787Result LwPRINTF: "This is my string"
788Length LwPRINTF: 17
789Test result: Pass
790----
791Format: "%0*d"
792Params: "10, -123"
793Result VSprintf: "-000000123"
794Length VSprintf: 10
795Result LwPRINTF: "-000000123"
796Length LwPRINTF: 10
797Test result: Pass
798----
799Format: "%zu"
800Params: "(size_t)10"
801Result VSprintf: "10"
802Length VSprintf: 2
803Result LwPRINTF: "10"
804Length LwPRINTF: 2
805Test result: Pass
806----
807Format: "%ju"
808Params: "(uintmax_t)10"
809Result VSprintf: "10"
810Length VSprintf: 2
811Result LwPRINTF: "10"
812Length LwPRINTF: 2
813Test result: Pass
814----
815Format: "% d"
816Params: "1024"
817Result VSprintf: " 1024"
818Length VSprintf: 5
819Result LwPRINTF: " 1024"
820Length LwPRINTF: 5
821Test result: Pass
822----
823Format: "% 4d"
824Params: "1024"
825Result VSprintf: " 1024"
826Length VSprintf: 5
827Result LwPRINTF: " 1024"
828Length LwPRINTF: 5
829Test result: Pass
830----
831Format: "% 3d"
832Params: "1024"
833Result VSprintf: " 1024"
834Length VSprintf: 5
835Result LwPRINTF: " 1024"
836Length LwPRINTF: 5
837Test result: Pass
838----
839Format: "% 3f"
840Params: "32.687"
841Result VSprintf: " 32.687000"
842Length VSprintf: 10
843Result LwPRINTF: " 32.687000"
844Length LwPRINTF: 10
845Test result: Pass
846----
847Format: "%*.*s"
848Params: "8, 12, "This is my string""
849Result VSprintf: "This is my s"
850Length VSprintf: 12
851Result LwPRINTF: "This is my s"
852Length LwPRINTF: 12
853Test result: Pass
854----
855Format: "%*.*s"
856Params: "8, 12, "Stri""
857Result VSprintf: " Stri"
858Length VSprintf: 8
859Result LwPRINTF: " Stri"
860Length LwPRINTF: 8
861Test result: Pass
862----
863Format: "%-6.10s"
864Params: ""This is my string""
865Result VSprintf: "This is my"
866Length VSprintf: 10
867Result LwPRINTF: "This is my"
868Length LwPRINTF: 10
869Test result: Pass
870----
871Format: "%6.10s"
872Params: ""This is my string""
873Result VSprintf: "This is my"
874Length VSprintf: 10
875Result LwPRINTF: "This is my"
876Length LwPRINTF: 10
877Test result: Pass
878----
879Format: "%-6.10s"
880Params: ""This is my string""
881Result VSprintf: "This is my"
882Length VSprintf: 10
883Result LwPRINTF: "This is my"
884Length LwPRINTF: 10
885Test result: Pass
886----
887Format: "%6.10s"
888Params: ""Th""
889Result VSprintf: " Th"
890Length VSprintf: 6
891Result LwPRINTF: " Th"
892Length LwPRINTF: 6
893Test result: Pass
894----
895Format: "%-6.10s"
896Params: ""Th""
897Result VSprintf: "Th "
898Length VSprintf: 6
899Result LwPRINTF: "Th "
900Length LwPRINTF: 6
901Test result: Pass
902----
903Format: "%*.*s"
904Params: "-6, 10, "Th""
905Result VSprintf: "Th "
906Length VSprintf: 6
907Result LwPRINTF: "Th "
908Length LwPRINTF: 6
909Test result: Pass
910----
911Format: "%*.*s"
912Params: "6, 10, "Th""
913Result VSprintf: " Th"
914Length VSprintf: 6
915Result LwPRINTF: " Th"
916Length LwPRINTF: 6
917Test result: Pass
918----
919Format: "%.4s"
920Params: ""This is my string""
921Result VSprintf: "This"
922Length VSprintf: 4
923Result LwPRINTF: "This"
924Length LwPRINTF: 4
925Test result: Pass
926----
927Format: "%.6s"
928Params: ""1234""
929Result VSprintf: "1234"
930Length VSprintf: 4
931Result LwPRINTF: "1234"
932Length LwPRINTF: 4
933Test result: Pass
934----
935Format: "%.4s"
936Params: ""stri""
937Result VSprintf: "stri"
938Length VSprintf: 4
939Result LwPRINTF: "stri"
940Length LwPRINTF: 4
941Test result: Pass
942----
943Format: "%.4s%.2s"
944Params: ""123456", "abcdef""
945Result VSprintf: "1234ab"
946Length VSprintf: 6
947Result LwPRINTF: "1234ab"
948Length LwPRINTF: 6
949Test result: Pass
950----
951Format: "%.4.2s"
952Params: ""123456""
953Result VSprintf: ".2s"
954Length VSprintf: 3
955Result LwPRINTF: ".2s"
956Length LwPRINTF: 3
957Test result: Pass
958----
959Format: "%.*s"
960Params: "3, "123456""
961Result VSprintf: "123"
962Length VSprintf: 3
963Result LwPRINTF: "123"
964Length LwPRINTF: 3
965Test result: Pass
966----
967Format: "%.3s"
968Params: """"
969Result VSprintf: ""
970Length VSprintf: 0
971Result LwPRINTF: ""
972Length LwPRINTF: 0
973Test result: Pass
974----
975Format: "%yunknown"
976Params: """"
977Result VSprintf: "yunknown"
978Length VSprintf: 8
979Result LwPRINTF: "yunknown"
980Length LwPRINTF: 8
981Test result: Pass
982----
983Format: "%#2X"
984Params: "123"
985Result VSprintf: "0X7B"
986Length VSprintf: 4
987Result LwPRINTF: "0X7B"
988Length LwPRINTF: 4
989Test result: Pass
990----
991Format: "%#2x"
992Params: "123"
993Result VSprintf: "0x7b"
994Length VSprintf: 4
995Result LwPRINTF: "0x7b"
996Length LwPRINTF: 4
997Test result: Pass
998----
999Format: "%#2o"
1000Params: "123"
1001Result VSprintf: "0173"
1002Length VSprintf: 4
1003Result LwPRINTF: "0173"
1004Length LwPRINTF: 4
1005Test result: Pass
1006----
1007Format: "%#2X"
1008Params: "1"
1009Result VSprintf: "0X1"
1010Length VSprintf: 3
1011Result LwPRINTF: "0X1"
1012Length LwPRINTF: 3
1013Test result: Pass
1014----
1015Format: "%#2x"
1016Params: "1"
1017Result VSprintf: "0x1"
1018Length VSprintf: 3
1019Result LwPRINTF: "0x1"
1020Length LwPRINTF: 3
1021Test result: Pass
1022----
1023Format: "%#2o"
1024Params: "1"
1025Result VSprintf: "01"
1026Length VSprintf: 2
1027Result LwPRINTF: "01"
1028Length LwPRINTF: 2
1029Test result: Pass
1030----
1031Format: "%#2X"
1032Params: "0"
1033Result VSprintf: " 0"
1034Length VSprintf: 2
1035Result LwPRINTF: " 0"
1036Length LwPRINTF: 2
1037Test result: Pass
1038----
1039Format: "%#2x"
1040Params: "0"
1041Result VSprintf: " 0"
1042Length VSprintf: 2
1043Result LwPRINTF: " 0"
1044Length LwPRINTF: 2
1045Test result: Pass
1046----
1047Format: "%#2o"
1048Params: "0"
1049Result VSprintf: " 0"
1050Length VSprintf: 2
1051Result LwPRINTF: " 0"
1052Length LwPRINTF: 2
1053Test result: Pass
1054----
1055Format: "%p"
1056Params: "&tests_passed"
1057Result VSprintf: "00BE0FD4"
1058Length VSprintf: 8
1059Result LwPRINTF: "00BE0FD4"
1060Length LwPRINTF: 8
1061Test result: Pass
1062----
1063Format: "0X%p"
1064Params: "&tests_passed"
1065Result VSprintf: "0X00BE0FD4"
1066Length VSprintf: 10
1067Result LwPRINTF: "0X00BE0FD4"
1068Length LwPRINTF: 10
1069Test result: Pass
1070----
1071Format: "0x%p"
1072Params: "&tests_passed"
1073Result VSprintf: "0x00BE0FD4"
1074Length VSprintf: 10
1075Result LwPRINTF: "0x00BE0FD4"
1076Length LwPRINTF: 10
1077Test result: Pass
1078----
1079Format: "%llb abc"
1080Params: "123"
1081Result expected: "1111011 abc"
1082Length expected: 11
1083Result LwPRINTF: "1111011 abc"
1084Length LwPRINTF: 11
1085Test result: Pass
1086----
1087Format: "%b"
1088Params: "4"
1089Result expected: "100"
1090Length expected: 3
1091Result LwPRINTF: "100"
1092Length LwPRINTF: 3
1093Test result: Pass
1094----
1095Format: "%#2B"
1096Params: "1"
1097Result expected: "0B1"
1098Length expected: 3
1099Result LwPRINTF: "0B1"
1100Length LwPRINTF: 3
1101Test result: Pass
1102----
1103Format: "%#2b"
1104Params: "1"
1105Result expected: "0b1"
1106Length expected: 3
1107Result LwPRINTF: "0b1"
1108Length LwPRINTF: 3
1109Test result: Pass
1110----
1111Format: "%#2B"
1112Params: "0"
1113Result expected: " 0"
1114Length expected: 2
1115Result LwPRINTF: " 0"
1116Length LwPRINTF: 2
1117Test result: Pass
1118----
1119Format: "%#2b"
1120Params: "0"
1121Result expected: " 0"
1122Length expected: 2
1123Result LwPRINTF: " 0"
1124Length LwPRINTF: 2
1125Test result: Pass
1126----
1127Format: "%#B"
1128Params: "0"
1129Result expected: "0"
1130Length expected: 1
1131Result LwPRINTF: "0"
1132Length LwPRINTF: 1
1133Test result: Pass
1134----
1135Format: "%#b"
1136Params: "0"
1137Result expected: "0"
1138Length expected: 1
1139Result LwPRINTF: "0"
1140Length LwPRINTF: 1
1141Test result: Pass
1142----
1143Format: "%#B"
1144Params: "6"
1145Result expected: "0B110"
1146Length expected: 5
1147Result LwPRINTF: "0B110"
1148Length LwPRINTF: 5
1149Test result: Pass
1150----
1151Format: "%#b"
1152Params: "6"
1153Result expected: "0b110"
1154Length expected: 5
1155Result LwPRINTF: "0b110"
1156Length LwPRINTF: 5
1157Test result: Pass
1158----
1159Format: "%5K"
1160Params: "my_arr"
1161Result expected: "0102B5C6D7"
1162Length expected: 10
1163Result LwPRINTF: "0102B5C6D7"
1164Length LwPRINTF: 10
1165Test result: Pass
1166----
1167Format: "%*K"
1168Params: "3, my_arr"
1169Result expected: "0102B5"
1170Length expected: 6
1171Result LwPRINTF: "0102B5"
1172Length LwPRINTF: 6
1173Test result: Pass
1174----
1175Format: "% *K"
1176Params: "3, my_arr"
1177Result expected: "01 02 B5"
1178Length expected: 8
1179Result LwPRINTF: "01 02 B5"
1180Length LwPRINTF: 8
1181Test result: Pass
1182----
1183Format: "%5k"
1184Params: "my_arr"
1185Result expected: "0102b5c6d7"
1186Length expected: 10
1187Result LwPRINTF: "0102b5c6d7"
1188Length LwPRINTF: 10
1189Test result: Pass
1190----
1191Format: "%*k"
1192Params: "3, my_arr"
1193Result expected: "0102b5"
1194Length expected: 6
1195Result LwPRINTF: "0102b5"
1196Length LwPRINTF: 6
1197Test result: Pass
1198----
1199Format: "% *k"
1200Params: "3, my_arr"
1201Result expected: "01 02 b5"
1202Length expected: 8
1203Result LwPRINTF: "01 02 b5"
1204Length LwPRINTF: 8
1205Test result: Pass
Examples and demos¶
Various examples are provided for fast library evaluation on embedded systems. These are prepared and maintained for 2
platforms, but could be easily extended to more platforms:
WIN32 examples, prepared as Visual Studio Community projects
ARM Cortex-M examples for STM32, prepared as STM32CubeIDE GCC projects
Warning
Library is platform independent and can be used on any platform.
Debug for STM32L4¶
Simple example is available, that runs on STM32L432KC-Nucleo board and shows basic confiuration for library. On-board Virtual-COM-Port through embedded ST-Link provides communication to MCU via UART peripheral.
Output function writes data to PC using USART2 hardware IP.