Giter Club home page Giter Club logo

xprintfc's Introduction

xprintfc

Most completed and little printf like subsystem for embedded system.

Example of code size now 2 architecture with all features enabled, compiled with -O3 :

Embedded 32 bit ARM : 2268 bytes
Linux X64 : 3690 bytes
  • Tested on microprocessor from 8 to 64 bit
  • Optional support for floating point number
  • Optional support for long long number
  • Support for binary number (%b)
  • Support for boolean value (%B)
  • Support for pointer in hex format (%p/%P)
  • Support for size_t C99 argument size
  • No library function required
  • Parametric function to emit single char
  • Configurable using config.h and -DHAVE_CONFIG_H
  • 10% fastest than libc functions.
  • And much more

Configurable options

The option can be set directly on the compiler command line for example : gcc -DXCFG_FORMAT_LONGLONG=0 -c xformatc.c compile the function without floating point support or inserted in the file config.h and define the symbol HAVE_CONFIG_H on compilation time.

XCFG_FORMAT_LONGLONG Set to 0 to exclude support for long long.

XCFG_FORMAT_STATIC Set to static to reduce stack usage only for mono thread application.

XCFG_FORMAT_FLOAT Set to 0 to exclude support for floating point.

XCFG_FORMAT_FLOAT_PREC Set to 1 to make calculation using float instead of double.

xprintfc's People

Contributors

marioviara avatar marcoe87 avatar

Stargazers

Egor Dolgalev avatar Jonathan Talamantes avatar zgw avatar  avatar suguang avatar  avatar  avatar Mikk avatar Luke Gary avatar Thomas Höhenleitner avatar Repeerc avatar magic_overload avatar  avatar  avatar boggyb avatar  avatar Toni Neubert avatar may avatar SilverFox avatar Aliaksandr Kavalchuk avatar  avatar  avatar  avatar  avatar  avatar Flavio Sonnenberg avatar David Sosa avatar Sergey Golovin avatar  avatar Raivis avatar BG13 avatar Gustavo Javier Malano avatar Michael Krauter avatar Gudin Vladimir avatar  avatar cctsao1008 avatar daichenghe avatar Vasiliy avatar Ivan ALF avatar yhnu avatar NotSqrt avatar Priyank avatar Shreyas Balakrishna avatar Uffe Jakobsen avatar  avatar  avatar Huaqi Fang avatar Simone Marra avatar Adam Jones avatar  avatar  avatar AlexShi avatar Kevin Smith avatar  avatar Mark avatar  avatar Erich Styger avatar Vitaliy Suchkov avatar Richard Osterloh avatar

Watchers

Mark avatar Ivan ALF avatar Andrei Paulau avatar Redferne Bellini avatar Priyank avatar JackN avatar David Sosa avatar  avatar  avatar  avatar

xprintfc's Issues

how to analyze potential memory issue

thank you so much for this terrific module! This issue is most likely not a problem with your code and perhaps a user question. You did not state if or how you would like to address these so I hope you do not mind that I put it in here.

I am using your library on a LPC1343 in a FreeRTOS context. I believe my FreeRTOS configuration works stable since I can ran tasks and queues for hours. I am working on a serial "CLI'". My xprintf also runs stable-ish. But once I use xformatc my application immediately hangs.

The test suite for xformatc has 70% code coverage so I am confident that I did not mess up your code base. Currently I do not feel very confident to debug the embedded FreeRTOS setting I have so I hope you would share some tips for trouble-shooting with me.

I should probably state that I run version 1.01 of your code.

the xprintf function I came up with:

#include <stdarg.h>
#include "xprintf.h"
#include "xformatc.h"
#include "uart.h"

static void put_char(void *arg, char c) {
  //UARTSendChar((uint8_t) c);
  UARTSendChar(c);
}

void xprintf(const char *fmt, ...) {
  va_list args;
  va_start(args, fmt);
  xvformat(put_char, NULL, fmt, args);
  va_end(args);
}

void xvprintf(const char *fmt, va_list _args) {
  //va_list args;
  //va_copy(args, _args);
  xvformat(put_char, NULL, fmt, _args);
  //va_end(args);
}

long long on PIC32MX

in xformatc.c around line 867, the long long type is popped off the stack, but on the CPU i'm compiling for (a PIC32MX, with the XC32 compiler) this doesn't work. instead it results in some out-of-boundary garbage.

so when changing the case statement to something like this, it does work:

case FLAG_TYPE_LONGLONG: {
	long high = (LONG)va_arg(args,long);
	long low = (LONG)va_arg(args,long);
	
	param.values.llvalue = (LONGLONG)high << 32 | low;
	break;
}

thought i'd let you know

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.