Momentics Console View - no stdin?

I’m running a program under Momentics that expects text input from the user.
The Console View doesn’t seem to handle this. Is this the expected
behavior, or can I configure it to handle text input properly?

For example…

#include <stdlib.h>
#include <stdio.h>

int main(int argc, char *argv[]) {
printf(“Welcome to the Momentics IDE\n”);
return EXIT_SUCCESS;
}

…prints “Welcome to the Momentics IDE” in the Console View, as you would
expect.

However, the example…

#include <stdlib.h>
#include <stdio.h>

int main(int argc, char *argv[]) {
printf("Welcome to the Momentics IDE… ");
while ( getchar() != ‘\n’ ) {
}
return EXIT_SUCCESS;
}

…doesn’t print anything into the Console View. If you try to type
characters in the Console View, it also does nothing. If you run it in a
Terminal Window, it works as expected—it prompts you with the Welcome, and
if you type characters and a CR, the program completes.

What’s up? Can I get the Console View to behave so I can use the debugging
features in Momentics?

Thanks.

– Celia

Celia <celiaonline@attbi.com> wrote:

The exact behaviour of the console view has changed a bit over the
releases of QNX Momentics, and still doesn’t properly handle all
terminal input/output.

You didn’t post which version you have, so my suggestion may or
may not work.

I’m running a program under Momentics that expects text input from the user.
The Console View doesn’t seem to handle this. Is this the expected
behavior, or can I configure it to handle text input properly?

It is…known (broken) behaviour. There is no configuration you can
do that will improve it. But…

However, the example…

#include <stdlib.h
#include <stdio.h

int main(int argc, char *argv[]) {

Try:
setvbuf( stdout, NULL, _IOLBF, 0 );

printf("Welcome to the Momentics IDE… ");
printf("Welcome to the Momentics IDE…\n ");

Or Try an:
fflush(stdout);

Those will get it to print.

while ( getchar() != ‘\n’ ) {
}
return EXIT_SUCCESS;
}

Though, I’m not sure what will happen with the getchar – I’d bet
the terminal view doesn’t send anything to the far side until
you hit enter.

Basically, the console view isn’t a fully functioning terminal
device.

…doesn’t print anything into the Console View. If you try to type
characters in the Console View, it also does nothing. If you run it in a
Terminal Window, it works as expected—it prompts you with the Welcome, and
if you type characters and a CR, the program completes.

What’s up? Can I get the Console View to behave so I can use the debugging
features in Momentics?

If you enforce the buffering (setvbuf), it will be more functional – but
it is a line-oriented device, it will not give you character at a time
input/output.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

It should work fine. Just click mouse to the first empty string (below the
last output).
One inconvenience: for version you are using now there maybe don’t see
printf output on IDE console if you don’t flush it from program.


“Celia” <celiaonline@attbi.com> wrote in message
news:bk2f0l$dtl$1@inn.qnx.com

I’m running a program under Momentics that expects text input from the
user.
The Console View doesn’t seem to handle this. Is this the expected
behavior, or can I configure it to handle text input properly?

For example…

#include <stdlib.h
#include <stdio.h

int main(int argc, char *argv[]) {
printf(“Welcome to the Momentics IDE\n”);
return EXIT_SUCCESS;
}

…prints “Welcome to the Momentics IDE” in the Console View, as you would
expect.

However, the example…

#include <stdlib.h
#include <stdio.h

int main(int argc, char *argv[]) {
printf("Welcome to the Momentics IDE… ");
while ( getchar() != ‘\n’ ) {
}
return EXIT_SUCCESS;
}

…doesn’t print anything into the Console View. If you try to type
characters in the Console View, it also does nothing. If you run it in a
Terminal Window, it works as expected—it prompts you with the Welcome,
and
if you type characters and a CR, the program completes.

What’s up? Can I get the Console View to behave so I can use the
debugging
features in Momentics?

Thanks.

– Celia

Thanks, David. For reference, I have Neutrino 6.2.1. I was able to get
setvbuf(stdout, NULL, _IONBF, 0); to work. (I didn’t try _IOLBF.)

– Celia

“David Gibbs” <dagibbs@qnx.com> wrote in message
news:bk4mv7$q0e$1@nntp.qnx.com

Celia <> celiaonline@attbi.com> > wrote:

The exact behaviour of the console view has changed a bit over the
releases of QNX Momentics, and still doesn’t properly handle all
terminal input/output.

You didn’t post which version you have, so my suggestion may or
may not work.

I’m running a program under Momentics that expects text input from the
user.
The Console View doesn’t seem to handle this. Is this the expected
behavior, or can I configure it to handle text input properly?

It is…known (broken) behaviour. There is no configuration you can
do that will improve it. But…

However, the example…

#include <stdlib.h
#include <stdio.h

int main(int argc, char *argv[]) {

Try:
setvbuf( stdout, NULL, _IOLBF, 0 );

printf("Welcome to the Momentics IDE… ");
printf("Welcome to the Momentics IDE…\n ");

Or Try an:
fflush(stdout);

Those will get it to print.

while ( getchar() != ‘\n’ ) {
}
return EXIT_SUCCESS;
}

Though, I’m not sure what will happen with the getchar – I’d bet
the terminal view doesn’t send anything to the far side until
you hit enter.

Basically, the console view isn’t a fully functioning terminal
device.

…doesn’t print anything into the Console View. If you try to type
characters in the Console View, it also does nothing. If you run it in
a
Terminal Window, it works as expected—it prompts you with the Welcome,
and
if you type characters and a CR, the program completes.

What’s up? Can I get the Console View to behave so I can use the
debugging
features in Momentics?

If you enforce the buffering (setvbuf), it will be more functional – but
it is a line-oriented device, it will not give you character at a time
input/output.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.