Serial.print Problems

For some unknown reason two distinctly different print statements are becoming smashed together. What I mean is that the serial.monitor is printing part of another message within one of my other print statements.

Ex:" rmal : Active0ion Status : Not ActiveStatus : Not Active253Not Active24917 "

The above line is direct from my serial.monitor and should print the value obtained from my working accelerometer, hence the numbers. Instead, it is being muddled by a previous part of code that determines the status of another connected system, hence the active, not active statements.

Does anyone have any idea what may be causing this?

So far as I can tell, it seems like the code I wrote is trying to execute two prints statements within the window time it takes to fully complete a single print statement. Could this be true? If so how do I make sure that a new Serial.print does start until the first is finished. Thanks

Does anyone have any idea what maybe causing this?

Probably bad code.

well obviously. lol I know ive messed something up. All I know is that I added in another layer of subroutines and now I have this bleeding effect. Any ideas what could be the problem?

Any ideas what could be the problem?

I'd probably put money on it being something to do with your code.

Is there a way to make the Serial.print function wait until its done printing the first statement before starting the second?

That is exactly how it works.

So then why would this even be happening? Its not like im doing anything crazy in my code. Its all just a polling system for various sensors. I am basically making a black box device. It checks whether the received value makes sense if it does not it branches into other functions that check if other parts are working to determine whether the error was a false positive or not.

So then why would this even be happening

Maybe there's something wrong with your code.

Enough discussing and no code. Post the code.

Its not like im doing anything crazy in my code.

My cat Runt is saying something different.

Unfortunately, I cant do that, without having my company clear it for release. Thats why I havent post any.
Thank you all for your input, I do appreciate it.

Unfortunately, I cant do that, without having my company clear it for release.

Guess they are getting what they pay for at the free store. ;)

That...could have gone better.

That…could have gone better.

Always best to be up front with the situation instead of being perceived as being somewhere between clueless and intentionally evasive.

I could not agree more!

Still, I think we've all wasted enough time on this one.

I apologize for seeming evasive. I thought that my original post was more than explanatory enough of what the problem was or could be.

Based on the description I could give. Does anyone have any advice on how I might resolve this? or try debugging it? I have been self teaching my self how to use all this stuff for the last few weeks. So therefore I do not have a proper coding background in C++.

Important C programming lesson: Most programming languages allow you to shoot yourself in the foot. C hands you the loaded gun.

The problem is difficult because there's so many areas that might be an issue (or might not):

  • do you have an interrupt issue, with conflicts of some sort?

  • are you not initializing a variable properly, perhaps leaving the old message in it?

  • are you trying to do something really nonstandard and coming up with a glitch no one has encountered before?

  • are you mistaken in the message, or leaving out a clue that would make everyone know the answer right away?

I could go on for pages - which is exactly why everyone is asking for source code - so as to narrow down the problem. Trying to solve based on one error message (or two) you created yourself is really shooting in the dark.

To put it in non-programming terms - if I brought a car into a mechanic and said "when I turn on the radio the car doesn't run properly", where would he (or she) start?

AWOL: Important C programming lesson: Most programming languages allow you to shoot yourself in the foot. C hands you the loaded gun.

C++ would "prevent" you from doing some stupid things but you can still define a gun class and a foot class and call my_gun.shoot(new foot(left)); ;)

Either the sender or the receiver could have messed up the string. Without the code, I can only suggest you to isolate the two, say use a known program to test the string received to make sure the receiving end of your code is not messing up the string.

I am using an interrupt but I have already commented it out and got the same result. I am not loading a new value to a message string. Instead I am using a separate print statement.

To my knowledge im not leaving anything out. All I know is that I had this problem with my gps values leeching into the strings and determined it was the interrupt that was the problem. fixed that. and now its happening again but worse. and i havent changed anything but added a shit ton of if statements with simple conditions like if sensor value == 1 print " on" if value == 0 print "off".

the real head scratcher for me is that the two different print statements are dependent on two very different variables that are not in any way linked other than sequential order.