• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Development Tools » TI C/C++ Compiler » TI C/C++ Compiler - Forum » sscanf Sys/bios and C28x
Share
TI C/C++ Compiler
  • Forum
Options
  • Subscribe via RSS

sscanf Sys/bios and C28x

sscanf Sys/bios and C28x

  • MARTIN Olivier
    Posted by MARTIN Olivier
    on Jan 27 2012 06:12 AM
    Prodigy60 points

    I m using sscanf but it always returns 0. My simple code is :

    int var1,var2;
    char *buf="100";
    var1=sscanf(buf,"%d",&var2);

    > var1=var2=0;
    in the config file I've tried to change default heap size to 0x400 as suggested in numerous forums and docs but the result is always the same : 0.
    what is the trick to use this stdio function ?
    Olivier 
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • George Mock
    Posted by George Mock
    on Jan 30 2012 10:38 AM
    Guru51475 points

    Make sure you #include <stdio.h> .  While you are not doing external I/O, other tips in this wiki article may be helpful.

    Thanks and regards,

    -George


    TI C/C++ Compiler Forum Moderator
    Please click Verify Answer on the best reply to your question.
    The Compiler Wiki answers most common questions.
    Track an issue with SDOWP. Enter your bug id in the "Find Record ID" box.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • MARTIN Olivier
    Posted by MARTIN Olivier
    on Feb 02 2012 11:33 AM
    Prodigy60 points

    Thank you George for this answer but stdio.h is included and I have already read this wiki. I use the 28069 experimenter kit with sys/bios : sscanf return 0 using %d or %s !

    But %f works well.

    source :

    int var1=0;
    char *buf="123 456 bonjour";
    int entier=0;
    float flottant=0;
    char buffer[20];
    char str[50];
    var1=sscanf(buf,"%f %s %d",&flottant,buffer,&entier);
    sprintf(str,"sprintf(%f/%s/%d)",flottant,buffer,entier);

    return : "123.00000//0"  var1=1

    What's wrong with this code ?

    Thanks and regards,

    Olivier

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • George Mock
    Posted by George Mock
    on Mar 19 2012 15:38 PM
    Guru51475 points

    Sorry for the delay ...

    MARTIN Olivier
    What's wrong with this code ?

    The code has no problems I can see.  Are you sure you have allocated enough stack and heap?  

    Thanks and regards,

    -George


    TI C/C++ Compiler Forum Moderator
    Please click Verify Answer on the best reply to your question.
    The Compiler Wiki answers most common questions.
    Track an issue with SDOWP. Enter your bug id in the "Find Record ID" box.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • MARTIN Olivier
    Posted by MARTIN Olivier
    on Mar 19 2012 19:00 PM
    Prodigy60 points

    Yes, I'm sure stack and heap size are sufficient and I remind you that scanf with %f works very well. it s so strange.... Nobody has reported this issue ?

    Thank you very much,

    Olivier

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Archaeologist
    Posted by Archaeologist
    on Mar 20 2012 09:46 AM
    Mastermind40810 points

    No, it does not look familiar.  Are you sure you are using the sscanf that comes from the RTS library?  Please generate the linker map file (with the --map_file linker option) and post that here.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • MARTIN Olivier
    Posted by MARTIN Olivier
    on Mar 21 2012 04:38 AM
    Prodigy60 points

    It seems that sscanf comes from RTS lib according to the following map-file :

    2063.mapFile.txt

    but is rts2800_fpu_eh is the correct lib ? (experimenter kit F28069)

    Olivier

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Archaeologist
    Posted by Archaeologist
    on Mar 21 2012 09:33 AM
    Mastermind40810 points

    I don't know anything about that kit, so I can't say whether that is the correct library.

    From the map file, I note your stack is only of size 0x100, which is quite small.  Please try increasing it to 0x500.

    Also, the stack is at location 0x0, which is scary; it is conceivable that something in the library might mistake that for the NULL pointer, so you might want to consider restricting the M01SARAM to addresses 0x1 - 0x800

    These might not be related to the problem, but it would be helpful to rule them out as causes.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • MARTIN Olivier
    Posted by MARTIN Olivier
    on Mar 22 2012 10:59 AM
    Prodigy60 points

    I really appreciate your help. You are totally right, the size of the stack and its location were not correct but it still doesn t work.

    Thus, I have try an other project (non bios) in opening  usb_dev_keyboard and I encounter a new but similar pb : 

    UARTprintf("hello%d",123);

    return : hello8109848

    you can find map file below :

    http://e2e.ti.com/cfs-file.ashx/__key/CommunityServer-Discussions-Components-Files/343/3730.usb_5F00_dev_5F00_keyboard.txt

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Archaeologist
    Posted by Archaeologist
    on Mar 22 2012 11:22 AM
    Mastermind40810 points

    UARTprintf is not part of the compiler's run time support library; I can't say much about it.

    My guess is that you don't have a prototype for UARTprintf in scope.  Are you sure you included the correct header file?

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • MARTIN Olivier
    Posted by MARTIN Olivier
    on Mar 28 2012 10:40 AM
    Prodigy60 points

    Hi !

    I think that the problem came from the types char and int of the Piccolo 28x family.

    char and int are 16-bits long

    unsigned long is 32bits long

    In the code of uartstdio.c [line 983]

    case 'c': {

                        // Get the value from the varargs.
    ulValue = va_arg(vaArgP, unsigned long); // can't work with a char !  
     it should be replaced by: char c=va_arg(vaArgP,char); UARTwrite(&c, 1);
                     
    // Print out the character.
    UARTwrite((char *)&ulValue, 1);

    ...

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Archaeologist
    Posted by Archaeologist
    on Mar 28 2012 11:17 AM
    Mastermind40810 points

    MARTIN Olivier
    va_arg(vaArgP,char)

    Technically, that is not strictly legal C code.  If a char is passed to a variadic function, it is promoted to int or unsigned int, so that code should be:

    va_arg(vaArgP,int)

    I realize that it makes no difference for C2000, but the code is strictly legal with "int", and therefore more portable.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
TI E2E™ Community
  • Support Forums
  • Blogs
  • Videos
  • Groups
  • Site Support & Feedback
  • Settings
TI E2E™ Community Groups
  • TI University Program
  • Make the Switch
  • Microcontroller Projects
  • Motor Drive & Control
Other Communities
  • Deyisupport
  • Designsomething.org
  • beagleboard.org
  • TI on Element 14
  • TI on TechXchangeSM
Other Technical & Support Resources
  • WEBENCH® Design Center
  • Product Information Centers
  • Technical Documents
  • TI Design Network
  • TI Technical Articles
  • TI Training

All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
embedded processors, along with software, tools and the industry’s largest sales/support staff.

© Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy Policy | Terms of Use