Jump to content
43oh

StringAdditionOperation shows garbage


Recommended Posts

Hello,

I just received my launchpad and I'm going through the examples supplied with Energia.

The StringAdditionOperator shows garbage after the first addition (I substituted * for the unprintable character that shows as a square in the serial monitor):

 

Adding strings together (concatenation):

stringThree = 123

ing*ngThree = *i

*Three

**g*ngThree = *

**g*ngThree = *i

 

**ringTh123456789*

Link to post
Share on other sites

msp430 indeed has very little ram to go on and dynamic memory (re)allocation as used by the WString lib has to be used with care and avoided if at all possible.

 

With that said, this code should have worked just fine since there is plenty of ram left in a small Sketch like this. The culprit is that realloc() was replaced by alloc() due to lack of realloc() in mspgcc. This leeds to all kinds of issues since the original string is not preserved which results in garbage in the serial output. Will look into a fix for the next release. Bug is files as: https://github.com/energia/Energia/issues/113

 

Thanks for the report!

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...