Need Help with serial interface
Reinhard
Posts: 489
Hi,
today I tried several demos, any from myself and other from here in the forum, which use getchar, gets, fgets and so on,
which wait for an input from serial line.
All this programs work fine if I use the built in terminal from propeller-load.(!)
But no one works with other terminal programs like parallax terminal , hyperterminal or other usuall terminalprograms.
Yes, I have adjust the port, baudrate and other parameters correct.
Commands like printf, putc, puts works correct.
I spend hours about this problem and maybe now I am blind for this.
Can anybody confirm this, or is it my mistake ?
I see no reason and can not explain this.
best regards,
Reinhard
today I tried several demos, any from myself and other from here in the forum, which use getchar, gets, fgets and so on,
which wait for an input from serial line.
All this programs work fine if I use the built in terminal from propeller-load.(!)
But no one works with other terminal programs like parallax terminal , hyperterminal or other usuall terminalprograms.
Yes, I have adjust the port, baudrate and other parameters correct.
Commands like printf, putc, puts works correct.
I spend hours about this problem and maybe now I am blind for this.
Can anybody confirm this, or is it my mistake ?
I see no reason and can not explain this.
best regards,
Reinhard
Comments
Thanks,
Reinhard
I know this sounds a little bit hmm ... curious.
for example this snippet :
gets(Buffer); // see the echo
i = atoi(Buffer);
printf("i=%d\n",i); // see no printf !
I take the demo from jazzed, make float to int, for avoid memory problems on my lmm board.
what I see is the
printf("Commands %s then number1 number2.", cmdchars);
and not more ...
For remember with propeller-load it works ?!
but not with parallax terminal
No , make not a difference
\myC\propeller_chip\gcc\calc>propeller-load -pcom7 -t -e calc.elf
Propeller Version 1 on com7
Writing 31668 bytes to EEPROM.
Verifying ... Upload OK!
[ Entering terminal mode. Type ESC or Control-C to exit. ]
5
Very Simple Propeller Calculator Demo
Commands +, -, *, /, or q then number1 number2.
Command? +
Enter first number: 1
Enter second number: 2
1 + 2 = 3
Command? q
What I see with Parallax Terminal:
Very Simple Propeller Calculator Demo
Commands +, -, *, /, or q then number1 number2.
Command? +
and nothing more ...
But this is only a example, other demos show the same behaviour (hmm)
Thanks for effort, I have no trouble, only wonder
Thanks Reinhard.
--Steve
have you run the toggle demo? That works from GtkTerm w/ the settings of 115200, 8n1 none. Fedora Core 16, Fibo will not output anything. Fibo will output using the loader terminal mode.
Frank
If I remember right, the toggle demos support no serial io.
So with this the phenomenon can't detect.
Actualy I have no propeller platform for test here, but I guess the problem can reduced to:
#include <stdio.h>
void foo ()
{
while(1)
putchar(getchar());
}
with propeller-load you see your input and the echo.
with other terminal programs ? ? ?
best regards,
Reinhard
Eric
I assume you're taking it. Can you file an issue?
Thanks,
--Steve
I filed an issue, and have checked in a fix that works for me -- it'd be great if some other people could double check this.
(It turns out a simple fix works, but it has to be in exactly the right place, namely before the character is written into the buffer.)
Thanks,
Eric
I have try to reduce the issue in a minimal test:
with this code the behaviour is reproducible:
#include <stdio.h>
unsigned char Buffer[10];
void main ()
{
unsigned char i,j;
while(1)
{
puts("\ngets\n ");
gets(Buffer);
printf("%s \n",Buffer);
}
}
works with propeller-load, not with parallax terminal, hyperterminal and zoc (termial emulator)
Thanks, Reinhard
Your analysis is correct , with this workaround the stdin works on all tested terminal programs.
Thanks for this info.
best regards,
Reinhard
One very annoying thing about some windows terminals is that we have to send \r\n to get a carriage-return/new-line. Just changing \r to \n doesn't really get it because some windows terminals translate things differently than Linux. I think the library has to send both \r and \n so windows stuff will work.
I've been holding back on a new test distribution because of license stuff. However, I think that if we have a reasonable fix for this, we should post a new test package before I go on my trip.
now I understand the reason for the command line options -D CR_ON_LF and -D NO_CR_TO_LF which used
by the Catalina C Compiler.
best regards,
Reinhard
Good idea. I've checked in a change to make terminal output do this, as well as the fix for the issue Reinhard discovered.
Eric
I'm afraid we'll need to add a putbyte ...
I don't have anymore time to test today - sorry there's a turkey calling me.
Happy Thanksgiving to all !
Have a Happy Thanksgiving!
Eric
@David, I'm not sure what the consensus should be exactly, but it would be really nice if our terminal behavior matched what is expected of the PST default behavior - unless there is proof that PST is wrong. The terminal behaviour not a perfect match with PST yet, but it is certainly workable.
@Kevin, using the built-in propeller-load terminal is mostly a convenience. It makes certain things easy.