propeller-load terminal and carriage return / newline
Rayman
Posts: 14,665
Just noticed the terminal and demos were probably written by non-Windows programmers...
Looks like it's rigged to work with "\n" and not "\r" for a new line...
So, my codes that were working fine with PST with just the "\r" are going to require changing to "\r\n"
to work in both places, I think...
Looks like it's rigged to work with "\n" and not "\r" for a new line...
So, my codes that were working fine with PST with just the "\r" are going to require changing to "\r\n"
to work in both places, I think...
Comments
So, I guess I have to put just "\n" to have it work right?
(if so, not sure I'm so happy about that...)
This is a long standing problem. Good starting point http://en.wikipedia.org/wiki/Newline
Having the serial driver replace \n with \r\n sounds a little strange to me. Is that what Linux does?
If not, I think we'd be better off without that... Can't you just have the terminal window treat \n as a newline with CR?
Is this "cooked" thing mean you are doing it in a non-standard way?
For now, I'll be happy if the "\r\n" combo in code works as I would expect the the loader's terminal...
Does Linux really send \r\n over a serial connection when given \n?
What do PropGCC and regular GCC do when writing to a file instead of serial port?
Does it then just do the \n character? Or, does it add the \r there too?
Eric: What is your opinion? Do you think this would help or just confuse things more?
I guess I'll be happy if "\r\n" works with the loader terminal. I think it will, sounds like treats the "\r" character properly, so having 2 of them probably makes no difference.
Actually, I guess it is PST that is behaving in a non-standard fashion by giving a newline with "\r"... Maybe that's something they could easily add an option to fix...
I think that would just confuse things more.
In C the \n character means "end of line"; it is *not* necessarily ASCII 10. The standard "hello, world" program is: (see Kernighan and Ritchie, page 7, or the first few Google hits for "C hello world"). There is no \r. K&R specifies that \n advances the cursor to the left margin of the next line. For many terminals, this means outputting the ASCII sequence 13, 10.
Eric
Edit: By the way, I don't really like what I'm suggesting. I'm just trying to find a way to make PropGCC work with the non-standard PST.
Do you have a reference that says this is the default behavior?
This page kinda suggests it only does this when told to with special commands:
http://frank.harvard.edu/~coldwell/terminals/
BTW: I found the loader works the way I want when fed "\r\n", so I'm happy the way it is.
And, I don't really see a need for using PST with PropGCC at the moment...
The ONLCR is what translates \n to \r \n.
Edit: By the way, I was wrong about this having to do with "cooked" mode. That only affects input not output but I believe it is responsible for \r being translated to \n on input.
Ok, So I feel happier about the situation now. Only thing that troubles me now is why my own SPIN code has just "\r" in it...
I must have been unknownly influenced by a Mac programmer...
By the way, I'm not saying that I like the Unix/Linux way of doing this. I'm just saying that it is probably what C programmers will expect.
Do you have the code snippet for "uncooking" the output?
This page has the input version, but not the output. http://propgcc.googlecode.com/hg/doc/Library.html