Using std::cout in V 3.0.0 for MODM7AE70

Discussion to talk about software related topics only.
Post Reply
ecasey
Posts: 164
Joined: Sat Mar 26, 2011 9:34 pm

Using std::cout in V 3.0.0 for MODM7AE70

Post by ecasey »

std::cout does not do a carriage return (\r) for output in MTTTY on my Windows 10 machine.
Previous versions always did.

For the code:

Code: Select all

    while (1)    {
        OSTimeDly(TICKS_PER_SECOND);
       std::cout << "one "<<endl << "two "<< endl ;
    }
}
I get this in the MTTTY window:

Code: Select all

one
    two
        one
            two
                one
                    two
                        one
                            two
                                one
                                    two 
It std::endl seems to work fine from within a std::stream, for example, the code:

Code: Select all

    std::ostringstream Reading;
    Reading <<"one "<<std::endl << "two "<< std::endl ;
    while (1)
    {
        OSTimeDly(TICKS_PER_SECOND);
       std::cout << Reading.str() <<"three "<< std::endl ;
    }
}
gives this output:

Code: Select all

one
two
three
      one
two
three
      one
two
three
I think std::endl should be consistent between std::streams and std::cout. That would save me having to put a "\r" into every std::cout statement.

Ed
User avatar
pbreed
Posts: 1080
Joined: Thu Apr 24, 2008 3:58 pm

Re: Using std::cout in V 3.0.0 for MODM7AE70

Post by pbreed »

By definition in the C++ standard endl is \n....

The init call is supposed to modify stdout so \n turns into \r\n automagicall...

Is this happening after the init call?
(need to dig some more, there were some issue here and it may be broken again)
ecasey
Posts: 164
Joined: Sat Mar 26, 2011 9:34 pm

Re: Using std::cout in V 3.0.0 for MODM7AE70

Post by ecasey »

Yes it is after init() call. Here is the whole thing.

Code: Select all

void UserMain(void *pd)
{
    init();                                       // Initialize network stack
    StartHttp();                                  // Start web server, default port 80
    WaitForActiveNetwork();

    iprintf("Application: %s\r\nNNDK Revision: %s\r\n", AppName, GetReleaseTag());
    ostringstream Reading;
    Reading <<"one "<<endl << "two "<< endl ;
    while (1)
    {
        OSTimeDly(TICKS_PER_SECOND);
       std::cout << Reading.str() <<"three "<< endl ;
    }
}
User avatar
pbreed
Posts: 1080
Joined: Thu Apr 24, 2008 3:58 pm

Re: Using std::cout in V 3.0.0 for MODM7AE70

Post by pbreed »

Have a fix, please submit a support ticket and I'll send you a patched file.
Post Reply