MrP 1 Posted April 21, 2014 Share Posted April 21, 2014 I want to read a line of input from the Code Composer Studio (CCS) console using an MSP430 I am able to get printf( tripwire 1 Quote Link to post Share on other sites
tripwire 139 Posted April 21, 2014 Share Posted April 21, 2014 This turned out to be an interesting one, and you're probably going to kick yourself when you see why fgets wasn't working for you... Initially my gut feeling was that there was no support for reading from the console window on the target*. Having dug a little further I found that the CIO system does support reading from the target side, so I set up a test program to try it out. It didn't work. I noticed that you'd mentioned setting the heap size, so I set mine. That fixed printf but not fgets. Stepping into the library code revealed that the problem was with allocating the stream buffer for stdin. I'd set the heap to 512 bytes, and each stream requires 256 bytes buffer space plus 32 bytes of header. The printf call was allocating a buffer for stdout and then the heap had insufficient space to allocate a buffer for stdin. While printf causes the program to exit when it fails to initialise the buffer, fgets and getc just return immediately. Setting the heap size greater than 576 bytes fixed the issue for me. * Mainly because I've never seen anyone else even try it - stdio.h is commonly regarded as being a bit "heavyweight" for MSP430. The default stream buffer size is bigger than the ram on the msp430g2553! Most example code I've seen uses the UART backchannel instead, or at least a very cut-down printf implementation with a much smaller buffer. bluehash, MrP, oPossum and 1 other 4 Quote Link to post Share on other sites
MrP 1 Posted April 23, 2014 Author Share Posted April 23, 2014 tripwire, thanks for thinking about my question and taking the time to investigate and figure out the issue! Set my heap > 576 and it worked like a charm. I am using the printf(...) and fgets(...) to enable a simple command line interpreter from the CCS debugger. This allows me to dynamically read/write to I2C slaves, trigger interrupts, start timers, do resets to other chips on my board etc Quote Link to post Share on other sites
bluehash 1,581 Posted April 23, 2014 Share Posted April 23, 2014 Thanks! Moving to the IDE/compiler section. Quote Link to post Share on other sites
tripwire 139 Posted February 8, 2015 Share Posted February 8, 2015 I am curious as to where you got the specific code for the fgets.c for a specific MSP430xxx? In my CCS environment trying to step into those routines I don't have the source but can see the assembly. I used Eclipse in the past for other development so attaching source and such is a familiar activity. I just noticed that I never got around to answering this question. Sorry about that! In case anyone else finds this post in future and wants to know where the library source code lives, you should find it in: {CCS Install Folder}\ccsv6\tools\compiler\msp430_4.3.5\lib\src The "ccsv6" and "msp430_4.3.5" parts of the path might have different version numbers depending on your CCS install. If that folder doesn't exist or is empty, look in the \lib folder and there will be an rtssrc.zip that you can unpack to get the full source. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.