![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
hello188
Joined: 02 Jun 2010 Posts: 74
|
Putty and RS 232C question Question |
Posted: Tue Apr 26, 2011 1:59 am |
|
|
Hi, I am trying to make a simple program where the target board prompts the user(PC) to say something, and the user is suppose to return some strings.
The displaying of the character(TX from MCU to PC) works fine on Putty.
However, When I type something on Putty, they don't show but when I press
enter, they get transmitted to MCU and MCU gets it.
I don't know why the Putty is not showing the strings.
Anybody has idea?
Code: | #INCLUDE<18F46K22.h>
#FUSES HSH, NOPLLEN, NOIESO, PUT, NOBROWNOUT, NOWDT, NOPBADEN, MCLR, STVREN
#USE DELAY(clock = 14745600)//14.7456 MHz crystal for baud rate
char string[30];
void main(void){
#USE RS232(UART1, BAUD = 115200, PARITY = E, BITS = 8, STOP = 1)
setup_uart(115200);
set_uart_speed(115200);
while(1){
printf("Say something \n \r");//need both new line(LF) and carriage return
gets(string);
printf("You entered ");
printf(string);
printf("\n\r");
}
}
|
My compiler version is 4.120
Thanks
Thanks |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19366
|
|
Posted: Tue Apr 26, 2011 2:23 am |
|
|
First a comment. Lay things out slightly differently. Not 'critical', _but_ will prevent problems latter:
Code: |
//SETUP
#INCLUDE<18F46K22.h>
#FUSES HSH, NOPLLEN, NOIESO, PUT, NOBROWNOUT, NOWDT, NOPBADEN, MCLR, STVREN
#USE DELAY(clock = 14745600)//14.7456 MHz crystal for baud rate
#USE RS232(UART1, BAUD = 115200, PARITY = E, BITS = 8, STOP = 1)
//Now GLOBALs
char string[30];
void main(void){
//setup_uart(115200);
//set_uart_speed(115200); neither of these are needed - only if you want
//to change speed - then only one or the other, not both!....
while(1){
printf("Say something \n\r");
gets(string);
printf("You entered ");
printf(string);
printf("\n\r");
}
}
|
Now, one other change in this. /n/r, not /n /r.
Some terminal programs _require_ these to be adjacent to one another. May be your entire problem.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
hello188
Joined: 02 Jun 2010 Posts: 74
|
|
Posted: Tue Apr 26, 2011 2:56 am |
|
|
I am sorry, but it doesn't fix the problem.
When I tried AVR mega644 and scanf function from avrgcc, the cursor blinks as if prompting for response and all the characters I type display.
So, I am thinking maybe there should be a character(esacape sequece)
missing?
Of course, I can force the putty to display the characters I type instead of trying to decide on its own whether or not to display. But i want it to decide on its own correctly.
Thanks |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9173 Location: Greensville,Ontario
|
|
Posted: Tue Apr 26, 2011 5:26 am |
|
|
Is 8 bits AND Even Parity valid for PC hardware and PuTTY ?
Old school guys like me could only have 7 bits AND parity OR 8 bit data only. |
|
![](templates/subSilver/images/spacer.gif) |
hello188
Joined: 02 Jun 2010 Posts: 74
|
|
Posted: Tue Apr 26, 2011 10:33 am |
|
|
Yea, I think it is possible
It's 8 bit data + 1 parity bit + 1 stop bit |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19366
|
|
Posted: Tue Apr 26, 2011 1:58 pm |
|
|
OK.
I was slightly misunderstanding what you were saying was happening. I was getting it as the first string not displaying, but then when you sent the string 'back', it did.
Your problem sounds like local echo being off. This is normally controlled by ESC'E', if your copy is setup in the default mode. The alternative in a sense better, since it then proves that the link is working both ways), is to implement 'echo' yourself in the line input routine. There is an alternative function to gets, that does this for you, and is also better, in allowing you to limit the maximm lne length input, and avoid buffer overflows. Look at get_string in input.c.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
hello188
Joined: 02 Jun 2010 Posts: 74
|
|
Posted: Tue Apr 26, 2011 7:48 pm |
|
|
Thanks for the replies
What i didn't know was that Hyperterminal/Putty only supposed to display the characters recieved, and not the characters to be sent.
What most of the target devices communicating with PC does is that they echo the characters that they receive, so if you type "c", the MCU receives it and sends "c" again until carriage return.
Thanks |
|
![](templates/subSilver/images/spacer.gif) |
hello188
Joined: 02 Jun 2010 Posts: 74
|
|
Posted: Wed Apr 27, 2011 11:51 pm |
|
|
That "get_string()" function does just the right thing for me.
It's works virtually like the AVR-GCC's "scanf" function.
Thank's a lot Ttelmah!! |
|
![](templates/subSilver/images/spacer.gif) |
bkamen
Joined: 07 Jan 2004 Posts: 1611 Location: Central Illinois, USA
|
|
Posted: Fri Apr 29, 2011 10:19 am |
|
|
hello188 wrote: | Thanks for the replies
What i didn't know was that Hyperterminal/Putty only supposed to display the characters recieved, and not the characters to be sent.
What most of the target devices communicating with PC does is that they echo the characters that they receive, so if you type "c", the MCU receives it and sends "c" again until carriage return.
|
Yes. Once upon a time, we actually had use for "echo" (ATE1) being turned on.
If your remote application doesn't do it - it's still there.
However, if you want most people to turn on and go, make sure to always echo back stuff you want to be seen in the terminal. It doesn't happen automatically.
I use puTTY all the time. I love that program.
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9173 Location: Greensville,Ontario
|
|
Posted: Sat Apr 30, 2011 5:52 am |
|
|
What you are talking about is 'local echo', where the device shows you what is transmitted.Probably every 'terminal' program will have it as an option.
I always have it 'disabled' during a debug session,as you can be misled that the remote device is echoing it back,when really it's just the local echo.With local echo enabled and a loopback connector or program running, you'll see 2 copies of each character sent. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|