standard library functions

Comments

9 comments

  • Avatar
    Paul Curtis

    puts is in <stdio.h> and requires a character writing routine, __putchar, to be implemented.

    printf is the same, it's in <stdio.h>, it's in the library, and lots of customers use it.

    strsep is not a standard function that I know of, and I know them all in the standard.  So you'll need to provide your own.

    You'll need to write a standard __putchar function to output to UART0.

    0
    Comment actions Permalink
  • Avatar
    Gordon Scott

    Hi,

     

    I notice stdio.h contains prototypes for other stdio functions like fputc, but that these are undefined, so I presume they don't exist and we have to supply everything. Am I right, and/or in there any precedent set within the Rowley toolchain for these functions, please?

     

    Thanks,

                Gordon.

    0
    Comment actions Permalink
  • Avatar
    Paul Curtis

    Standard I/O is not provided--where would the output go in an embedded system?  strsep is not an ISO C function, so is not provided.  If you want standard I/O to output to a UART, for example, you must implement __putc.  Note that printf is supplied, but the underlying character I/O function needs to be provided for the target system in question.

    0
    Comment actions Permalink
  • Avatar
    Gordon Scott

    Hi Paul,

    In this particular embedded system, to UART, USB and SPI ,and of course I need the drivers for those.  I wondered mostly if there was and skeleton available for associating streams with them, though at present I'm a fair way into an own solution anyway.


    It's no surprise if nothing exists, but it seems worth asking before I invent a wheel..


    strsep was the original writer's question, not. mine. It's part of string.h not stdio.h and is used for parsing tokenized data, e.g., words separated by whitespace, or wjatever.

    Thanks anyway.

    0
    Comment actions Permalink
  • Avatar
    Paul Curtis

    strsep doesn't exist, bot strtok does.  I do have an infrastructure for streamed I/O but it's not going to make it into V2 in any short order.  I now have DMA-driven, interrupt-drivenm and polled SPI drivers, UART drivers, and various other drivers for LPC2k, and will extend these.  But this project is pretty much an internal development on top of CTL so you will need CTL to make the most of it--or any of it outside of a polled driver.

    0
    Comment actions Permalink
  • Avatar
    Gordon Scott

    Hi Paul,

    That's the kind of thing I want, though on SAM7S rather than LPC.

    "Have an infrastructure for" sounds like it could be very early in the development.  Is there any mileage in sharing what you have? I'd aim to stick to the same methods and would send gladly my efforts back for incorporation . If not I'll just stick with essentially what I'm doing now.

    My USB plan is for CDC only, so fit's _my_ infrastructure plans, but might not then fit yours.

     

    strsep() definitely exists though I don't for  a moment suggest you need do anything about it.  It's a close sister to strtok().

    http://www.gnu.org/s/libc/manual/html_node/Finding-Tokens-in-a-String.html

    The source is out there for people who want it and I think it's also part of newlib if they want the bundle of nearly everything.

    0
    Comment actions Permalink
  • Avatar
    Paul Curtis

    The "grand plan" is a set of libraries for TCP/IP, USB, Mass storage, and, um, some other things.  I already have drivers for many peripherals that you commonly find on micros (e.g. PrimeCell DMA and SSP) which work rather nicely.  I have not done anything on the SAM7S, so you're on your own there, I've done things for STM32, LM3S, and LPC2k (and that will easily port to LPC1700).  Other things that are going into this project are configurable memory managers (linked heaps and buddy heaps, for instance, to allow real-time allocation and deallocation of memory in DMA-able memory regions.)

    strsep is not an ISO function, nor is it a POSIX function, so it's not really portable.  I could pop it into our library, but really, that would sort of open the floodgates to more non-standard functions.  I guess strsep isn't such a big deal.

    0
    Comment actions Permalink
  • Avatar
    Patrick Moran

    Where do I put the definition of _putchar ? I've run into the same problem when I compile my code (that I've copied from elsewhere) that has the putchar stdio call. I knwo I have to define _putchar (because I get .... undefined reference to _putchar). So I'm looking through all the code for the place holder for _putchar and cant find it. Where is it?

    Why cnat I get to the <stdio.h> file from inside the IDE? Is there a way to open this code directly without having to search through the installation directory?

     

    Thanks!

     

    0
    Comment actions Permalink
  • Avatar
    Paul Curtis

    To open <stdio.h>, go to the line containing #include <stdio.h> and type Alt+G (Go To Definition).

    __putchar is describes in the docs, but you need:

    int __putchar(int ch);  return EOF if "putting" error, otherwise zero-or-positive.

    0
    Comment actions Permalink

Please sign in to leave a comment.