LwPRINTF v1.0.1 documentation¶
Welcome to the documentation for version v1.0.1.
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¶
Download library¶
Library is primarly hosted on Github.
Download latest release from releases area on Github
Clone develop branch for latest development
Download from releases¶
All releases are available on Github releases area.
Clone from Github¶
First-time clone¶
Download and install
git
if not alreadyOpen 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 submodulesRun
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.
Copy
lwprintf
folder to your projectAdd
lwprintf/src/include
folder to include path of your toolchainAdd source files from
lwprintf/src/
folder to toolchain buildCopy
lwprintf/src/include/lwprintf/lwprintf_opts_template.h
to project folder and rename it tolwprintf_opts.h
Build the project
Configuration file¶
Library comes with template config file, which can be modified according to needs.
This file shall be named lwprintf_opts.h
and its default template looks like the one below.
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 (or simply renamed in-place) where compiler
include paths have access to it by using #include "lwprintf_opts.h"
.
Tip
Check Configuration section for possible configuration settings
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | /**
* \file lwprintf_opts_template.h
* \brief LwPRINTF configuration file
*/
/*
* 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.
*
* This file is part of LwPRINTF - Lightweight stdio manager library.
*
* Author: Tilen MAJERLE <tilen@majerle.eu>
* Version: v1.0.1
*/
#ifndef LWPRINTF_HDR_OPTS_H
#define LWPRINTF_HDR_OPTS_H
/* Rename this file to "lwprintf_opts.h" for your application */
/*
* Open "include/lwprintf/lwprintf_opt.h" and
* copy & replace here settings you want to change values
*/
#endif /* LWPRINTF_HDR_OPTS_H */
|
Minimal example code¶
Run below example to test and verify library
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include "lwprintf/lwprintf.h"
/* Called for every character to be printed */
int
lwprintf_out(int ch, lwprintf_t* lwp) {
/* May use printf to output it for test */
if (ch != '\0') {
printf("%c", (char)ch);
}
return ch;
}
int
main(void) {
/* Initialize default lwprintf instance with output function */
lwprintf_init(lwprintf_out);
/* Print first text */
lwprintf_printf("Text: %d", 10);
}
|
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 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include "lwprintf/lwprintf.h"
/* Called for every character to be printed */
int
lwprintf_out(int ch, lwprintf_t* lwp) {
/* May use printf to output it for test */
if (ch != '\0') {
printf("%c", (char)ch);
}
return ch;
}
int
main(void) {
/* Initialize default lwprintf instance with output function */
lwprintf_init(lwprintf_out);
/* Print first text */
lwprintf_printf("Text: %d", 10);
}
|
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 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | /* List of specifiers added in the library which are not available in standard printf implementation */
#include "lwprintf/lwprintf.h"
/**
* \brief List of additional specifiers to print
*/
void
additional_format_specifiers(void) {
unsigned char my_array[] = { 0x01, 0x02, 0xA4, 0xB5, 0xC6 };
/* Binary output */
/* Prints number 8 in binary format, so "1000" */
lwprintf_printf("%b\r\n", 8U);
/* Prints number 16 in binary format with 10 places, so " 10000" */
lwprintf_printf("%10b\r\n", 16U);
/* Prints number 16 in binary format with 10 places, leading zeros, so "0000010000" */
lwprintf_printf("%010b\r\n", 16U);
/* Array outputs */
/* Fixed length with uppercase hex numbers, outputs "0102A4B5C6" */
lwprintf_printf("%5K\r\n", my_array);
/* Fixed length with lowercase hex numbers, outputs "0102a4b5c6" */
lwprintf_printf("%5k\r\n", my_array);
/* Variable length with uppercase letters, outputs "0102A4B5C6" */
lwprintf_printf("%*K\r\n", (int)LWPRINTF_ARRAYSIZE(my_array), my_array);
/* Variable length with lowercase letters, outputs "0102a4b5c6" */
lwprintf_printf("%*k\r\n", (int)LWPRINTF_ARRAYSIZE(my_array), my_array);
/* Variable length with uppercase letters and spaces, outputs "01 02 A4 B5 C6" */
lwprintf_printf("% *K\r\n", (int)LWPRINTF_ARRAYSIZE(my_array), my_array);
/* Variable length with uppercase letters and spaces, outputs "01 02 a4 b5 c6" */
lwprintf_printf("% *k\r\n", (int)LWPRINTF_ARRAYSIZE(my_array), my_array);
}
|
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 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | #include "lwprintf/lwprintf.h"
/* Define application custom instance */
lwprintf_t custom_instance;
/* Define custom output function for print */
int
custom_out(int ch, lwprintf_t* p) {
/* Do whatever with this character */
if (ch == '\0') {
/* This is end of string in current formatting */
/* Maybe time to start DMA transfer? */
} else {
/* Print or send character */
}
/* Return character to proceed */
return ch;
}
/* Define output function for default instance */
int
default_out(int ch, lwprintf_t* p) {
/* Print function for default instance */
/* See custom_out function for implementation details */
}
int
main(void) {
/* Initialize default lwprintf instance with output function */
lwprintf_init(default_out);
/* Initialize custom lwprintf instance with output function */
lwprintf_init_ex(&custom_instance, custom_out);
/* Print first text over default output */
lwprintf_printf("Text: %d", 10);
/* Print text over custom instance */
lwprintf_printf_ex(&custom_instance, "Custom: %f", 3.2f);
}
|
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 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | #include "lwprintf/lwprintf.h"
/* Define application custom instance */
lwprintf_t custom_instance1;
lwprintf_t custom_instance2;
/* Define custom output function for print */
int
my_out(int ch, lwprintf_t* p) {
if (p == &custom_instance1) {
/* This is custom instance 1 */
} else if (p == &custom_instance2) {
/* This is custom instance 2 */
} else {
/* This is default instance */
}
return ch;
}
int
main(void) {
/* Initialize default lwprintf instance with output function */
lwprintf_init(my_out);
lwprintf_init_ex(&custom_instance1, my_out);
lwprintf_init_ex(&custom_instance2, my_out);
/* Use print functions ... */
}
|
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 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include "lwprintf/lwprintf.h"
/* Assuming LwPRINTF has been initialized before */
void
task_1(void* arg) {
lwprintf_printf("Hello world\r\n");
}
void
task_2(void* arg) {
lwprintf_printf("This is Task 2\r\n");
}
/*
* If thread safety is not enabled,
* running above example may print:
*
* "Hello This is Task 2\r\nworld\r\n"
*/
|
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 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | /**
* \file lwprintf_sys_cmsis_os.c
* \brief System functions for CMSIS-OS based operating system
*/
/*
* 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.
*
* This file is part of LwPRINTF - Lightweight stdio manager library.
*
* Author: Tilen MAJERLE <tilen@majerle.eu>
* Version: v1.0.1
*/
#include "system/lwprintf_sys.h"
#if LWPRINTF_CFG_OS && !__DOXYGEN__
#include "cmsis_os.h"
uint8_t
lwprintf_sys_mutex_create(LWPRINTF_CFG_OS_MUTEX_HANDLE* m) {
*m = osMutexNew(NULL);
return lwprintf_sys_mutex_isvalid(m);
}
uint8_t
lwprintf_sys_mutex_isvalid(LWPRINTF_CFG_OS_MUTEX_HANDLE* m) {
return *m != NULL;
}
uint8_t
lwprintf_sys_mutex_wait(LWPRINTF_CFG_OS_MUTEX_HANDLE* m) {
return osMutexAcquire(*m, osWaitForever) == osOK;
}
uint8_t
lwprintf_sys_mutex_release(LWPRINTF_CFG_OS_MUTEX_HANDLE* m) {
return osMutexRelease(*m) == osOK;
}
#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
[in] x
: Unused variable
-
LWPRINTF_ARRAYSIZE
(x)¶ Calculate size of statically allocated array.
- Return
Number of array elements
- Parameters
[in] x
: Input array
-
lwprintf_sprintf_ex
(lw, s, format, ...)¶ Write formatted data from variable argument list to sized buffer.
- Return
The number of characters that would have been written, not counting the terminating null character.
- Parameters
[inout] lw
: LwPRINTF instance. Set toNULL
to use default instance[in] s
: Pointer to a buffer where the resulting C-string is stored. The buffer should have a size of at leastn
characters[in] format
: C string that contains a format string that follows the same specifications as format in printf[in] ...
: Optional arguments for format string
-
lwprintf_init
(out_fn)¶ Initialize default LwPRINTF instance.
- Return
1
on success,0
otherwise- See
- Parameters
[in] out_fn
: Output function used for print operation
-
lwprintf_vprintf
(format, arg)¶ Print formatted data from variable argument list to the output with default LwPRINTF instance.
- Return
The number of characters that would have been written if
n
had been sufficiently large, not counting the terminating null character.- Parameters
[in] format
: C string that contains the text to be written to output[in] arg
: A value identifying a variable arguments list initialized withva_start
.va_list
is a special type defined in<cstdarg>
.
-
lwprintf_printf
(format, ...)¶ Print formatted data to the output with default LwPRINTF instance.
- Return
The number of characters that would have been written if
n
had been sufficiently large, not counting the terminating null character.- Parameters
[in] format
: C string that contains the text to be written to output[in] ...
: Optional arguments for format string
-
lwprintf_vsnprintf
(s, n, format, arg)¶ Write formatted data from variable argument list to sized buffer with default LwPRINTF instance.
- Return
The number of characters that would have been written if
n
had been sufficiently large, not counting the terminating null character.- Parameters
[in] s
: Pointer to a buffer where the resulting C-string is stored. The buffer should have a size of at leastn
characters[in] n
: Maximum number of bytes to be used in the buffer. The generated string has a length of at mostn - 1
, leaving space for the additional terminating null character[in] format
: C string that contains a format string that follows the same specifications as format in printf[in] arg
: A value identifying a variable arguments list initialized withva_start
.va_list
is a special type defined in<cstdarg>
.
-
lwprintf_snprintf
(s, n, format, ...)¶ Write formatted data from variable argument list to sized buffer with default LwPRINTF instance.
- Return
The number of characters that would have been written if
n
had been sufficiently large, not counting the terminating null character.- Parameters
[in] s
: Pointer to a buffer where the resulting C-string is stored. The buffer should have a size of at leastn
characters[in] n
: Maximum number of bytes to be used in the buffer. The generated string has a length of at mostn - 1
, leaving space for the additional terminating null character[in] format
: C string that contains a format string that follows the same specifications as format in printf[in] ...
: Optional arguments for format string
-
lwprintf_sprintf
(s, format, ...)¶ Write formatted data from variable argument list to sized buffer with default LwPRINTF instance.
- Return
The number of characters that would have been written, not counting the terminating null character.
- Parameters
[in] s
: Pointer to a buffer where the resulting C-string is stored. The buffer should have a size of at leastn
characters[in] format
: C string that contains a format string that follows the same specifications as format in printf[in] ...
: Optional arguments for format string
-
lwprintf
¶ Print formatted data to the output with default LwPRINTF instance.
- Return
The number of characters that would have been written if
n
had been sufficiently large, not counting the terminating null character.- Note
This function is equivalent to lwprintf_printf and available only if LWPRINTF_CFG_ENABLE_SHORTNAMES is enabled
- Parameters
[in] format
: C string that contains the text to be written to output[in] ...
: Optional arguments for format string
-
lwvprintf
¶ Print formatted data from variable argument list to the output with default LwPRINTF instance.
- Return
The number of characters that would have been written if
n
had been sufficiently large, not counting the terminating null character.- Note
This function is equivalent to lwprintf_vprintf and available only if LWPRINTF_CFG_ENABLE_SHORTNAMES is enabled
- Parameters
[in] format
: C string that contains the text to be written to output[in] arg
: A value identifying a variable arguments list initialized withva_start
.va_list
is a special type defined in<cstdarg>
.
-
lwvsnprintf
¶ Write formatted data from variable argument list to sized buffer with default LwPRINTF instance.
- Return
The number of characters that would have been written if
n
had been sufficiently large, not counting the terminating null character.- Note
This function is equivalent to lwprintf_vsnprintf and available only if LWPRINTF_CFG_ENABLE_SHORTNAMES is enabled
- Parameters
[in] s
: Pointer to a buffer where the resulting C-string is stored. The buffer should have a size of at leastn
characters[in] n
: Maximum number of bytes to be used in the buffer. The generated string has a length of at mostn - 1
, leaving space for the additional terminating null character[in] format
: C string that contains a format string that follows the same specifications as format in printf[in] arg
: A value identifying a variable arguments list initialized withva_start
.va_list
is a special type defined in<cstdarg>
.
-
lwsnprintf
¶ Write formatted data from variable argument list to sized buffer with default LwPRINTF instance.
- Return
The number of characters that would have been written if
n
had been sufficiently large, not counting the terminating null character.- Note
This function is equivalent to lwprintf_snprintf and available only if LWPRINTF_CFG_ENABLE_SHORTNAMES is enabled
- Parameters
[in] s
: Pointer to a buffer where the resulting C-string is stored. The buffer should have a size of at leastn
characters[in] n
: Maximum number of bytes to be used in the buffer. The generated string has a length of at mostn - 1
, leaving space for the additional terminating null character[in] format
: C string that contains a format string that follows the same specifications as format in printf[in] ...
: Optional arguments for format string
-
lwsprintf
¶ Write formatted data from variable argument list to sized buffer with default LwPRINTF instance.
- Return
The number of characters that would have been written, not counting the terminating null character.
- Note
This function is equivalent to lwprintf_sprintf and available only if LWPRINTF_CFG_ENABLE_SHORTNAMES is enabled
- Parameters
[in] s
: Pointer to a buffer where the resulting C-string is stored. The buffer should have a size of at leastn
characters[in] format
: C string that contains a format string that follows the same specifications as format in printf[in] ...
: Optional arguments for format string
-
printf
¶ Print formatted data to the output with default LwPRINTF instance.
- Return
The number of characters that would have been written if
n
had been sufficiently large, not counting the terminating null character.- Note
This function is equivalent to lwprintf_printf and available only if LWPRINTF_CFG_ENABLE_STD_NAMES is enabled
- Parameters
[in] format
: C string that contains the text to be written to output[in] ...
: Optional arguments for format string
-
vprintf
¶ Print formatted data from variable argument list to the output with default LwPRINTF instance.
- Return
The number of characters that would have been written if
n
had been sufficiently large, not counting the terminating null character.- Note
This function is equivalent to lwprintf_vprintf and available only if LWPRINTF_CFG_ENABLE_STD_NAMES is enabled
- Parameters
[in] format
: C string that contains the text to be written to output[in] arg
: A value identifying a variable arguments list initialized withva_start
.va_list
is a special type defined in<cstdarg>
.
-
vsnprintf
¶ Write formatted data from variable argument list to sized buffer with default LwPRINTF instance.
- Return
The number of characters that would have been written if
n
had been sufficiently large, not counting the terminating null character.- Note
This function is equivalent to lwprintf_vsnprintf and available only if LWPRINTF_CFG_ENABLE_STD_NAMES is enabled
- Parameters
[in] s
: Pointer to a buffer where the resulting C-string is stored. The buffer should have a size of at leastn
characters[in] n
: Maximum number of bytes to be used in the buffer. The generated string has a length of at mostn - 1
, leaving space for the additional terminating null character[in] format
: C string that contains a format string that follows the same specifications as format in printf[in] arg
: A value identifying a variable arguments list initialized withva_start
.va_list
is a special type defined in<cstdarg>
.
-
snprintf
¶ Write formatted data from variable argument list to sized buffer with default LwPRINTF instance.
- Return
The number of characters that would have been written if
n
had been sufficiently large, not counting the terminating null character.- Note
This function is equivalent to lwprintf_snprintf and available only if LWPRINTF_CFG_ENABLE_STD_NAMES is enabled
- Parameters
[in] s
: Pointer to a buffer where the resulting C-string is stored. The buffer should have a size of at leastn
characters[in] n
: Maximum number of bytes to be used in the buffer. The generated string has a length of at mostn - 1
, leaving space for the additional terminating null character[in] format
: C string that contains a format string that follows the same specifications as format in printf[in] ...
: Optional arguments for format string
-
sprintf
¶ Write formatted data from variable argument list to sized buffer with default LwPRINTF instance.
- Return
The number of characters that would have been written, not counting the terminating null character.
- Note
This function is equivalent to lwprintf_sprintf and available only if LWPRINTF_CFG_ENABLE_STD_NAMES is enabled
- Parameters
[in] s
: Pointer to a buffer where the resulting C-string is stored. The buffer should have a size of at leastn
characters[in] format
: C string that contains a format string that follows the same specifications as format in printf[in] ...
: Optional arguments for format string
Typedefs
-
typedef int (*
lwprintf_output_fn
)(int ch, struct lwprintf *lw)¶ Callback function for character output.
- Return
ch
on success,0
to terminate further string processing- Parameters
[in] ch
: Character to print[in] lw
: LwPRINTF instance
Functions
-
uint8_t
lwprintf_init_ex
(lwprintf_t *lw, lwprintf_output_fn out_fn)¶ Initialize LwPRINTF instance.
- Return
1
on success,0
otherwise- Parameters
[inout] lw
: LwPRINTF working instance[in] out_fn
: Output function used for print operation
-
int
lwprintf_vprintf_ex
(lwprintf_t *const lw, const char *format, va_list arg)¶ Print formatted data from variable argument list to the output.
- Return
The number of characters that would have been written if
n
had been sufficiently large, not counting the terminating null character.- Parameters
[inout] lw
: LwPRINTF instance. Set toNULL
to use default instance[in] format
: C string that contains the text to be written to output[in] arg
: A value identifying a variable arguments list initialized withva_start
.va_list
is a special type defined in<cstdarg>
.
-
int
lwprintf_printf_ex
(lwprintf_t *const lw, const char *format, ...)¶ Print formatted data to the output.
- Return
The number of characters that would have been written if
n
had been sufficiently large, not counting the terminating null character.- Parameters
[inout] lw
: LwPRINTF instance. Set toNULL
to use default instance[in] format
: C string that contains the text to be written to output[in] ...
: Optional arguments for format string
-
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.
- Return
The number of characters that would have been written if
n
had been sufficiently large, not counting the terminating null character.- Parameters
[inout] lw
: LwPRINTF instance. Set toNULL
to use default instance[in] s
: Pointer to a buffer where the resulting C-string is stored. The buffer should have a size of at leastn
characters[in] n
: Maximum number of bytes to be used in the buffer. The generated string has a length of at mostn - 1
, leaving space for the additional terminating null character[in] format
: C string that contains a format string that follows the same specifications as format in printf[in] arg
: A value identifying a variable arguments list initialized withva_start
.va_list
is a special type defined in<cstdarg>
.
-
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.
- Return
The number of characters that would have been written if
n
had been sufficiently large, not counting the terminating null character.- Parameters
[inout] lw
: LwPRINTF instance. Set toNULL
to use default instance[in] s
: Pointer to a buffer where the resulting C-string is stored. The buffer should have a size of at leastn
characters[in] n
: Maximum number of bytes to be used in the buffer. The generated string has a length of at mostn - 1
, leaving space for the additional terminating null character[in] format
: C string that contains a format string that follows the same specifications as format in printf[in] ...
: Optional arguments for format string
-
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
-
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
-
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.
- Return
1
on success,0
otherwise- Parameters
[out] m
: Output variable to save mutex handle
-
uint8_t
lwprintf_sys_mutex_isvalid
(LWPRINTF_CFG_OS_MUTEX_HANDLE *m)¶ Check if mutex handle is valid.
- Return
1
on success,0
otherwise- Parameters
[in] m
: Mutex handle to check if valid
-
uint8_t
lwprintf_sys_mutex_wait
(LWPRINTF_CFG_OS_MUTEX_HANDLE *m)¶ Wait for a mutex until ready (unlimited time)
- Return
1
on success,0
otherwise- Parameters
[in] m
: Mutex handle to wait for
-
uint8_t
lwprintf_sys_mutex_release
(LWPRINTF_CFG_OS_MUTEX_HANDLE *m)¶ Release already locked mutex.
- Return
1
on success,0
otherwise- Parameters
[in] m
: Mutex handle to release
-
uint8_t
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 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 | ------------------------
Number of tests run: 149
Number of tests passed: 141
Number of tests failed: 8
Coverage: 94.630875 %
------------------------
Negative tests
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 432432423.342321321"
Result VSprintf: "Precision: 19, 432432423.3423213363"
Length VSprintf: 36
Result LwPRINTF: "Precision: 19, 432432423.342321336"
Length LwPRINTF: 36
Test result: Fail
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 0.0001234567"
Result VSprintf: "Precision: 19, 0.0001234566999999999999"
Length VSprintf: 40
Result LwPRINTF: "Precision: 19, 0.0001234567"
Length LwPRINTF: 36
Test result: Fail
----
Format: "%.45f"
Params: "3.23321321"
Result VSprintf: "3.233213210000000170651901498786173760890960693"
Length VSprintf: 47
Result LwPRINTF: "3.233213210000000160000000000000000000000000000"
Length LwPRINTF: 47
Test result: Fail
----
Format: "%.45F"
Params: "3.23321321"
Result VSprintf: "3.233213210000000170651901498786173760890960693"
Length VSprintf: 47
Result LwPRINTF: "3.233213210000000160000000000000000000000000000"
Length LwPRINTF: 47
Test result: Fail
----
Format: "%22.33e"
Params: "123.456"
Result VSprintf: "1.234560000000000030695446184836328e+02"
Length VSprintf: 39
Result LwPRINTF: "1.234560000000000096000000000000000e+02"
Length LwPRINTF: 39
Test result: Fail
----
Format: "%22.33e"
Params: "-123.456"
Result VSprintf: "-1.234560000000000030695446184836328e+02"
Length VSprintf: 40
Result LwPRINTF: "-1.234560000000000096000000000000000e+02"
Length LwPRINTF: 40
Test result: Fail
----
Format: "%22.33e"
Params: "0.123456"
Result VSprintf: "1.234559999999999962971841682701779e-01"
Length VSprintf: 39
Result LwPRINTF: "1.234559999999999872000000000000000e-01"
Length LwPRINTF: 39
Test result: Fail
----
Format: "%22.33e"
Params: "-0.123456"
Result VSprintf: "-1.234559999999999962971841682701779e-01"
Length VSprintf: 40
Result LwPRINTF: "-1.234559999999999872000000000000000e-01"
Length LwPRINTF: 40
Test result: Fail
------------------------
Positive tests
----
Format: "Precision: %3d, %.*g"
Params: "17, 17, 0.0001234567"
Result VSprintf: "Precision: 17, 0.0001234567"
Length VSprintf: 28
Result LwPRINTF: "Precision: 17, 0.0001234567"
Length LwPRINTF: 28
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 432432423.342321321"
Result VSprintf: "Precision: 0, 4e+08"
Length VSprintf: 36
Result LwPRINTF: "Precision: 0, 4e+08"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 432432423.342321321"
Result VSprintf: "Precision: 1, 4e+08"
Length VSprintf: 36
Result LwPRINTF: "Precision: 1, 4e+08"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 432432423.342321321"
Result VSprintf: "Precision: 2, 4.3e+08"
Length VSprintf: 36
Result LwPRINTF: "Precision: 2, 4.3e+08"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 432432423.342321321"
Result VSprintf: "Precision: 3, 4.32e+08"
Length VSprintf: 36
Result LwPRINTF: "Precision: 3, 4.32e+08"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 432432423.342321321"
Result VSprintf: "Precision: 4, 4.324e+08"
Length VSprintf: 36
Result LwPRINTF: "Precision: 4, 4.324e+08"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 432432423.342321321"
Result VSprintf: "Precision: 5, 4.3243e+08"
Length VSprintf: 36
Result LwPRINTF: "Precision: 5, 4.3243e+08"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 432432423.342321321"
Result VSprintf: "Precision: 6, 4.32432e+08"
Length VSprintf: 36
Result LwPRINTF: "Precision: 6, 4.32432e+08"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 432432423.342321321"
Result VSprintf: "Precision: 7, 4.324324e+08"
Length VSprintf: 36
Result LwPRINTF: "Precision: 7, 4.324324e+08"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 432432423.342321321"
Result VSprintf: "Precision: 8, 4.3243242e+08"
Length VSprintf: 36
Result LwPRINTF: "Precision: 8, 4.3243242e+08"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 432432423.342321321"
Result VSprintf: "Precision: 9, 432432423"
Length VSprintf: 36
Result LwPRINTF: "Precision: 9, 432432423"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 432432423.342321321"
Result VSprintf: "Precision: 10, 432432423.3"
Length VSprintf: 36
Result LwPRINTF: "Precision: 10, 432432423.3"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 432432423.342321321"
Result VSprintf: "Precision: 11, 432432423.34"
Length VSprintf: 36
Result LwPRINTF: "Precision: 11, 432432423.34"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 432432423.342321321"
Result VSprintf: "Precision: 12, 432432423.342"
Length VSprintf: 36
Result LwPRINTF: "Precision: 12, 432432423.342"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 432432423.342321321"
Result VSprintf: "Precision: 13, 432432423.3423"
Length VSprintf: 36
Result LwPRINTF: "Precision: 13, 432432423.3423"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 432432423.342321321"
Result VSprintf: "Precision: 14, 432432423.34232"
Length VSprintf: 36
Result LwPRINTF: "Precision: 14, 432432423.34232"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 432432423.342321321"
Result VSprintf: "Precision: 15, 432432423.342321"
Length VSprintf: 36
Result LwPRINTF: "Precision: 15, 432432423.342321"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 432432423.342321321"
Result VSprintf: "Precision: 16, 432432423.3423213"
Length VSprintf: 36
Result LwPRINTF: "Precision: 16, 432432423.3423213"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 432432423.342321321"
Result VSprintf: "Precision: 17, 432432423.34232134"
Length VSprintf: 36
Result LwPRINTF: "Precision: 17, 432432423.34232134"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 432432423.342321321"
Result VSprintf: "Precision: 18, 432432423.342321336"
Length VSprintf: 36
Result LwPRINTF: "Precision: 18, 432432423.342321336"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 0.0001234567"
Result VSprintf: "Precision: 0, 0.0001"
Length VSprintf: 36
Result LwPRINTF: "Precision: 0, 0.0001"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 0.0001234567"
Result VSprintf: "Precision: 1, 0.0001"
Length VSprintf: 36
Result LwPRINTF: "Precision: 1, 0.0001"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 0.0001234567"
Result VSprintf: "Precision: 2, 0.00012"
Length VSprintf: 36
Result LwPRINTF: "Precision: 2, 0.00012"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 0.0001234567"
Result VSprintf: "Precision: 3, 0.000123"
Length VSprintf: 36
Result LwPRINTF: "Precision: 3, 0.000123"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 0.0001234567"
Result VSprintf: "Precision: 4, 0.0001235"
Length VSprintf: 36
Result LwPRINTF: "Precision: 4, 0.0001235"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 0.0001234567"
Result VSprintf: "Precision: 5, 0.00012346"
Length VSprintf: 36
Result LwPRINTF: "Precision: 5, 0.00012346"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 0.0001234567"
Result VSprintf: "Precision: 6, 0.000123457"
Length VSprintf: 36
Result LwPRINTF: "Precision: 6, 0.000123457"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 0.0001234567"
Result VSprintf: "Precision: 7, 0.0001234567"
Length VSprintf: 36
Result LwPRINTF: "Precision: 7, 0.0001234567"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 0.0001234567"
Result VSprintf: "Precision: 8, 0.0001234567"
Length VSprintf: 36
Result LwPRINTF: "Precision: 8, 0.0001234567"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 0.0001234567"
Result VSprintf: "Precision: 9, 0.0001234567"
Length VSprintf: 36
Result LwPRINTF: "Precision: 9, 0.0001234567"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 0.0001234567"
Result VSprintf: "Precision: 10, 0.0001234567"
Length VSprintf: 36
Result LwPRINTF: "Precision: 10, 0.0001234567"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 0.0001234567"
Result VSprintf: "Precision: 11, 0.0001234567"
Length VSprintf: 36
Result LwPRINTF: "Precision: 11, 0.0001234567"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 0.0001234567"
Result VSprintf: "Precision: 12, 0.0001234567"
Length VSprintf: 36
Result LwPRINTF: "Precision: 12, 0.0001234567"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 0.0001234567"
Result VSprintf: "Precision: 13, 0.0001234567"
Length VSprintf: 36
Result LwPRINTF: "Precision: 13, 0.0001234567"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 0.0001234567"
Result VSprintf: "Precision: 14, 0.0001234567"
Length VSprintf: 36
Result LwPRINTF: "Precision: 14, 0.0001234567"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 0.0001234567"
Result VSprintf: "Precision: 15, 0.0001234567"
Length VSprintf: 36
Result LwPRINTF: "Precision: 15, 0.0001234567"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 0.0001234567"
Result VSprintf: "Precision: 16, 0.0001234567"
Length VSprintf: 36
Result LwPRINTF: "Precision: 16, 0.0001234567"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 0.0001234567"
Result VSprintf: "Precision: 17, 0.0001234567"
Length VSprintf: 36
Result LwPRINTF: "Precision: 17, 0.0001234567"
Length LwPRINTF: 36
Test result: Pass
----
Format: "Precision: %3d, %20.*g"
Params: "i, i, 0.0001234567"
Result VSprintf: "Precision: 18, 0.0001234567"
Length VSprintf: 36
Result LwPRINTF: "Precision: 18, 0.0001234567"
Length LwPRINTF: 36
Test result: Pass
----
Format: "%.4f"
Params: "3.23321321"
Result VSprintf: "3.2332"
Length VSprintf: 6
Result LwPRINTF: "3.2332"
Length LwPRINTF: 6
Test result: Pass
----
Format: "%.4F"
Params: "3.23321321"
Result VSprintf: "3.2332"
Length VSprintf: 6
Result LwPRINTF: "3.2332"
Length LwPRINTF: 6
Test result: Pass
----
Format: "%g"
Params: "1.23342"
Result VSprintf: "1.23342"
Length VSprintf: 7
Result LwPRINTF: "1.23342"
Length LwPRINTF: 7
Test result: Pass
----
Format: "%g"
Params: "12334.2"
Result VSprintf: "12334.2"
Length VSprintf: 7
Result LwPRINTF: "12334.2"
Length LwPRINTF: 7
Test result: Pass
----
Format: "%.8g"
Params: "0.000000123342"
Result VSprintf: "1.23342e-07"
Length VSprintf: 11
Result LwPRINTF: "1.23342e-07"
Length LwPRINTF: 11
Test result: Pass
----
Format: "%.8G"
Params: "0.000000123342"
Result VSprintf: "1.23342E-07"
Length VSprintf: 11
Result LwPRINTF: "1.23342E-07"
Length LwPRINTF: 11
Test result: Pass
----
Format: "%.4f"
Params: "323243432432432.432"
Result VSprintf: "323243432432432.4375"
Length VSprintf: 20
Result LwPRINTF: "323243432432432.4375"
Length LwPRINTF: 20
Test result: Pass
----
Format: "%e"
Params: "-123.456"
Result VSprintf: "-1.234560e+02"
Length VSprintf: 13
Result LwPRINTF: "-1.234560e+02"
Length LwPRINTF: 13
Test result: Pass
----
Format: "%e"
Params: "0.000001"
Result VSprintf: "1.000000e-06"
Length VSprintf: 12
Result LwPRINTF: "1.000000e-06"
Length LwPRINTF: 12
Test result: Pass
----
Format: "%e"
Params: "0.123456"
Result VSprintf: "1.234560e-01"
Length VSprintf: 12
Result LwPRINTF: "1.234560e-01"
Length LwPRINTF: 12
Test result: Pass
----
Format: "%e"
Params: "-0.123456"
Result VSprintf: "-1.234560e-01"
Length VSprintf: 13
Result LwPRINTF: "-1.234560e-01"
Length LwPRINTF: 13
Test result: Pass
----
Format: "%.4e"
Params: "123.456"
Result VSprintf: "1.2346e+02"
Length VSprintf: 10
Result LwPRINTF: "1.2346e+02"
Length LwPRINTF: 10
Test result: Pass
----
Format: "%.4e"
Params: "-123.456"
Result VSprintf: "-1.2346e+02"
Length VSprintf: 11
Result LwPRINTF: "-1.2346e+02"
Length LwPRINTF: 11
Test result: Pass
----
Format: "%.4e"
Params: "0.123456"
Result VSprintf: "1.2346e-01"
Length VSprintf: 10
Result LwPRINTF: "1.2346e-01"
Length LwPRINTF: 10
Test result: Pass
----
Format: "%.4e"
Params: "-0.123456"
Result VSprintf: "-1.2346e-01"
Length VSprintf: 11
Result LwPRINTF: "-1.2346e-01"
Length LwPRINTF: 11
Test result: Pass
----
Format: "%.0e"
Params: "123.456"
Result VSprintf: "1e+02"
Length VSprintf: 5
Result LwPRINTF: "1e+02"
Length LwPRINTF: 5
Test result: Pass
----
Format: "%.0e"
Params: "-123.456"
Result VSprintf: "-1e+02"
Length VSprintf: 6
Result LwPRINTF: "-1e+02"
Length LwPRINTF: 6
Test result: Pass
----
Format: "%.0e"
Params: "0.123456"
Result VSprintf: "1e-01"
Length VSprintf: 5
Result LwPRINTF: "1e-01"
Length LwPRINTF: 5
Test result: Pass
----
Format: "%.0e"
Params: "-0.123456"
Result VSprintf: "-1e-01"
Length VSprintf: 6
Result LwPRINTF: "-1e-01"
Length LwPRINTF: 6
Test result: Pass
----
Format: "%22.4e"
Params: "123.456"
Result VSprintf: " 1.2346e+02"
Length VSprintf: 22
Result LwPRINTF: " 1.2346e+02"
Length LwPRINTF: 22
Test result: Pass
----
Format: "%22.4e"
Params: "-123.456"
Result VSprintf: " -1.2346e+02"
Length VSprintf: 22
Result LwPRINTF: " -1.2346e+02"
Length LwPRINTF: 22
Test result: Pass
----
Format: "%22.4e"
Params: "0.123456"
Result VSprintf: " 1.2346e-01"
Length VSprintf: 22
Result LwPRINTF: " 1.2346e-01"
Length LwPRINTF: 22
Test result: Pass
----
Format: "%22.4e"
Params: "-0.123456"
Result VSprintf: " -1.2346e-01"
Length VSprintf: 22
Result LwPRINTF: " -1.2346e-01"
Length LwPRINTF: 22
Test result: Pass
----
Format: "%022.4e"
Params: "123.456"
Result VSprintf: "0000000000001.2346e+02"
Length VSprintf: 22
Result LwPRINTF: "0000000000001.2346e+02"
Length LwPRINTF: 22
Test result: Pass
----
Format: "%022.4e"
Params: "-123.456"
Result VSprintf: "-000000000001.2346e+02"
Length VSprintf: 22
Result LwPRINTF: "-000000000001.2346e+02"
Length LwPRINTF: 22
Test result: Pass
----
Format: "%022.4e"
Params: "0.123456"
Result VSprintf: "0000000000001.2346e-01"
Length VSprintf: 22
Result LwPRINTF: "0000000000001.2346e-01"
Length LwPRINTF: 22
Test result: Pass
----
Format: "%e"
Params: "0.00000000123456"
Result VSprintf: "1.234560e-09"
Length VSprintf: 12
Result LwPRINTF: "1.234560e-09"
Length LwPRINTF: 12
Test result: Pass
----
Format: "%022.4e"
Params: "-0.123456"
Result VSprintf: "-000000000001.2346e-01"
Length VSprintf: 22
Result LwPRINTF: "-000000000001.2346e-01"
Length LwPRINTF: 22
Test result: Pass
----
Format: "%.4E"
Params: "-123.456"
Result VSprintf: "-1.2346E+02"
Length VSprintf: 11
Result LwPRINTF: "-1.2346E+02"
Length LwPRINTF: 11
Test result: Pass
----
Format: "% 3u"
Params: "(unsigned)28"
Result VSprintf: " 28"
Length VSprintf: 3
Result LwPRINTF: " 28"
Length LwPRINTF: 3
Test result: Pass
----
Format: "% 3u"
Params: "(unsigned)123456"
Result VSprintf: "123456"
Length VSprintf: 6
Result LwPRINTF: "123456"
Length LwPRINTF: 6
Test result: Pass
----
Format: "%03d"
Params: "28"
Result VSprintf: "028"
Length VSprintf: 3
Result LwPRINTF: "028"
Length LwPRINTF: 3
Test result: Pass
----
Format: "%+03d"
Params: "28"
Result VSprintf: "+28"
Length VSprintf: 3
Result LwPRINTF: "+28"
Length LwPRINTF: 3
Test result: Pass
----
Format: "%+3d"
Params: "28"
Result VSprintf: "+28"
Length VSprintf: 3
Result LwPRINTF: "+28"
Length LwPRINTF: 3
Test result: Pass
----
Format: "%03d"
Params: "-28"
Result VSprintf: "-28"
Length VSprintf: 3
Result LwPRINTF: "-28"
Length LwPRINTF: 3
Test result: Pass
----
Format: "%+03d"
Params: "-28"
Result VSprintf: "-28"
Length VSprintf: 3
Result LwPRINTF: "-28"
Length LwPRINTF: 3
Test result: Pass
----
Format: "%+3d"
Params: "-28"
Result VSprintf: "-28"
Length VSprintf: 3
Result LwPRINTF: "-28"
Length LwPRINTF: 3
Test result: Pass
----
Format: "%03u"
Params: "(unsigned)123456"
Result VSprintf: "123456"
Length VSprintf: 6
Result LwPRINTF: "123456"
Length LwPRINTF: 6
Test result: Pass
----
Format: "%-010uabc"
Params: "(unsigned)123456"
Result VSprintf: "123456 abc"
Length VSprintf: 13
Result LwPRINTF: "123456 abc"
Length LwPRINTF: 13
Test result: Pass
----
Format: "%010uabc"
Params: "(unsigned)123456"
Result VSprintf: "0000123456abc"
Length VSprintf: 13
Result LwPRINTF: "0000123456abc"
Length LwPRINTF: 13
Test result: Pass
----
Format: "%-10d"
Params: "-123"
Result VSprintf: "-123 "
Length VSprintf: 10
Result LwPRINTF: "-123 "
Length LwPRINTF: 10
Test result: Pass
----
Format: "%10d"
Params: "-123"
Result VSprintf: " -123"
Length VSprintf: 10
Result LwPRINTF: " -123"
Length LwPRINTF: 10
Test result: Pass
----
Format: "%-06d"
Params: "-1234567"
Result VSprintf: "-1234567"
Length VSprintf: 8
Result LwPRINTF: "-1234567"
Length LwPRINTF: 8
Test result: Pass
----
Format: "%06d"
Params: "-1234567"
Result VSprintf: "-1234567"
Length VSprintf: 8
Result LwPRINTF: "-1234567"
Length LwPRINTF: 8
Test result: Pass
----
Format: "%-10d"
Params: "-1234567"
Result VSprintf: "-1234567 "
Length VSprintf: 10
Result LwPRINTF: "-1234567 "
Length LwPRINTF: 10
Test result: Pass
----
Format: "%10d"
Params: "-1234567"
Result VSprintf: " -1234567"
Length VSprintf: 10
Result LwPRINTF: " -1234567"
Length LwPRINTF: 10
Test result: Pass
----
Format: "%-010d"
Params: "-1234567"
Result VSprintf: "-1234567 "
Length VSprintf: 10
Result LwPRINTF: "-1234567 "
Length LwPRINTF: 10
Test result: Pass
----
Format: "%010d"
Params: "-1234567"
Result VSprintf: "-001234567"
Length VSprintf: 10
Result LwPRINTF: "-001234567"
Length LwPRINTF: 10
Test result: Pass
----
Format: "%s"
Params: ""This is my string""
Result VSprintf: "This is my string"
Length VSprintf: 17
Result LwPRINTF: "This is my string"
Length LwPRINTF: 17
Test result: Pass
----
Format: "%10s"
Params: ""This is my string""
Result VSprintf: "This is my string"
Length VSprintf: 17
Result LwPRINTF: "This is my string"
Length LwPRINTF: 17
Test result: Pass
----
Format: "%0*d"
Params: "10, -123"
Result VSprintf: "-000000123"
Length VSprintf: 10
Result LwPRINTF: "-000000123"
Length LwPRINTF: 10
Test result: Pass
----
Format: "%zu"
Params: "(size_t)10"
Result VSprintf: "10"
Length VSprintf: 2
Result LwPRINTF: "10"
Length LwPRINTF: 2
Test result: Pass
----
Format: "%ju"
Params: "(uintmax_t)10"
Result VSprintf: "10"
Length VSprintf: 2
Result LwPRINTF: "10"
Length LwPRINTF: 2
Test result: Pass
----
Format: "% d"
Params: "1024"
Result VSprintf: " 1024"
Length VSprintf: 5
Result LwPRINTF: " 1024"
Length LwPRINTF: 5
Test result: Pass
----
Format: "% 4d"
Params: "1024"
Result VSprintf: " 1024"
Length VSprintf: 5
Result LwPRINTF: " 1024"
Length LwPRINTF: 5
Test result: Pass
----
Format: "% 3d"
Params: "1024"
Result VSprintf: " 1024"
Length VSprintf: 5
Result LwPRINTF: " 1024"
Length LwPRINTF: 5
Test result: Pass
----
Format: "% 3f"
Params: "32.687"
Result VSprintf: " 32.687000"
Length VSprintf: 10
Result LwPRINTF: " 32.687000"
Length LwPRINTF: 10
Test result: Pass
----
Format: "%*.*s"
Params: "8, 12, "This is my string""
Result VSprintf: "This is my s"
Length VSprintf: 12
Result LwPRINTF: "This is my s"
Length LwPRINTF: 12
Test result: Pass
----
Format: "%*.*s"
Params: "8, 12, "Stri""
Result VSprintf: " Stri"
Length VSprintf: 8
Result LwPRINTF: " Stri"
Length LwPRINTF: 8
Test result: Pass
----
Format: "%-6.10s"
Params: ""This is my string""
Result VSprintf: "This is my"
Length VSprintf: 10
Result LwPRINTF: "This is my"
Length LwPRINTF: 10
Test result: Pass
----
Format: "%6.10s"
Params: ""This is my string""
Result VSprintf: "This is my"
Length VSprintf: 10
Result LwPRINTF: "This is my"
Length LwPRINTF: 10
Test result: Pass
----
Format: "%-6.10s"
Params: ""This is my string""
Result VSprintf: "This is my"
Length VSprintf: 10
Result LwPRINTF: "This is my"
Length LwPRINTF: 10
Test result: Pass
----
Format: "%6.10s"
Params: ""Th""
Result VSprintf: " Th"
Length VSprintf: 6
Result LwPRINTF: " Th"
Length LwPRINTF: 6
Test result: Pass
----
Format: "%-6.10s"
Params: ""Th""
Result VSprintf: "Th "
Length VSprintf: 6
Result LwPRINTF: "Th "
Length LwPRINTF: 6
Test result: Pass
----
Format: "%*.*s"
Params: "-6, 10, "Th""
Result VSprintf: "Th "
Length VSprintf: 6
Result LwPRINTF: "Th "
Length LwPRINTF: 6
Test result: Pass
----
Format: "%*.*s"
Params: "6, 10, "Th""
Result VSprintf: " Th"
Length VSprintf: 6
Result LwPRINTF: " Th"
Length LwPRINTF: 6
Test result: Pass
----
Format: "%.4s"
Params: ""This is my string""
Result VSprintf: "This"
Length VSprintf: 4
Result LwPRINTF: "This"
Length LwPRINTF: 4
Test result: Pass
----
Format: "%.6s"
Params: ""1234""
Result VSprintf: "1234"
Length VSprintf: 4
Result LwPRINTF: "1234"
Length LwPRINTF: 4
Test result: Pass
----
Format: "%.4s"
Params: ""stri""
Result VSprintf: "stri"
Length VSprintf: 4
Result LwPRINTF: "stri"
Length LwPRINTF: 4
Test result: Pass
----
Format: "%.4s%.2s"
Params: ""123456", "abcdef""
Result VSprintf: "1234ab"
Length VSprintf: 6
Result LwPRINTF: "1234ab"
Length LwPRINTF: 6
Test result: Pass
----
Format: "%.4.2s"
Params: ""123456""
Result VSprintf: ".2s"
Length VSprintf: 3
Result LwPRINTF: ".2s"
Length LwPRINTF: 3
Test result: Pass
----
Format: "%.*s"
Params: "3, "123456""
Result VSprintf: "123"
Length VSprintf: 3
Result LwPRINTF: "123"
Length LwPRINTF: 3
Test result: Pass
----
Format: "%.3s"
Params: """"
Result VSprintf: ""
Length VSprintf: 0
Result LwPRINTF: ""
Length LwPRINTF: 0
Test result: Pass
----
Format: "%yunknown"
Params: """"
Result VSprintf: "yunknown"
Length VSprintf: 8
Result LwPRINTF: "yunknown"
Length LwPRINTF: 8
Test result: Pass
----
Format: "%#2X"
Params: "123"
Result VSprintf: "0X7B"
Length VSprintf: 4
Result LwPRINTF: "0X7B"
Length LwPRINTF: 4
Test result: Pass
----
Format: "%#2x"
Params: "123"
Result VSprintf: "0x7b"
Length VSprintf: 4
Result LwPRINTF: "0x7b"
Length LwPRINTF: 4
Test result: Pass
----
Format: "%#2o"
Params: "123"
Result VSprintf: "0173"
Length VSprintf: 4
Result LwPRINTF: "0173"
Length LwPRINTF: 4
Test result: Pass
----
Format: "%#2X"
Params: "1"
Result VSprintf: "0X1"
Length VSprintf: 3
Result LwPRINTF: "0X1"
Length LwPRINTF: 3
Test result: Pass
----
Format: "%#2x"
Params: "1"
Result VSprintf: "0x1"
Length VSprintf: 3
Result LwPRINTF: "0x1"
Length LwPRINTF: 3
Test result: Pass
----
Format: "%#2o"
Params: "1"
Result VSprintf: "01"
Length VSprintf: 2
Result LwPRINTF: "01"
Length LwPRINTF: 2
Test result: Pass
----
Format: "%#2X"
Params: "0"
Result VSprintf: " 0"
Length VSprintf: 2
Result LwPRINTF: " 0"
Length LwPRINTF: 2
Test result: Pass
----
Format: "%#2x"
Params: "0"
Result VSprintf: " 0"
Length VSprintf: 2
Result LwPRINTF: " 0"
Length LwPRINTF: 2
Test result: Pass
----
Format: "%#2o"
Params: "0"
Result VSprintf: " 0"
Length VSprintf: 2
Result LwPRINTF: " 0"
Length LwPRINTF: 2
Test result: Pass
----
Format: "%p"
Params: "&tests_passed"
Result VSprintf: "00BE0FD4"
Length VSprintf: 8
Result LwPRINTF: "00BE0FD4"
Length LwPRINTF: 8
Test result: Pass
----
Format: "0X%p"
Params: "&tests_passed"
Result VSprintf: "0X00BE0FD4"
Length VSprintf: 10
Result LwPRINTF: "0X00BE0FD4"
Length LwPRINTF: 10
Test result: Pass
----
Format: "0x%p"
Params: "&tests_passed"
Result VSprintf: "0x00BE0FD4"
Length VSprintf: 10
Result LwPRINTF: "0x00BE0FD4"
Length LwPRINTF: 10
Test result: Pass
----
Format: "%llb abc"
Params: "123"
Result expected: "1111011 abc"
Length expected: 11
Result LwPRINTF: "1111011 abc"
Length LwPRINTF: 11
Test result: Pass
----
Format: "%b"
Params: "4"
Result expected: "100"
Length expected: 3
Result LwPRINTF: "100"
Length LwPRINTF: 3
Test result: Pass
----
Format: "%#2B"
Params: "1"
Result expected: "0B1"
Length expected: 3
Result LwPRINTF: "0B1"
Length LwPRINTF: 3
Test result: Pass
----
Format: "%#2b"
Params: "1"
Result expected: "0b1"
Length expected: 3
Result LwPRINTF: "0b1"
Length LwPRINTF: 3
Test result: Pass
----
Format: "%#2B"
Params: "0"
Result expected: " 0"
Length expected: 2
Result LwPRINTF: " 0"
Length LwPRINTF: 2
Test result: Pass
----
Format: "%#2b"
Params: "0"
Result expected: " 0"
Length expected: 2
Result LwPRINTF: " 0"
Length LwPRINTF: 2
Test result: Pass
----
Format: "%#B"
Params: "0"
Result expected: "0"
Length expected: 1
Result LwPRINTF: "0"
Length LwPRINTF: 1
Test result: Pass
----
Format: "%#b"
Params: "0"
Result expected: "0"
Length expected: 1
Result LwPRINTF: "0"
Length LwPRINTF: 1
Test result: Pass
----
Format: "%#B"
Params: "6"
Result expected: "0B110"
Length expected: 5
Result LwPRINTF: "0B110"
Length LwPRINTF: 5
Test result: Pass
----
Format: "%#b"
Params: "6"
Result expected: "0b110"
Length expected: 5
Result LwPRINTF: "0b110"
Length LwPRINTF: 5
Test result: Pass
----
Format: "%5K"
Params: "my_arr"
Result expected: "0102B5C6D7"
Length expected: 10
Result LwPRINTF: "0102B5C6D7"
Length LwPRINTF: 10
Test result: Pass
----
Format: "%*K"
Params: "3, my_arr"
Result expected: "0102B5"
Length expected: 6
Result LwPRINTF: "0102B5"
Length LwPRINTF: 6
Test result: Pass
----
Format: "% *K"
Params: "3, my_arr"
Result expected: "01 02 B5"
Length expected: 8
Result LwPRINTF: "01 02 B5"
Length LwPRINTF: 8
Test result: Pass
----
Format: "%5k"
Params: "my_arr"
Result expected: "0102b5c6d7"
Length expected: 10
Result LwPRINTF: "0102b5c6d7"
Length LwPRINTF: 10
Test result: Pass
----
Format: "%*k"
Params: "3, my_arr"
Result expected: "0102b5"
Length expected: 6
Result LwPRINTF: "0102b5"
Length LwPRINTF: 6
Test result: Pass
----
Format: "% *k"
Params: "3, my_arr"
Result expected: "01 02 b5"
Length expected: 8
Result LwPRINTF: "01 02 b5"
Length LwPRINTF: 8
Test 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.